internal/task: move NewTaskRequest.Properties into TaskSlices field

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>
This commit is contained in:
Dmitri Shuralyov 2024-11-01 16:27:17 -04:00 коммит произвёл Gopher Robot
Родитель 369b10322c
Коммит 13e69a8bdc
1 изменённых файлов: 23 добавлений и 19 удалений

Просмотреть файл

@ -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 {