Skip to content

Commit

Permalink
internal/task: move NewTaskRequest.Properties into TaskSlices field
Browse files Browse the repository at this point in the history
The top-level Properties field is deprecated¹ in favor of using
TaskSlices[0].Properties, so start using the new approach, as
already done in the ./internal/gomote package. The same applies
to the ExpirationSecs² field.

¹ https://pkg.go.dev/go.chromium.org/luci@v0.0.0-20241101193118-2a5f92ed1087/swarming/proto/api_v2#NewTaskRequest.Properties
² https://pkg.go.dev/go.chromium.org/luci@v0.0.0-20241101193118-2a5f92ed1087/swarming/proto/api_v2#NewTaskRequest.ExpirationSecs

Change-Id: Icfcac66f83e61790b4507b8eb5f8170dbcbfe194
Reviewed-on: https://go-review.googlesource.com/c/build/+/623822
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
dmitshur authored and gopherbot committed Nov 5, 2024
1 parent 369b103 commit 13e69a8
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions internal/task/swarming.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,41 @@ func (c *RealSwarmingClient) RunTask(ctx context.Context, dims map[string]string

req := &apipb.NewTaskRequest{
Name: "relui task",
ExpirationSecs: 3 * 60 * 60,
Priority: 20,
User: "relui",
ServiceAccount: c.ServiceAccount,
Realm: c.Realm,

Properties: &apipb.TaskProperties{
EnvPrefixes: []*apipb.StringListPair{
{Key: "PATH", Value: []string{"tools/bin"}},
},
Env: []*apipb.StringPair{},
Command: append(append([]string{"luci-auth", "context"}, shell...), script),
CipdInput: &apipb.CipdInput{
Packages: []*apipb.CipdPackage{
{Path: "tools/bin", PackageName: "infra/tools/luci-auth/" + cipdPlatform, Version: "latest"},
{Path: "tools", PackageName: "golang/bootstrap-go/" + cipdPlatform, Version: "latest"},
{Path: "tools", PackageName: "infra/3pp/tools/gcloud/" + cipdPlatform, Version: "latest"},
{Path: "tools", PackageName: "infra/3pp/tools/cpython3/" + cipdPlatform, Version: "latest"},
TaskSlices: []*apipb.TaskSlice{
{
Properties: &apipb.TaskProperties{
EnvPrefixes: []*apipb.StringListPair{
{Key: "PATH", Value: []string{"tools/bin"}},
},
Env: []*apipb.StringPair{},
Command: append(append([]string{"luci-auth", "context"}, shell...), script),
CipdInput: &apipb.CipdInput{
Packages: []*apipb.CipdPackage{
{Path: "tools/bin", PackageName: "infra/tools/luci-auth/" + cipdPlatform, Version: "latest"},
{Path: "tools", PackageName: "golang/bootstrap-go/" + cipdPlatform, Version: "latest"},
{Path: "tools", PackageName: "infra/3pp/tools/gcloud/" + cipdPlatform, Version: "latest"},
{Path: "tools", PackageName: "infra/3pp/tools/cpython3/" + cipdPlatform, Version: "latest"},
},
},
Dimensions: []*apipb.StringPair{
{Key: "pool", Value: c.Pool},
},
ExecutionTimeoutSecs: 600,
},
ExpirationSecs: 3 * 60 * 60,
},
Dimensions: []*apipb.StringPair{
{Key: "pool", Value: c.Pool},
},
ExecutionTimeoutSecs: 600,
},
}
for k, v := range dims {
req.Properties.Dimensions = append(req.Properties.Dimensions, &apipb.StringPair{Key: k, Value: v})
req.TaskSlices[0].Properties.Dimensions = append(req.TaskSlices[0].Properties.Dimensions, &apipb.StringPair{Key: k, Value: v})
}
for k, v := range env {
req.Properties.Env = append(req.Properties.Env, &apipb.StringPair{Key: k, Value: v})
req.TaskSlices[0].Properties.Env = append(req.TaskSlices[0].Properties.Env, &apipb.StringPair{Key: k, Value: v})
}
task, err := c.SwarmingClient.NewTask(ctx, req)
if err != nil {
Expand Down

0 comments on commit 13e69a8

Please sign in to comment.