Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command vjobs, vqueues and unit tests. #666

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ command-lines:
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vcancel ./cmd/cli/vcancel
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vresume ./cmd/cli/vresume
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vsuspend ./cmd/cli/vsuspend
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vjobs ./cmd/cli/vjobs
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vqueues ./cmd/cli/vqueues
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need so many cli?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are simliar to Slurm cli like squeue, scancel, so that Slurm user would get used to our cli more easliy.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I donot think so. If you make each command a binary, it will definitely be inflated. And it will enforce users to install more tools and remember all.

2 changes: 1 addition & 1 deletion cmd/cli/util/util.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Volcano Authors.
Copyright 2019 The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions cmd/cli/vcancel/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Volcano Authors.
Copyright 2019 The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/klog"

"volcano.sh/volcano/cmd/cli/util"
"volcano.sh/volcano/pkg/cli/job"
"volcano.sh/volcano/pkg/cli/vcancel"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")
Expand All @@ -45,14 +45,14 @@ func main() {
Short: "cancel a job",
Long: `cancel a running, pending, or aborted job with specified name in default or specified namespace`,
Run: func(cmd *cobra.Command, args []string) {
util.CheckError(cmd, job.DeleteJob())
util.CheckError(cmd, vcancel.CancelJob())
},
}

jobCancelCmd := &rootCmd
job.InitDeleteFlags(jobCancelCmd)
vcancel.InitCancelFlags(jobCancelCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Printf("Failed to execute command: %v\n", err)
fmt.Printf("Failed to execute vcancel: %v\n", err)
os.Exit(-2)
}
}
58 changes: 58 additions & 0 deletions cmd/cli/vjobs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2019 The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

import (
"fmt"
"os"
"time"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog"

"volcano.sh/volcano/cmd/cli/util"
"volcano.sh/volcano/pkg/cli/vjobs"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")

func main() {
// flag.InitFlags()
klog.InitFlags(nil)

// The default klog flush interval is 30 seconds, which is frighteningly long.
go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop)
defer klog.Flush()

rootCmd := cobra.Command{
Use: "vjobs",
Short: "view job information",
Long: `view information of a job with specified name or jobs from the same namespace`,
Run: func(cmd *cobra.Command, args []string) {
util.CheckError(cmd, vjobs.ViewJob())
},
}

jobViewCmd := &rootCmd
vjobs.InitViewFlags(jobViewCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Printf("Failed to execute vjobs: %v\n", err)
os.Exit(-2)
}
}
58 changes: 58 additions & 0 deletions cmd/cli/vqueues/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2019 The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

import (
"fmt"
"os"
"time"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog"

"volcano.sh/volcano/cmd/cli/util"
"volcano.sh/volcano/pkg/cli/vqueues"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")

func main() {
// flag.InitFlags()
klog.InitFlags(nil)

// The default klog flush interval is 30 seconds, which is frighteningly long.
go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop)
defer klog.Flush()

rootCmd := cobra.Command{
Use: "vqueues",
Short: "view queue information",
Long: `view information of a queue with specified name or queues from the same namespace`,
Run: func(cmd *cobra.Command, args []string) {
util.CheckError(cmd, vqueues.GetQueue())
},
}

jobGetCmd := &rootCmd
vqueues.InitGetFlags(jobGetCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Printf("Failed to execute vqueues: %v\n", err)
os.Exit(-2)
}
}
10 changes: 5 additions & 5 deletions cmd/cli/vresume/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Volcano Authors.
Copyright 2019 The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/klog"

"volcano.sh/volcano/cmd/cli/util"
"volcano.sh/volcano/pkg/cli/job"
"volcano.sh/volcano/pkg/cli/vresume"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")
Expand All @@ -45,14 +45,14 @@ func main() {
Short: "resume a job",
Long: `resume an aborted job with specified name in default or specified namespace`,
Run: func(cmd *cobra.Command, args []string) {
util.CheckError(cmd, job.ResumeJob())
util.CheckError(cmd, vresume.ResumeJob())
},
}

jobResumeCmd := &rootCmd
job.InitResumeFlags(jobResumeCmd)
vresume.InitResumeFlags(jobResumeCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Printf("Failed to execute command: %v\n", err)
fmt.Printf("Failed to execute vresume: %v\n", err)
os.Exit(-2)
}
}
10 changes: 5 additions & 5 deletions cmd/cli/vsuspend/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Volcano Authors.
Copyright 2019 The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/klog"

"volcano.sh/volcano/cmd/cli/util"
"volcano.sh/volcano/pkg/cli/job"
"volcano.sh/volcano/pkg/cli/vsuspend"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")
Expand All @@ -45,14 +45,14 @@ func main() {
Short: "suspend a job",
Long: `suspend a running or pending job with specified name in default or specified namespace`,
Run: func(cmd *cobra.Command, args []string) {
util.CheckError(cmd, job.SuspendJob())
util.CheckError(cmd, vsuspend.SuspendJob())
},
}

jobSuspendCmd := &rootCmd
job.InitSuspendFlags(jobSuspendCmd)
vsuspend.InitSuspendFlags(jobSuspendCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Printf("Failed to execute command: %v\n", err)
fmt.Printf("Failed to execute vsuspend: %v\n", err)
os.Exit(-2)
}
}
Loading