Skip to content

Commit 37ae0fd

Browse files
authored
feat: Add mail-type TIMELIMIT (#260)
1 parent 2c68f00 commit 37ae0fd

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

internal/calloc/CmdArgParser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func init() {
9393
RootCmd.Flags().BoolVar(&FlagGetUserEnv, "get-user-env", false, "Load login environment variables of the user")
9494
RootCmd.Flags().StringVar(&FlagExport, "export", "", "Propagate environment variables")
9595
RootCmd.Flags().StringVar(&FlagExtraAttr, "extra-attr", "", "Extra attributes of the job (in JSON format)")
96-
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, ALL (default is NONE)")
96+
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, TIMELIMIT, ALL (default is NONE)")
9797
RootCmd.Flags().StringVar(&FlagMailUser, "mail-user", "", "Mail address of the notification receiver")
9898
RootCmd.Flags().StringVar(&FlagComment, "comment", "", "Comment of the job")
9999
}

internal/cbatch/CmdArgParser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func init() {
155155
RootCmd.Flags().StringVarP(&FlagStderrPath, "error", "e", "", "Redirection path of standard error of the script")
156156
RootCmd.Flags().StringVar(&FlagWrappedScript, "wrap", "", "Wrap command string in a sh script and submit")
157157
RootCmd.Flags().StringVar(&FlagExtraAttr, "extra-attr", "", "Extra attributes of the job (in JSON format)")
158-
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, ALL (default is NONE)")
158+
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, TIMELIMIT, ALL (default is NONE)")
159159
RootCmd.Flags().StringVar(&FlagMailUser, "mail-user", "", "Mail address of the notification receiver")
160160
RootCmd.Flags().StringVar(&FlagComment, "comment", "", "Comment of the job")
161161
RootCmd.Flags().BoolVar(&FlagJson, "json", false, "Output in JSON format")

internal/crun/CmdArgParser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func init() {
104104
RootCmd.Flags().BoolVar(&FlagX11Fwd, "x11-forwarding", false, "Enable X11 forwarding by CraneSched (secure), default is false")
105105

106106
RootCmd.Flags().StringVar(&FlagExtraAttr, "extra-attr", "", "Extra attributes of the job (in JSON format)")
107-
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, ALL (default is NONE)")
107+
RootCmd.Flags().StringVar(&FlagMailType, "mail-type", "", "Notify user by mail when certain events occur, supported values: NONE, BEGIN, END, FAIL, TIMELIMIT, ALL (default is NONE)")
108108
RootCmd.Flags().StringVar(&FlagMailUser, "mail-user", "", "Mail address of the notification receiver")
109109
RootCmd.Flags().StringVar(&FlagComment, "comment", "", "Comment of the job")
110110
}

internal/util/string.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func CheckMailType(mailtype string) bool {
239239
mailtype == "BEGIN" ||
240240
mailtype == "END" ||
241241
mailtype == "FAIL" ||
242+
mailtype == "TIMELIMIT" ||
242243
mailtype == "ALL"
243244
}
244245

plugin/mail/mail.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ func (p *MailPlugin) EndHook(ctx *api.PluginContext) {
197197
}
198198

199199
if mailtype == "ALL" || mailtype == "END" ||
200-
(task.Status == protos.TaskStatus_Failed && mailtype == "FAIL") {
200+
(mailtype == "FAIL" && task.Status == protos.TaskStatus_Failed) ||
201+
(mailtype == "TIMELIMIT" && task.Status == protos.TaskStatus_ExceedTimeLimit) {
201202
subject = p.subject(task)
202203
if !p.SubjectOnly {
203204
body = p.body(task)

0 commit comments

Comments
 (0)