in fast-build-update-tool/internal/runner/fleet_updater.go [188:219]
func (f *FleetUpdater) updateInstances(ctx context.Context, instances []*gamelift.Instance, sshKey ssh.Signer, sshPort int32, os config.OperatingSystem, updateScript string) (*FleetUpdateResults, error) {
f.logger.Debug("updating instances in GameLift fleet")
f.reportWriter.StartUpdatingInstances(len(instances))
results := &FleetUpdateResults{
InstancesFound: len(instances),
InstancesFailedUpdate: make([]string, 0, len(instances)),
}
for _, instance := range instances {
err := f.updateInstance(ctx, sshKey, sshPort, updateScript, instance)
if err != nil {
// If we fail to update an instance, log the error and continue. We may still be able to update other instances in the fleet
slog.Error("Error updating remote instance", "error", err, "instanceId", instance.InstanceId)
results.InstancesFailedUpdate = append(results.InstancesFailedUpdate, instance.InstanceId)
continue
}
results.InstancesUpdated = results.InstancesUpdated + 1
}
// We're done updating instances, write the report out for the user
f.reportWriter.ReportResults(results)
// If any instances failed to update, ensure that we return an error
if len(results.InstancesFailedUpdate) > 0 {
return results, UpdateFailedError
}
return results, nil
}