From 77a5bd3672ea09396c79f9ee5eea7380cc95ab74 Mon Sep 17 00:00:00 2001 From: Stan Rosenberg Date: Fri, 12 May 2023 14:29:33 +0000 Subject: [PATCH] roachprod: fix regression in propagateDiskLabels Previous PR [1] fixed data races, and as a result of refactoring, introduced another bug. When multiple zones are used, the `--zone` arg. is duplicated across all hosts. Epic: none Release note: None [1] https://github.com/cockroachdb/cockroach/pull/103087 --- pkg/roachprod/vm/gce/gcloud.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/roachprod/vm/gce/gcloud.go b/pkg/roachprod/vm/gce/gcloud.go index 363f9a81ff70..02a87281e272 100644 --- a/pkg/roachprod/vm/gce/gcloud.go +++ b/pkg/roachprod/vm/gce/gcloud.go @@ -866,15 +866,16 @@ func propagateDiskLabels( argsPrefix = append(argsPrefix, "--project", project) for zone, zoneHosts := range zoneToHostNames { - argsPrefix = append(argsPrefix, "--zone", zone) + zoneArg := []string{"--zone", zone} for _, host := range zoneHosts { - host := host + hostName := host g.Go(func() error { - args := append([]string(nil), argsPrefix...) + bootDiskArgs := append([]string(nil), argsPrefix...) + bootDiskArgs = append(bootDiskArgs, zoneArg...) // N.B. boot disk has the same name as the host. - bootDiskArgs := append(args, host) + bootDiskArgs = append(bootDiskArgs, hostName) cmd := exec.Command("gcloud", bootDiskArgs...) output, err := cmd.CombinedOutput() @@ -886,9 +887,10 @@ func propagateDiskLabels( if !opts.SSDOpts.UseLocalSSD { g.Go(func() error { - args := append([]string(nil), argsPrefix...) + persistentDiskArgs := append([]string(nil), argsPrefix...) + persistentDiskArgs = append(persistentDiskArgs, zoneArg...) // N.B. additional persistent disks are suffixed with the offset, starting at 1. - persistentDiskArgs := append(args, fmt.Sprintf("%s-1", host)) + persistentDiskArgs = append(persistentDiskArgs, fmt.Sprintf("%s-1", hostName)) cmd := exec.Command("gcloud", persistentDiskArgs...) output, err := cmd.CombinedOutput()