Skip to content
Open
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: 1 addition & 1 deletion internal/cacct/cacct.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
)

// QueryJob will query all pending, running and completed tasks
func QueryJob() util.CraneCmdError {
func QueryJob() util.CraneErrorType {
request := protos.QueryTasksInfoRequest{OptionIncludeCompletedTasks: true}

if FlagFilterStartTime != "" {
Expand Down
35 changes: 18 additions & 17 deletions internal/cacctmgr/CmdArgParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ var (
},
}

/* --------------------------------------------------- remove --------------------------------------------------- */
removeCmd = &cobra.Command{
/* --------------------------------------------------- delete --------------------------------------------------- */
deleteCmd = &cobra.Command{
Use: "delete",
Aliases: []string{"remove"},
SilenceErrors: true,
Short: "Delete entity",
Long: "",
}
removeAccountCmd = &cobra.Command{
deleteAccountCmd = &cobra.Command{
Use: "account",
Short: "Delete an existing account",
Long: "",
Expand All @@ -133,7 +133,7 @@ var (
}
},
}
removeUserCmd = &cobra.Command{
deleteUserCmd = &cobra.Command{
Use: "user",
Short: "Delete an existing user",
Long: "",
Expand All @@ -144,7 +144,7 @@ var (
}
},
}
removeQosCmd = &cobra.Command{
deleteQosCmd = &cobra.Command{
Use: "qos",
Short: "Delete an existing QoS",
Long: "",
Expand All @@ -159,6 +159,7 @@ var (
/* --------------------------------------------------- modify -------------------------------------------------- */
modifyCmd = &cobra.Command{
Use: "modify",
Aliases: []string{"update"},
SilenceErrors: true,
Short: "Modify entity",
Long: "",
Expand Down Expand Up @@ -476,7 +477,7 @@ func init() {
{
addQosCmd.Flags().StringVarP(&FlagQos.Name, "name", "N", "", "Set the name of the QoS")
addQosCmd.Flags().StringVarP(&FlagQos.Description, "description", "D", "", "Set the description of the QoS")
addQosCmd.Flags().Uint32VarP(&FlagQos.Priority, "priority", "P", 0, "Set job priority of the QoS")
addQosCmd.Flags().Uint32VarP(&FlagQos.Priority, "priority", "P", 1000, "Set job priority of the QoS")
addQosCmd.Flags().Uint32VarP(&FlagQos.MaxJobsPerUser, "max_jobs_per_user", "J", math.MaxUint32, "Set the maximum number of jobs per user")
addQosCmd.Flags().Uint32VarP(&FlagQos.MaxCpusPerUser, "max_cpus_per_user", "c", math.MaxUint32, "Set the maximum number of CPUs per user")
addQosCmd.Flags().Uint64VarP(&FlagQos.MaxTimeLimitPerTask, "max_time_limit_per_task", "T", uint64(util.InvalidDuration().Seconds), "Set the maximum time limit per job (in seconds)")
Expand All @@ -487,29 +488,29 @@ func init() {
}

/* --------------------------------------------------- remove --------------------------------------------------- */
RootCmd.AddCommand(removeCmd)
RootCmd.AddCommand(deleteCmd)
{
removeCmd.AddCommand(removeAccountCmd)
deleteCmd.AddCommand(deleteAccountCmd)
{
removeAccountCmd.Flags().StringVarP(&FlagAccount.Name, "name", "N", "", "Remove account with this name")
if err := removeAccountCmd.MarkFlagRequired("name"); err != nil {
deleteAccountCmd.Flags().StringVarP(&FlagAccount.Name, "name", "N", "", "Remove account with this name")
if err := deleteAccountCmd.MarkFlagRequired("name"); err != nil {
log.Fatalln("Can't mark 'name' flag required")
}
}

removeCmd.AddCommand(removeQosCmd)
deleteCmd.AddCommand(deleteQosCmd)
{
removeQosCmd.Flags().StringVarP(&FlagQos.Name, "name", "N", "", "Remove QoS with this name")
if err := removeQosCmd.MarkFlagRequired("name"); err != nil {
deleteQosCmd.Flags().StringVarP(&FlagQos.Name, "name", "N", "", "Remove QoS with this name")
if err := deleteQosCmd.MarkFlagRequired("name"); err != nil {
log.Fatalln("Can't mark 'name' flag required")
}
}

removeCmd.AddCommand(removeUserCmd)
deleteCmd.AddCommand(deleteUserCmd)
{
removeUserCmd.Flags().StringVarP(&FlagUser.Name, "name", "N", "", "Remove user with this name")
removeUserCmd.Flags().StringVarP(&FlagUser.Account, "account", "A", "", "Remove user from this account")
if err := removeUserCmd.MarkFlagRequired("name"); err != nil {
deleteUserCmd.Flags().StringVarP(&FlagUser.Name, "name", "N", "", "Remove user with this name")
deleteUserCmd.Flags().StringVarP(&FlagUser.Account, "account", "A", "", "Remove user from this account")
if err := deleteUserCmd.MarkFlagRequired("name"); err != nil {
log.Fatalln("Can't mark 'name' flag required")
}
}
Expand Down
30 changes: 15 additions & 15 deletions internal/cacctmgr/cacctmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func PrintAccountTree(parentTreeRoot treeprint.Tree, account string, accountMap
}
}

func AddAccount(account *protos.AccountInfo) util.CraneCmdError {
func AddAccount(account *protos.AccountInfo) util.CraneErrorType {
// FIXME: Move name validation to the backend?
// FIXME: Seperate this to Args of cobra package?
if account.Name == "=" {
Expand Down Expand Up @@ -348,7 +348,7 @@ func AddAccount(account *protos.AccountInfo) util.CraneCmdError {
}
}

func AddUser(user *protos.UserInfo, partition []string, level string, coordinator bool) util.CraneCmdError {
func AddUser(user *protos.UserInfo, partition []string, level string, coordinator bool) util.CraneErrorType {
if user.Name == "=" {
log.Errorf("User name empty")
return util.ErrorCmdArg
Expand Down Expand Up @@ -405,7 +405,7 @@ func AddUser(user *protos.UserInfo, partition []string, level string, coordinato
}
}

func AddQos(qos *protos.QosInfo) util.CraneCmdError {
func AddQos(qos *protos.QosInfo) util.CraneErrorType {
if qos.Name == "=" {
log.Errorln("QoS name empty.")
return util.ErrorCmdArg
Expand Down Expand Up @@ -433,7 +433,7 @@ func AddQos(qos *protos.QosInfo) util.CraneCmdError {
}
}

func DeleteAccount(name string) util.CraneCmdError {
func DeleteAccount(name string) util.CraneErrorType {
req := protos.DeleteEntityRequest{Uid: userUid, EntityType: protos.EntityType_Account, Name: name}

reply, err := stub.DeleteEntity(context.Background(), &req)
Expand All @@ -450,7 +450,7 @@ func DeleteAccount(name string) util.CraneCmdError {
}
}

func DeleteUser(name string, account string) util.CraneCmdError {
func DeleteUser(name string, account string) util.CraneErrorType {
req := protos.DeleteEntityRequest{Uid: userUid, EntityType: protos.EntityType_User, Name: name, Account: account}

reply, err := stub.DeleteEntity(context.Background(), &req)
Expand All @@ -467,7 +467,7 @@ func DeleteUser(name string, account string) util.CraneCmdError {
}
}

func DeleteQos(name string) util.CraneCmdError {
func DeleteQos(name string) util.CraneErrorType {
req := protos.DeleteEntityRequest{Uid: userUid, EntityType: protos.EntityType_Qos, Name: name}

reply, err := stub.DeleteEntity(context.Background(), &req)
Expand All @@ -484,7 +484,7 @@ func DeleteQos(name string) util.CraneCmdError {
}
}

func ModifyAccount(itemLeft string, itemRight string, name string, requestType protos.ModifyEntityRequest_OperatorType) util.CraneCmdError {
func ModifyAccount(itemLeft string, itemRight string, name string, requestType protos.ModifyEntityRequest_OperatorType) util.CraneErrorType {
req := protos.ModifyEntityRequest{
Uid: userUid,
Item: itemLeft,
Expand All @@ -509,7 +509,7 @@ func ModifyAccount(itemLeft string, itemRight string, name string, requestType p
}
}

func ModifyUser(itemLeft string, itemRight string, name string, account string, partition string, requestType protos.ModifyEntityRequest_OperatorType) util.CraneCmdError {
func ModifyUser(itemLeft string, itemRight string, name string, account string, partition string, requestType protos.ModifyEntityRequest_OperatorType) util.CraneErrorType {
if itemLeft == "admin_level" {
if itemRight != "none" && itemRight != "operator" && itemRight != "admin" {
log.Errorf("Unknown admin_level, valid values: none, operator, admin.")
Expand Down Expand Up @@ -543,7 +543,7 @@ func ModifyUser(itemLeft string, itemRight string, name string, account string,
}
}

func ModifyQos(itemLeft string, itemRight string, name string) util.CraneCmdError {
func ModifyQos(itemLeft string, itemRight string, name string) util.CraneErrorType {
req := protos.ModifyEntityRequest{
Uid: userUid,
Item: itemLeft,
Expand All @@ -567,7 +567,7 @@ func ModifyQos(itemLeft string, itemRight string, name string) util.CraneCmdErro
}
}

func ShowAccounts() util.CraneCmdError {
func ShowAccounts() util.CraneErrorType {
req := protos.QueryEntityInfoRequest{Uid: userUid, EntityType: protos.EntityType_Account}
reply, err := stub.QueryEntityInfo(context.Background(), &req)
if err != nil {
Expand All @@ -584,7 +584,7 @@ func ShowAccounts() util.CraneCmdError {
}
}

func ShowUser(name string, account string) util.CraneCmdError {
func ShowUser(name string, account string) util.CraneErrorType {
req := protos.QueryEntityInfoRequest{Uid: userUid, EntityType: protos.EntityType_User, Name: name, Account: account}
reply, err := stub.QueryEntityInfo(context.Background(), &req)
if err != nil {
Expand All @@ -601,7 +601,7 @@ func ShowUser(name string, account string) util.CraneCmdError {
}
}

func ShowQos(name string) util.CraneCmdError {
func ShowQos(name string) util.CraneErrorType {
req := protos.QueryEntityInfoRequest{Uid: userUid, EntityType: protos.EntityType_Qos, Name: name}
reply, err := stub.QueryEntityInfo(context.Background(), &req)
if err != nil {
Expand All @@ -622,7 +622,7 @@ func ShowQos(name string) util.CraneCmdError {
}
}

func FindAccount(name string) util.CraneCmdError {
func FindAccount(name string) util.CraneErrorType {
req := protos.QueryEntityInfoRequest{Uid: userUid, EntityType: protos.EntityType_Account, Name: name}
reply, err := stub.QueryEntityInfo(context.Background(), &req)
if err != nil {
Expand All @@ -639,7 +639,7 @@ func FindAccount(name string) util.CraneCmdError {
}
}

func BlockAccountOrUser(name string, entityType protos.EntityType, account string) util.CraneCmdError {
func BlockAccountOrUser(name string, entityType protos.EntityType, account string) util.CraneErrorType {
req := protos.BlockAccountOrUserRequest{Uid: userUid, Block: true, EntityType: entityType, Name: name, Account: account}
reply, err := stub.BlockAccountOrUser(context.Background(), &req)
if err != nil {
Expand All @@ -656,7 +656,7 @@ func BlockAccountOrUser(name string, entityType protos.EntityType, account strin
}
}

func UnblockAccountOrUser(name string, entityType protos.EntityType, account string) util.CraneCmdError {
func UnblockAccountOrUser(name string, entityType protos.EntityType, account string) util.CraneErrorType {
req := protos.BlockAccountOrUserRequest{Uid: userUid, Block: false, EntityType: entityType, Name: name, Account: account}
reply, err := stub.BlockAccountOrUser(context.Background(), &req)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/cbatch/cbatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func ProcessCbatchArg(args []CbatchArg) (bool, *protos.TaskToCtld) {
return true, task
}

func SendRequest(task *protos.TaskToCtld) util.CraneCmdError {
func SendRequest(task *protos.TaskToCtld) util.CraneErrorType {
config := util.ParseConfig(FlagConfigFilePath)
stub := util.GetStubToCtldByConfig(config)
req := &protos.SubmitBatchTaskRequest{Task: task}
Expand All @@ -268,7 +268,7 @@ func SendRequest(task *protos.TaskToCtld) util.CraneCmdError {
}
}

func SendMultipleRequests(task *protos.TaskToCtld, count uint32) util.CraneCmdError {
func SendMultipleRequests(task *protos.TaskToCtld, count uint32) util.CraneErrorType {
config := util.ParseConfig(FlagConfigFilePath)
stub := util.GetStubToCtldByConfig(config)
req := &protos.SubmitBatchTasksRequest{Task: task, Count: count}
Expand Down Expand Up @@ -357,7 +357,7 @@ func SetPropagatedEnviron(task *protos.TaskToCtld) {
}
}

func Cbatch(jobFilePath string) util.CraneCmdError {
func Cbatch(jobFilePath string) util.CraneErrorType {
if FlagRepeat == 0 {
log.Error("--repeat must >0")
return util.ErrorCmdArg
Expand Down
2 changes: 1 addition & 1 deletion internal/ccancel/ccancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
stub protos.CraneCtldClient
)

func CancelTask(args []string) util.CraneCmdError {
func CancelTask(args []string) util.CraneErrorType {
req := &protos.CancelTaskRequest{
OperatorUid: uint32(os.Getuid()),

Expand Down
Loading