|
|
|
@@ -74,35 +74,40 @@ func run(ctx context.Context, c Config) error {
|
|
|
|
|
runnerGroupID = runnerGroup.ID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slog.Info("creating scale set")
|
|
|
|
|
|
|
|
|
|
// Create the runner scale set
|
|
|
|
|
scaleSet, err := scalesetClient.CreateRunnerScaleSet(ctx, &scaleset.RunnerScaleSet{
|
|
|
|
|
Name: c.ScaleSetName,
|
|
|
|
|
RunnerGroupID: runnerGroupID,
|
|
|
|
|
Labels: c.BuildLabels(),
|
|
|
|
|
Labels: []scaleset.Label{},
|
|
|
|
|
RunnerSetting: scaleset.RunnerSetting{
|
|
|
|
|
DisableUpdate: true,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
slog.Error("failed to create", err)
|
|
|
|
|
return fmt.Errorf("failed to create runner scale set: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slog.Info("created")
|
|
|
|
|
|
|
|
|
|
// Set the user agent for the scaleset client now that we have the scale set ID
|
|
|
|
|
scalesetClient.SetSystemInfo(systemInfo(scaleSet.ID))
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
|
logger.Info(
|
|
|
|
|
"Deleting runner scale set",
|
|
|
|
|
slog.Int("scaleSetID", scaleSet.ID),
|
|
|
|
|
)
|
|
|
|
|
if err := scalesetClient.DeleteRunnerScaleSet(context.WithoutCancel(ctx), scaleSet.ID); err != nil {
|
|
|
|
|
slog.Error(
|
|
|
|
|
"Failed to delete runner scale set",
|
|
|
|
|
slog.Int("scaleSetID", scaleSet.ID),
|
|
|
|
|
slog.String("error", err.Error()),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
// defer func() {
|
|
|
|
|
// logger.Info(
|
|
|
|
|
// "Deleting runner scale set",
|
|
|
|
|
// slog.Int("scaleSetID", scaleSet.ID),
|
|
|
|
|
// )
|
|
|
|
|
// if err := scalesetClient.DeleteRunnerScaleSet(context.WithoutCancel(ctx), scaleSet.ID); err != nil {
|
|
|
|
|
// slog.Error(
|
|
|
|
|
// "Failed to delete runner scale set",
|
|
|
|
|
// slog.Int("scaleSetID", scaleSet.ID),
|
|
|
|
|
// slog.String("error", err.Error()),
|
|
|
|
|
// )
|
|
|
|
|
// }
|
|
|
|
|
// }()
|
|
|
|
|
|
|
|
|
|
dockerClient, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv, dockerclient.WithAPIVersionNegotiation())
|
|
|
|
|
if err != nil {
|
|
|
|
|