Skip to content

Commit

Permalink
[ci skip] 2024.07.26-30408
Browse files Browse the repository at this point in the history
  • Loading branch information
cybozu-neco committed Jul 26, 2024
2 parents 9e0e93b + 36a9e7a commit d479a89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dctest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SUDO = sudo
OUTPUT = ./output
PLACEMAT = /usr/bin/placemat2
GINKGO = env GO111MODULE=on $(GOPATH)/bin/ginkgo --fail-fast -v
GINKGO = env GO111MODULE=on $(GOPATH)/bin/ginkgo --fail-fast -v --timeout=90m
SUITE = bootstrap
PLACEMAT_DATADIR = /var/scratch/placemat
VM_SHARED_DIR = /mnt/placemat
Expand Down
10 changes: 8 additions & 2 deletions pkg/neco/cmd/apply-firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"sort"
"sync"
"time"

"github.com/cybozu-go/log"
"github.com/cybozu-go/neco"
Expand All @@ -34,14 +35,15 @@ If some nodes are already powered off, this command does not do anything to thos

var applyFirmwareGetOpts sabakanMachinesGetOpts
var applyFirmwareRebootOption bool
var applyFirmwareTimeoutOption time.Duration

func applyFirmwareRun(cmd *cobra.Command, args []string) {
ctx := context.Background()

uploadAssetsAndRunCommandOnWorkers(ctx, &applyFirmwareGetOpts, args, []string{"docker", "exec", "setup-hw", "setup-apply-firmware"}, applyFirmwareRebootOption)
uploadAssetsAndRunCommandOnWorkers(ctx, &applyFirmwareGetOpts, args, []string{"docker", "exec", "setup-hw", "setup-apply-firmware"}, applyFirmwareTimeoutOption, applyFirmwareRebootOption)
}

func uploadAssetsAndRunCommandOnWorkers(ctx context.Context, getOpts *sabakanMachinesGetOpts, filenames []string, cmdline []string, needReboot bool) {
func uploadAssetsAndRunCommandOnWorkers(ctx context.Context, getOpts *sabakanMachinesGetOpts, filenames []string, cmdline []string, timeout time.Duration, needReboot bool) {
machines, err := sabakanMachinesGet(ctx, getOpts)
if err != nil {
log.ErrorExit(err)
Expand Down Expand Up @@ -94,6 +96,9 @@ func uploadAssetsAndRunCommandOnWorkers(ctx context.Context, getOpts *sabakanMac
cmdArgs := []string{"ssh", addr}
cmdArgs = append(cmdArgs, cmdline...)
cmdArgs = append(cmdArgs, assetUrls...)

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
output, err := well.CommandContext(ctx, neco.CKECLIBin, cmdArgs...).Output()

mtx.Lock()
Expand Down Expand Up @@ -159,4 +164,5 @@ func init() {
rootCmd.AddCommand(applyFirmwareCmd)
addSabakanMachinesGetOpts(applyFirmwareCmd, &applyFirmwareGetOpts)
applyFirmwareCmd.Flags().BoolVar(&applyFirmwareRebootOption, "reboot", false, "Schedule reboot")
applyFirmwareCmd.Flags().DurationVar(&applyFirmwareTimeoutOption, "timeout", 5*time.Minute, "timeout")
}
5 changes: 4 additions & 1 deletion pkg/neco/cmd/isoreboot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"time"

"github.com/spf13/cobra"
)
Expand All @@ -20,14 +21,16 @@ If some nodes are already powered off, this command does not do anything to thos
}

var isoRebootGetOpts sabakanMachinesGetOpts
var isoRebootTimeoutOption time.Duration

func isoRebootRun(cmd *cobra.Command, args []string) {
ctx := context.Background()

uploadAssetsAndRunCommandOnWorkers(ctx, &isoRebootGetOpts, args, []string{"docker", "exec", "setup-hw", "setup-isoreboot"}, true)
uploadAssetsAndRunCommandOnWorkers(ctx, &isoRebootGetOpts, args, []string{"docker", "exec", "setup-hw", "setup-isoreboot"}, isoRebootTimeoutOption, true)
}

func init() {
rootCmd.AddCommand(isoRebootCmd)
addSabakanMachinesGetOpts(isoRebootCmd, &isoRebootGetOpts)
isoRebootCmd.Flags().DurationVar(&isoRebootTimeoutOption, "timeout", 30*time.Second, "timeout")
}

0 comments on commit d479a89

Please sign in to comment.