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
9 changes: 5 additions & 4 deletions internal/cacctmgr/cacctmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,15 @@ func DeleteLicenseResource(name string, server string, clusters string) error {
}
}

func ModifyAccount(params []ModifyParam, name string) error {
func ModifyAccount(params []ModifyParam, partition string, name string) error {
var valueList []string
var err error

req := protos.ModifyAccountRequest{
Uid: userUid,
Name: name,
Force: FlagForce,
Uid: userUid,
Name: name,
Force: FlagForce,
Partition: partition,
}

for _, param := range params {
Expand Down
151 changes: 150 additions & 1 deletion internal/cacctmgr/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ var (
FlagNodeList string
FlagNumLimit uint32

FlagShowPartitionLimit bool

FlagEntityName string
FlagEntityAccount string
FlagEntityPartitions string
Expand Down Expand Up @@ -751,6 +753,7 @@ func executeModifyAccountCommand(command *CAcctMgrCommand) error {
FlagAllowedQosList = ""
FlagDeletePartitionList = ""
FlagDeleteQosList = ""
FlagPartition = ""

WhereParams := command.GetWhereParams()
SetParams, AddParams, DeleteParams := command.GetSetParams()
Expand All @@ -768,6 +771,8 @@ func executeModifyAccountCommand(command *CAcctMgrCommand) error {
switch strings.ToLower(key) {
case "name":
FlagEntityName = value
case "partition":
FlagPartition = value
default:
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("Error: unknown where parameter '%s' for account modification\n", key))
}
Expand Down Expand Up @@ -816,6 +821,78 @@ func executeModifyAccountCommand(command *CAcctMgrCommand) error {
NewValue: FlagSetDefaultAccount,
RequestType: protos.OperationType_Overwrite,
})
case "maxsubmitjobs":
if FlagPartition == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxSubmitJobs' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxSubmitJobs", 32); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxSubmitJobs,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxjobs":
if FlagPartition == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxJobs' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxJobs", 32); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxJobs,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxtres":
if FlagPartition == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxTres' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if _, err := util.ParseTres(value); err != nil {
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("invalid argument %s for maxTres flag: %v\n", value, err))
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxTres,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxtresperjob":
if FlagPartition == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxTresPerJob' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if _, err := util.ParseTres(value); err != nil {
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("invalid argument %s for maxTresPerJob flag: %v\n", value, err))
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxTresPerJob,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxwall":
if FlagPartition == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxWall' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxWall", 64); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxWall,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxwallperjob":
if FlagPartition == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxWallPerJob' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxWallPerJob", 64); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxWallDurationPerJob,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
default:
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("Error: unknown set parameter '%s' for account modification\n", key))
}
Expand Down Expand Up @@ -863,7 +940,7 @@ func executeModifyAccountCommand(command *CAcctMgrCommand) error {
}
}

return ModifyAccount(params, FlagEntityName)
return ModifyAccount(params, FlagPartition, FlagEntityName)
}

