forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Assume controller is in UTC when calculating NextScheduledRuntime (
argoproj#4417) Signed-off-by: Simon Behar <[email protected]>
- Loading branch information
Showing
8 changed files
with
63 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cron | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/robfig/cron/v3" | ||
|
||
"github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" | ||
) | ||
|
||
// GetNextRuntime returns the next time the workflow should run in local time. It assumes the workflow-controller is in | ||
// UTC, but nevertheless returns the time in the local timezone. | ||
func GetNextRuntime(cwf *v1alpha1.CronWorkflow) (time.Time, error) { | ||
cronScheduleString := cwf.Spec.Schedule | ||
if cwf.Spec.Timezone != "" { | ||
cronScheduleString = "CRON_TZ=" + cwf.Spec.Timezone + " " + cronScheduleString | ||
} | ||
cronSchedule, err := cron.ParseStandard(cronScheduleString) | ||
if err != nil { | ||
return time.Time{}, err | ||
} | ||
return cronSchedule.Next(time.Now().UTC()).Local(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters