Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fcfe31040 | ||
|
|
bc6c5ed3e8 | ||
|
|
c250298318 | ||
|
|
14887afcce |
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright GitHub, Inc.
|
Copyright (c) 2025 GitHub
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"maps"
|
"maps"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -126,9 +127,9 @@ type ProxyFunc func(req *http.Request) (*url.URL, error)
|
|||||||
type SystemInfo struct {
|
type SystemInfo struct {
|
||||||
// System is the name of the scale set implementation
|
// System is the name of the scale set implementation
|
||||||
System string `json:"system"`
|
System string `json:"system"`
|
||||||
// Version is the version of the client
|
// Version is the version of the controller
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
// CommitSHA is the git commit SHA of the client
|
// CommitSHA is the git commit SHA of the controller
|
||||||
CommitSHA string `json:"commit_sha"`
|
CommitSHA string `json:"commit_sha"`
|
||||||
// ScaleSetID is the ID of the scale set
|
// ScaleSetID is the ID of the scale set
|
||||||
ScaleSetID int `json:"scale_set_id"`
|
ScaleSetID int `json:"scale_set_id"`
|
||||||
@@ -222,7 +223,6 @@ type userAgent struct {
|
|||||||
SystemInfo
|
SystemInfo
|
||||||
BuildVersion string `json:"build_version"`
|
BuildVersion string `json:"build_version"`
|
||||||
BuildCommitSHA string `json:"build_commit_sha"`
|
BuildCommitSHA string `json:"build_commit_sha"`
|
||||||
Kind string `json:"kind"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) newGitHubAPIRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) {
|
func (c *Client) newGitHubAPIRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) {
|
||||||
@@ -836,6 +836,8 @@ func (c *Client) getActionsServiceAdminConnection(ctx context.Context, rt *regis
|
|||||||
return nil, fmt.Errorf("failed to get actions service admin connection: %w", err)
|
return nil, fmt.Errorf("failed to get actions service admin connection: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.Info("got admin connection", *adminConnection.ActionsServiceURL)
|
||||||
|
|
||||||
return adminConnection, nil
|
return adminConnection, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ func (c *commonClient) setUserAgent() {
|
|||||||
SystemInfo: c.systemInfo,
|
SystemInfo: c.systemInfo,
|
||||||
BuildVersion: buildInfo.version,
|
BuildVersion: buildInfo.version,
|
||||||
BuildCommitSHA: buildInfo.commitSHA,
|
BuildCommitSHA: buildInfo.commitSHA,
|
||||||
Kind: "scaleset",
|
|
||||||
})
|
})
|
||||||
c.userAgent = string(b)
|
c.userAgent = string(b)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ func TestUserAgent(t *testing.T) {
|
|||||||
SystemInfo: testSystemInfo,
|
SystemInfo: testSystemInfo,
|
||||||
BuildCommitSHA: sha,
|
BuildCommitSHA: sha,
|
||||||
BuildVersion: version,
|
BuildVersion: version,
|
||||||
Kind: "scaleset",
|
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(wantInfo)
|
b, err := json.Marshal(wantInfo)
|
||||||
require.NoError(t, err, "failed to marshal expected user agent")
|
require.NoError(t, err, "failed to marshal expected user agent")
|
||||||
@@ -145,7 +144,6 @@ func TestUserAgent(t *testing.T) {
|
|||||||
SystemInfo: userAgentInfo,
|
SystemInfo: userAgentInfo,
|
||||||
BuildCommitSHA: sha,
|
BuildCommitSHA: sha,
|
||||||
BuildVersion: version,
|
BuildVersion: version,
|
||||||
Kind: "scaleset",
|
|
||||||
}
|
}
|
||||||
b, err = json.Marshal(wantInfo)
|
b, err = json.Marshal(wantInfo)
|
||||||
require.NoError(t, err, "failed to marshal expected user agent after SetSystemInfo")
|
require.NoError(t, err, "failed to marshal expected user agent after SetSystemInfo")
|
||||||
|
|||||||
@@ -74,35 +74,40 @@ func run(ctx context.Context, c Config) error {
|
|||||||
runnerGroupID = runnerGroup.ID
|
runnerGroupID = runnerGroup.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.Info("creating scale set")
|
||||||
|
|
||||||
// Create the runner scale set
|
// Create the runner scale set
|
||||||
scaleSet, err := scalesetClient.CreateRunnerScaleSet(ctx, &scaleset.RunnerScaleSet{
|
scaleSet, err := scalesetClient.CreateRunnerScaleSet(ctx, &scaleset.RunnerScaleSet{
|
||||||
Name: c.ScaleSetName,
|
Name: c.ScaleSetName,
|
||||||
RunnerGroupID: runnerGroupID,
|
RunnerGroupID: runnerGroupID,
|
||||||
Labels: c.BuildLabels(),
|
Labels: []scaleset.Label{},
|
||||||
RunnerSetting: scaleset.RunnerSetting{
|
RunnerSetting: scaleset.RunnerSetting{
|
||||||
DisableUpdate: true,
|
DisableUpdate: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
slog.Error("failed to create", err)
|
||||||
return fmt.Errorf("failed to create runner scale set: %w", 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
|
// Set the user agent for the scaleset client now that we have the scale set ID
|
||||||
scalesetClient.SetSystemInfo(systemInfo(scaleSet.ID))
|
scalesetClient.SetSystemInfo(systemInfo(scaleSet.ID))
|
||||||
|
|
||||||
defer func() {
|
// defer func() {
|
||||||
logger.Info(
|
// logger.Info(
|
||||||
"Deleting runner scale set",
|
// "Deleting runner scale set",
|
||||||
slog.Int("scaleSetID", scaleSet.ID),
|
// slog.Int("scaleSetID", scaleSet.ID),
|
||||||
)
|
// )
|
||||||
if err := scalesetClient.DeleteRunnerScaleSet(context.WithoutCancel(ctx), scaleSet.ID); err != nil {
|
// if err := scalesetClient.DeleteRunnerScaleSet(context.WithoutCancel(ctx), scaleSet.ID); err != nil {
|
||||||
slog.Error(
|
// slog.Error(
|
||||||
"Failed to delete runner scale set",
|
// "Failed to delete runner scale set",
|
||||||
slog.Int("scaleSetID", scaleSet.ID),
|
// slog.Int("scaleSetID", scaleSet.ID),
|
||||||
slog.String("error", err.Error()),
|
// slog.String("error", err.Error()),
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
}()
|
// }()
|
||||||
|
|
||||||
dockerClient, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv, dockerclient.WithAPIVersionNegotiation())
|
dockerClient, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv, dockerclient.WithAPIVersionNegotiation())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user