func executeModifyUserCommand(command *CAcctMgrCommand) error {
Expand Down Expand Up @@ -946,6 +1023,78 @@ func executeModifyUserCommand(command *CAcctMgrCommand) error {
NewValue: FlagAdminLevel,
RequestType: protos.OperationType_Overwrite,
})
case "maxsubmitjobs":
if FlagEntityPartitions == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxSubmitJobs' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxSubmitJobs", 32); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxSubmitJobs,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxjobs":
if FlagEntityPartitions == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxJobs' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxJobs", 32); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxJobs,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxtres":
if FlagEntityPartitions == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxTres' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if _, err := util.ParseTres(value); err != nil {
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("invalid argument %s for maxTres flag: %v\n", value, err))
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxTres,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxtresperjob":
if FlagEntityPartitions == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxTresPerJob' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if _, err := util.ParseTres(value); err != nil {
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("invalid argument %s for maxTresPerJob flag: %v\n", value, err))
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxTresPerJob,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxwall":
if FlagEntityPartitions == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxWall' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxWall", 64); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxWall,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
case "maxwallperjob":
if FlagEntityPartitions == "" {
return util.NewCraneErr(util.ErrorCmdArg, "Error: 'maxWallPerJob' can only be set for a specific partition. Please specify the partition in the where clause.\n")
}
if err := validateUintValue(value, "maxWallPerJob", 64); err != nil {
return util.WrapCraneErr(util.ErrorCmdArg, "%s\n", err)
}
params = append(params, ModifyParam{
ModifyField: protos.ModifyField_MaxWallDurationPerJob,
NewValue: value,
RequestType: protos.OperationType_Overwrite,
})
default:
return util.NewCraneErr(util.ErrorCmdArg, fmt.Sprintf("Error: unknown set parameter '%s' for user modification\n", key))
}
Expand Down
29 changes: 24 additions & 5 deletions internal/cacctmgr/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func showHelp() {
format=<Name,Description,AllowedPartition,Users,DefaultQos,AllowedQosList,
Coordinators,Blocked> (Spelling must be correct, case is not important)
For Example: cacctmgr show account format=name,users,coordinators
--partition-limit, -P Also display partition resource limits for each account

add user <name> Account=<account> [Coordinator=true|false] [Level=<level>]
[Partition=<part1,part2,...>] [Name=<name1,name2,...>]
Expand Down Expand Up @@ -98,6 +99,7 @@ func showHelp() {
format=<Account,UserName,Uid,AllowedPartition,AllowedQosList,DefaultQos,Coordinated,
AdminLevel,Blocked> (Spelling must be correct, case is not important)
For Example: cacctmgr show user format=account,defaultqos,adminlevel
--partition-limit, -P Also display partition resource limits for each user

add wckey <name> user=<user>
Create a new wckey and bind it to the user
Expand Down Expand Up @@ -234,6 +236,14 @@ func showHelp() {
set AllowedQos-=<qos1,qos2,...> Delete allowed QoS
set AllowedPartition=<part1,part2,...> Set allowed partitions directly
set AllowedQos=<qos1,qos2,...> Set allowed QoS directly
Account partition resource limit options (partition must be specified in where clause):
where Name=<account> Partition=<partition>
set MaxJobs=<num> Set max running jobs for the account in the partition
set MaxSubmitJobs=<num> Set max submit jobs for the account in the partition
set MaxTres=<tres> Set max Tres for the account in the partition (format: cpu:<num>,mem:<num>)
set MaxTresPerJob=<tres> Set max Tres per job for the account in the partition
set MaxWall=<sec> Set max wall time for the account in the partition (seconds)
set MaxWallPerJob=<sec> Set max wall time per job for the account in the partition (seconds)
User options:
where Name=<user> [Account=<account>] [Partition=<part1,part2,...>]
set AdminLevel=<level> Set user admin level
Expand All @@ -245,6 +255,14 @@ func showHelp() {
set AllowedQos-=... Delete allowed QoS
set AllowedPartition=... Set allowed partitions directly
set AllowedQos=... Set allowed QoS directly
User partition resource limit options (partition must be specified in where clause):
where Name=<user> [Account=<account>] Partition=<partition>
set MaxJobs=<num> Set max running jobs for the user in the partition
set MaxSubmitJobs=<num> Set max submit jobs for the user in the partition
set MaxTres=<tres> Set max Tres for the user in the partition (format: cpu:<num>,mem:<num>)
set MaxTresPerJob=<tres> Set max Tres per job for the user in the partition
set MaxWall=<sec> Set max wall time for the user in the partition (seconds)
set MaxWallPerJob=<sec> Set max wall time per job for the user in the partition (seconds)
QoS options:
where Name=<qos>
set Description=<desc> Set description
Expand Down Expand Up @@ -276,11 +294,12 @@ func showHelp() {
set Allowed=<num> Set amount allowed for the cluster (cluster must be specified)

GLOBAL OPTIONS:
--help, -h Display this help message
--config, -C Specify config file path (default: /etc/crane/config.yaml)
--json, -J Format output as JSON
--version, -v Display program version
--force, -f Force operation without confirmation
--help, -h Display this help message
--config, -C Specify config file path (default: /etc/crane/config.yaml)
--json, -J Format output as JSON
--version, -v Display program version
--force, -f Force operation without confirmation
--partition-limit, -P Display partition resource limits (for show account/user)

NOTE: Parameters in [] are optional. Parameters in <> should be replaced with actual values.
`
Expand Down
Loading
Loading