fix: continue including maintenance mode cron tasks in the cron:list subcommand

This commit is contained in:
Jose Diaz-Gonzalez committed 2025-06-08 22:34:47 -04:00
1 parent c0eb12f572
commit 0f4b5d4305
4 files changed
+24 -14

No files matched your search

+9 -7
View File
@@ -44,6 +44,9 @@ type TemplateCommand struct {
// LogFile is the log file to write to // LogFile is the log file to write to
LogFile string `json:"-"` LogFile string `json:"-"`
// Maintenance is whether the cron command is in maintenance mode
Maintenance bool `json:"maintenance"`
} }
// CronCommand returns the command to run for a given cron command // CronCommand returns the command to run for a given cron command
@@ -61,9 +64,7 @@ func (t TemplateCommand) CronCommand() string {
// FetchCronEntries returns a list of cron commands for a given app // FetchCronEntries returns a list of cron commands for a given app
func FetchCronEntries(appName string) ([]TemplateCommand, error) { func FetchCronEntries(appName string) ([]TemplateCommand, error) {
commands := []TemplateCommand{} commands := []TemplateCommand{}
if reportComputedMaintenance(appName) == "true" { isMaintenance := reportComputedMaintenance(appName) == "true"
return commands, nil
}
appJSON, err := appjson.GetAppJSON(appName) appJSON, err := appjson.GetAppJSON(appName)
if err != nil { if err != nil {
@@ -82,10 +83,11 @@ func FetchCronEntries(appName string) ([]TemplateCommand, error) {
} }
commands = append(commands, TemplateCommand{ commands = append(commands, TemplateCommand{
App: appName, App: appName,
Command: c.Command, Command: c.Command,
Schedule: c.Schedule, Schedule: c.Schedule,
ID: GenerateCommandID(appName, c), ID: GenerateCommandID(appName, c),
Maintenance: isMaintenance,
}) })
} }
+2 -2
View File
@@ -32,9 +32,9 @@ func CommandList(appName string, format string) error {
} }
if format == "stdout" { if format == "stdout" {
output := []string{"ID | Schedule | Command"} output := []string{"ID | Schedule | Maintenance | Command"}
for _, entry := range entries { for _, entry := range entries {
output = append(output, fmt.Sprintf("%s | %s | %s", entry.ID, entry.Schedule, entry.Command)) output = append(output, fmt.Sprintf("%s | %s | %t | %s", entry.ID, entry.Schedule, entry.Maintenance, entry.Command))
} }
result := columnize.SimpleFormat(output) result := columnize.SimpleFormat(output)
+5 -4
View File
@@ -83,9 +83,10 @@ func generateCronEntries() ([]cron.TemplateCommand, error) {
id := base36.EncodeToStringLc([]byte(strings.Join(parts, ";;;"))) id := base36.EncodeToStringLc([]byte(strings.Join(parts, ";;;")))
command := cron.TemplateCommand{ command := cron.TemplateCommand{
ID: id, ID: id,
Schedule: parts[0], Schedule: parts[0],
AltCommand: parts[1], AltCommand: parts[1],
Maintenance: false,
} }
if len(parts) == 3 { if len(parts) == 3 {
command.LogFile = parts[2] command.LogFile = parts[2]
@@ -106,7 +107,7 @@ func generateCronEntries() ([]cron.TemplateCommand, error) {
for result := range results { for result := range results {
c := result c := result
if len(c) > 0 { if len(c) > 0 && !c[0].Maintenance {
commands = append(commands, c...) commands = append(commands, c...)
} }
} }
+8 -1
View File
@@ -266,10 +266,17 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
workingDir := common.GetWorkingDir(appName, image) workingDir := common.GetWorkingDir(appName, image)
cronEntries, err := cron.FetchCronEntries(appName) allCronEntries, err := cron.FetchCronEntries(appName)
if err != nil { if err != nil {
return fmt.Errorf("Error fetching cron entries: %w", err) return fmt.Errorf("Error fetching cron entries: %w", err)
} }
// remove maintenance cron entries
cronEntries := []cron.TemplateCommand{}
for _, cronEntry := range allCronEntries {
if !cronEntry.Maintenance {
cronEntries = append(cronEntries, cronEntry)
}
}
domains := []string{} domains := []string{}
if _, ok := processes["web"]; ok { if _, ok := processes["web"]; ok {