Skip to content

Commit

Permalink
roachprod: fix regression in propagateDiskLabels
Browse files Browse the repository at this point in the history
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
  • Loading branch information
srosenberg committed May 12, 2023
1 parent 2e2e5c1 commit e676243
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 e676243

Please sign in to comment.