Skip to content

Commit 3c04512

Browse files
authored
Fix --queues_avoid default not applying (#499)
1 parent f7e1df2 commit 3c04512

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test-k8s-unit: compile_k8s_tmp ## Run the unit and integration tests for the kub
3737
race: export CGO_ENABLED = 1
3838
race:
3939
go test -p 1 -tags netgo -race --count 1 -failfast ./
40+
go test -p 1 -tags netgo -race --count 1 -failfast ./cmd
4041
go test -p 1 -tags netgo -race --count 1 -failfast ./queue
4142
go test -p 1 -tags netgo -race --count 1 -failfast -timeout 30m ./jobqueue
4243
go test -p 1 -tags netgo -race --count 1 -failfast -timeout 40m ./jobqueue/scheduler

cmd/add.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var (
8585
cmdCloudSharedDisk bool
8686
cmdFlavor string
8787
cmdQueue string
88-
cmdQueuesAvoid string
88+
cmdQueuesAvoidAdd string
8989
cmdMisc string
9090
cmdMonitorDocker string
9191
cmdWithDocker string
@@ -560,7 +560,7 @@ func init() {
560560
addCmd.Flags().StringVar(&cmdCloudConfigs, "cloud_config_files", "", "in the cloud, comma separated paths of config files to copy to servers created to run these commands")
561561
addCmd.Flags().BoolVar(&cmdCloudSharedDisk, "cloud_shared", false, "mount /shared")
562562
addCmd.Flags().StringVar(&cmdQueue, "queue", "", "name of queue to submit to, for schedulers with queues")
563-
addCmd.Flags().StringVar(&cmdQueuesAvoid, "queues_avoid", "interactive",
563+
addCmd.Flags().StringVar(&cmdQueuesAvoidAdd, "queues_avoid", "interactive",
564564
"comma-separated list of substrings found in queues that should not be submitted to, for schedulers with queues")
565565
addCmd.Flags().StringVar(&cmdMisc, "misc", "", "miscellaneous options to pass through to scheduler when submitting")
566566
addCmd.Flags().StringVar(&cmdEnv, "env", "", "comma-separated list of key=value environment variables to set before running the commands")
@@ -651,7 +651,7 @@ func parseCmdFile(jq *jobqueue.Client, diskSet bool) ([]*jobqueue.Job, bool, boo
651651
CloudFlavor: cmdFlavor,
652652
CloudShared: cmdCloudSharedDisk,
653653
SchedulerQueue: cmdQueue,
654-
SchedulerQueuesAvoid: cmdQueuesAvoid,
654+
SchedulerQueuesAvoid: cmdQueuesAvoidAdd,
655655
SchedulerMisc: cmdMisc,
656656
BsubMode: bsubMode,
657657
RTimeout: rtimeoutint,

cmd/add_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright © 2016-2021,2024,2025 Genome Research Limited
2+
// Author: Sendu Bala <sb10@sanger.ac.uk>.
3+
//
4+
// This file is part of wr.
5+
//
6+
// wr is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU Lesser General Public License as published by
8+
// the Free Software Foundation, either version 3 of the License, or
9+
// (at your option) any later version.
10+
//
11+
// wr is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU Lesser General Public License for more details.
15+
//
16+
// You should have received a copy of the GNU Lesser General Public License
17+
// along with wr. If not, see <http://www.gnu.org/licenses/>.
18+
19+
package cmd
20+
21+
import (
22+
"testing"
23+
24+
. "github.com/smartystreets/goconvey/convey"
25+
)
26+
27+
func TestAddQueuesAvoidDefault(t *testing.T) {
28+
Convey("add queues_avoid default is applied when unset", t, func() {
29+
flag := addCmd.Flags().Lookup("queues_avoid")
30+
So(flag, ShouldNotBeNil)
31+
So(flag.Value.String(), ShouldEqual, "interactive")
32+
So(cmdQueuesAvoidAdd, ShouldEqual, "interactive")
33+
})
34+
}

cmd/mod.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var (
3737
cmdCwdMattersUnset bool
3838
cmdChangeHomeUnset bool
3939
cmdCloudSharedDiskUnset bool
40+
cmdQueuesAvoidMod string
4041
)
4142

4243
const nothingBehaviour = `[{"Nothing":true}]`
@@ -245,8 +246,8 @@ new internal ids is printed.`,
245246
if cmdQueue != "" {
246247
other["scheduler_queue"] = cmdQueue
247248
}
248-
if cmdQueuesAvoid != "" {
249-
other["scheduler_queues_avoid"] = cmdQueuesAvoid
249+
if cmdQueuesAvoidMod != "" {
250+
other["scheduler_queues_avoid"] = cmdQueuesAvoidMod
250251
}
251252
if len(other) > 0 || otherSet {
252253
req.Other = other
@@ -423,7 +424,7 @@ func init() {
423424
modCmd.Flags().BoolVar(&cmdCloudSharedDiskUnset, "unset_cloud_shared", false, "unset --cloud_shared")
424425
modCmd.Flags().StringVar(&cmdEnv, "env", "", "comma-separated list of key=value environment variables to set before running the commands")
425426
modCmd.Flags().StringVar(&cmdQueue, "queue", "", "name of queue to submit to, for schedulers with queues")
426-
modCmd.Flags().StringVar(&cmdQueuesAvoid, "queues_avoid", "",
427+
modCmd.Flags().StringVar(&cmdQueuesAvoidMod, "queues_avoid", "",
427428
"comma-separated list of substrings found in queues that should not be submitted to, for schedulers with queues")
428429
// modCmd.Flags().BoolVar(&cmdBsubMode, "bsub", false, "enable bsub emulation mode")
429430

0 commit comments

Comments
 (0)