Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
103191: roachprod: fix regression in propagateDiskLabels r=renatolabs a=srosenberg

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] cockroachdb#103087

Co-authored-by: Stan Rosenberg <stan@cockroachlabs.com>
  • Loading branch information
craig[bot] and srosenberg committed May 12, 2023
2 parents 81a3824 + e676243 commit 957e51e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/roachprod/vm/gce/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,15 +886,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()
Expand All @@ -906,9 +907,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()
Expand Down

0 comments on commit 957e51e

Please sign in to comment.