sensu / web

Open-source Web UI for Sensu Go clusters
MIT License
30 stars 22 forks source link

Check UI does not handle cron schedules with Timezones #387

Closed mrweir closed 2 years ago

mrweir commented 2 years ago

When you specify a timezone for your cron check as specified in the docs, the UI does not correctly display the schedule.

Expected Behavior

The check page should correctly display the cron schedule, with timezone information.

Current Behavior

For a check with the cron schedule CRON_TZ=America/Edmonton 0 10,22 * * *, the UI shows this: Screen Shot 2021-10-25 at 10 09 43 AM

Note that this problem happens with both CRON_TZ and TZ.

It looks like it's treating the / in the time zone as a cron step value.

For comparison purposes, here's what the check looks like when the schedule is 0 10,22 * * *, without the timezone: Screen Shot 2021-10-25 at 10 11 21 AM

Possible Solution

You could split the string on space characters, check if the first chunk contains TZ=, and if perform the current processing with the remaining chunks, and then split the first chunk on = and add something like in the timezone America/Edmonton to the tail end of the schedule text.

Steps to Reproduce

  1. Define a check with a cron: schedule, including a time zone as instructed in the documentation linked above
  2. Observe the Schedule in the dashboard for that check.