Skip to content

Commit

Permalink
Support crun/calloc
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessOIer committed Feb 23, 2025
1 parent 309ed61 commit 50eb401
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/calloc/CmdArgParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ var (
FlagConfigFilePath string
FlagDebugLevel string

FlagReservation string

RootCmd = &cobra.Command{
Use: "calloc",
Short: "Allocate resource and create terminal",
Expand Down Expand Up @@ -87,4 +89,5 @@ func init() {
RootCmd.Flags().StringVarP(&FlagExcludes, "exclude", "x", "", "Exclude specific nodes from allocating (commas separated list)")
RootCmd.Flags().BoolVar(&FlagGetUserEnv, "get-user-env", false, "Load login environment variables of the user")
RootCmd.Flags().StringVar(&FlagExport, "export", "", "Propagate environment variables")
RootCmd.Flags().StringVarP(&FlagReservation, "reservation", "r", "", "Use reserved resources")
}
3 changes: 3 additions & 0 deletions internal/calloc/calloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ func MainCalloc(cmd *cobra.Command, args []string) util.CraneCmdError {
if FlagExport != "" {
task.Env["CRANE_EXPORT_ENV"] = FlagExport
}
if FlagReservation != "" {
task.Reservation = FlagReservation
}

// Set total limit of cpu cores
task.Resources.AllocatableRes.CpuCoreLimit = task.CpusPerTask * float64(task.NtasksPerNode)
Expand Down
2 changes: 1 addition & 1 deletion internal/cbatch/CmdArgParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ func init() {
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, ALL (default is NONE)")
RootCmd.Flags().StringVar(&FlagMailUser, "mail-user", "", "Mail address of the notification receiver")
RootCmd.Flags().BoolVar(&FlagJson, "json", false, "Output in JSON format")
RootCmd.Flags().StringVarP(&FlagReservation, "reservation", "r", "", "Allow to user reservation")
RootCmd.Flags().StringVarP(&FlagReservation, "reservation", "r", "", "Use reserved resources")
}
3 changes: 3 additions & 0 deletions internal/crun/CmdArgParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ var (

FlagConfigFilePath string
FlagDebugLevel string

FlagReservation string
)

func ParseCmdArgs() {
Expand Down Expand Up @@ -89,4 +91,5 @@ func init() {
RootCmd.Flags().StringVar(&FlagExport, "export", "", "Propagate environment variables")
RootCmd.Flags().BoolVar(&FlagPty, "pty", false, "Run with a pseudo-terminal")
RootCmd.Flags().BoolVar(&FlagX11, "x11", false, "Run with X11 forwarding (insecure)")
RootCmd.Flags().StringVarP(&FlagReservation, "reservation", "r", "", "Use reserved resources")
}
3 changes: 3 additions & 0 deletions internal/crun/crun.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,9 @@ func MainCrun(cmd *cobra.Command, args []string) util.CraneCmdError {
if FlagExport != "" {
task.Env["CRANE_EXPORT_ENV"] = FlagExport
}
if FlagReservation != "" {
task.Reservation = FlagReservation
}

// Set total limit of cpu cores
task.Resources.AllocatableRes.CpuCoreLimit = task.CpusPerTask * float64(task.NtasksPerNode)
Expand Down

0 comments on commit 50eb401

Please sign in to comment.