Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RAM] Fix snooze scheduler timezone handling #157338

Merged
merged 1 commit into from
May 17, 2023

Conversation

Zacqary
Copy link
Contributor

@Zacqary Zacqary commented May 10, 2023

Summary

Closes #156535

The Snooze Scheduler was failing to properly save and load snoozes if the user selected a timezone other than the Kibana default. This is because the datepicker only converts timestamp values between UTC and the default Kibana timezone.

This PR fixes the issue by offsetting all dates that come in and out of the scheduler UI relative to local time.

To test, create a snooze like this on main and make sure you select timezone America/Los_Angeles. (If your local timezone is equivalent to America/Los_Angeles, select a different timezone)

Screenshot 2023-05-10 at 3 58 57 PM

On main, editing the snooze will (erroneously) display the wrong times:

Screenshot 2023-05-10 at 4 03 24 PM

Repeating this process on this PR's branch will save a snooze with the correct dtstart and consequently load the correct snooze time.

# Conflicts:
#	x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx
@Zacqary Zacqary added release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Alerting/RulesManagement Issues related to the Rules Management UX v8.9.0 v8.8.1 labels May 10, 2023
@Zacqary Zacqary requested a review from a team as a code owner May 10, 2023 21:05
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
triggersActionsUi 1.4MB 1.4MB +287.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@JiaweiWu JiaweiWu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! good catch, I wonder if the maintenance window date picker has the same bug too, I will have to test it out tomorrow.

@Zacqary
Copy link
Contributor Author

Zacqary commented May 17, 2023

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

Zacqary added a commit to Zacqary/kibana that referenced this pull request May 17, 2023
## Summary

Closes elastic#156535

The Snooze Scheduler was failing to properly save and load snoozes if
the user selected a timezone other than the Kibana default. This is
because the datepicker only converts timestamp values between UTC and
the default Kibana timezone.

This PR fixes the issue by offsetting all dates that come in and out of
the scheduler UI relative to local time.

To test, create a snooze like this on `main` and make sure you select
timezone America/Los_Angeles. (If your local timezone is equivalent to
America/Los_Angeles, select a different timezone)

<img width="426" alt="Screenshot 2023-05-10 at 3 58 57 PM"
src="https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d">

On `main`, editing the snooze will (erroneously) display the wrong
times:

<img width="423" alt="Screenshot 2023-05-10 at 4 03 24 PM"
src="https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64">

Repeating this process on this PR's branch will save a snooze with the
correct `dtstart` and consequently load the correct snooze time.

(cherry picked from commit 213a697)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 17, 2023
## Summary

Closes elastic#156535

The Snooze Scheduler was failing to properly save and load snoozes if
the user selected a timezone other than the Kibana default. This is
because the datepicker only converts timestamp values between UTC and
the default Kibana timezone.

This PR fixes the issue by offsetting all dates that come in and out of
the scheduler UI relative to local time.

To test, create a snooze like this on `main` and make sure you select
timezone America/Los_Angeles. (If your local timezone is equivalent to
America/Los_Angeles, select a different timezone)

<img width="426" alt="Screenshot 2023-05-10 at 3 58 57 PM"
src="https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d">

On `main`, editing the snooze will (erroneously) display the wrong
times:

<img width="423" alt="Screenshot 2023-05-10 at 4 03 24 PM"
src="https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64">

Repeating this process on this PR's branch will save a snooze with the
correct `dtstart` and consequently load the correct snooze time.

(cherry picked from commit 213a697)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

Zacqary added a commit that referenced this pull request May 17, 2023
# Backport

This will backport the following commits from `main` to `8.8`:
- [[RAM] Fix snooze scheduler timezone handling
(#157338)](#157338)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Zacqary Adam
Xeper","email":"Zacqary@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-17T16:41:04Z","message":"[RAM]
Fix snooze scheduler timezone handling (#157338)\n\n##
Summary\r\n\r\nCloses #156535 \r\n\r\nThe Snooze Scheduler was failing
to properly save and load snoozes if\r\nthe user selected a timezone
other than the Kibana default. This is\r\nbecause the datepicker only
converts timestamp values between UTC and\r\nthe default Kibana
timezone.\r\n\r\nThis PR fixes the issue by offsetting all dates that
come in and out of\r\nthe scheduler UI relative to local time.\r\n\r\nTo
test, create a snooze like this on `main` and make sure you
select\r\ntimezone America/Los_Angeles. (If your local timezone is
equivalent to\r\nAmerica/Los_Angeles, select a different
timezone)\r\n\r\n<img width=\"426\" alt=\"Screenshot 2023-05-10 at 3 58
57
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d\">\r\n\r\nOn
`main`, editing the snooze will (erroneously) display the
wrong\r\ntimes:\r\n\r\n<img width=\"423\" alt=\"Screenshot 2023-05-10 at
4 03 24
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64\">\r\n\r\nRepeating
this process on this PR's branch will save a snooze with the\r\ncorrect
`dtstart` and consequently load the correct snooze
time.","sha":"213a69739f89bde0fefab284618968a77d1798b8","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","Feature:Alerting/RulesManagement","v8.8.0","v8.9.0"],"number":157338,"url":"https://github.com/elastic/kibana/pull/157338","mergeCommit":{"message":"[RAM]
Fix snooze scheduler timezone handling (#157338)\n\n##
Summary\r\n\r\nCloses #156535 \r\n\r\nThe Snooze Scheduler was failing
to properly save and load snoozes if\r\nthe user selected a timezone
other than the Kibana default. This is\r\nbecause the datepicker only
converts timestamp values between UTC and\r\nthe default Kibana
timezone.\r\n\r\nThis PR fixes the issue by offsetting all dates that
come in and out of\r\nthe scheduler UI relative to local time.\r\n\r\nTo
test, create a snooze like this on `main` and make sure you
select\r\ntimezone America/Los_Angeles. (If your local timezone is
equivalent to\r\nAmerica/Los_Angeles, select a different
timezone)\r\n\r\n<img width=\"426\" alt=\"Screenshot 2023-05-10 at 3 58
57
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d\">\r\n\r\nOn
`main`, editing the snooze will (erroneously) display the
wrong\r\ntimes:\r\n\r\n<img width=\"423\" alt=\"Screenshot 2023-05-10 at
4 03 24
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64\">\r\n\r\nRepeating
this process on this PR's branch will save a snooze with the\r\ncorrect
`dtstart` and consequently load the correct snooze
time.","sha":"213a69739f89bde0fefab284618968a77d1798b8"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157338","number":157338,"mergeCommit":{"message":"[RAM]
Fix snooze scheduler timezone handling (#157338)\n\n##
Summary\r\n\r\nCloses #156535 \r\n\r\nThe Snooze Scheduler was failing
to properly save and load snoozes if\r\nthe user selected a timezone
other than the Kibana default. This is\r\nbecause the datepicker only
converts timestamp values between UTC and\r\nthe default Kibana
timezone.\r\n\r\nThis PR fixes the issue by offsetting all dates that
come in and out of\r\nthe scheduler UI relative to local time.\r\n\r\nTo
test, create a snooze like this on `main` and make sure you
select\r\ntimezone America/Los_Angeles. (If your local timezone is
equivalent to\r\nAmerica/Los_Angeles, select a different
timezone)\r\n\r\n<img width=\"426\" alt=\"Screenshot 2023-05-10 at 3 58
57
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d\">\r\n\r\nOn
`main`, editing the snooze will (erroneously) display the
wrong\r\ntimes:\r\n\r\n<img width=\"423\" alt=\"Screenshot 2023-05-10 at
4 03 24
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64\">\r\n\r\nRepeating
this process on this PR's branch will save a snooze with the\r\ncorrect
`dtstart` and consequently load the correct snooze
time.","sha":"213a69739f89bde0fefab284618968a77d1798b8"}}]}] BACKPORT-->
kibanamachine added a commit that referenced this pull request May 17, 2023
# Backport

This will backport the following commits from `main` to `8.8`:
- [[RAM] Fix snooze scheduler timezone handling
(#157338)](#157338)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Zacqary Adam
Xeper","email":"Zacqary@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-17T16:41:04Z","message":"[RAM]
Fix snooze scheduler timezone handling (#157338)\n\n##
Summary\r\n\r\nCloses #156535 \r\n\r\nThe Snooze Scheduler was failing
to properly save and load snoozes if\r\nthe user selected a timezone
other than the Kibana default. This is\r\nbecause the datepicker only
converts timestamp values between UTC and\r\nthe default Kibana
timezone.\r\n\r\nThis PR fixes the issue by offsetting all dates that
come in and out of\r\nthe scheduler UI relative to local time.\r\n\r\nTo
test, create a snooze like this on `main` and make sure you
select\r\ntimezone America/Los_Angeles. (If your local timezone is
equivalent to\r\nAmerica/Los_Angeles, select a different
timezone)\r\n\r\n<img width=\"426\" alt=\"Screenshot 2023-05-10 at 3 58
57
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d\">\r\n\r\nOn
`main`, editing the snooze will (erroneously) display the
wrong\r\ntimes:\r\n\r\n<img width=\"423\" alt=\"Screenshot 2023-05-10 at
4 03 24
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64\">\r\n\r\nRepeating
this process on this PR's branch will save a snooze with the\r\ncorrect
`dtstart` and consequently load the correct snooze
time.","sha":"213a69739f89bde0fefab284618968a77d1798b8","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","Feature:Alerting/RulesManagement","v8.9.0","v8.8.1"],"number":157338,"url":"https://github.com/elastic/kibana/pull/157338","mergeCommit":{"message":"[RAM]
Fix snooze scheduler timezone handling (#157338)\n\n##
Summary\r\n\r\nCloses #156535 \r\n\r\nThe Snooze Scheduler was failing
to properly save and load snoozes if\r\nthe user selected a timezone
other than the Kibana default. This is\r\nbecause the datepicker only
converts timestamp values between UTC and\r\nthe default Kibana
timezone.\r\n\r\nThis PR fixes the issue by offsetting all dates that
come in and out of\r\nthe scheduler UI relative to local time.\r\n\r\nTo
test, create a snooze like this on `main` and make sure you
select\r\ntimezone America/Los_Angeles. (If your local timezone is
equivalent to\r\nAmerica/Los_Angeles, select a different
timezone)\r\n\r\n<img width=\"426\" alt=\"Screenshot 2023-05-10 at 3 58
57
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d\">\r\n\r\nOn
`main`, editing the snooze will (erroneously) display the
wrong\r\ntimes:\r\n\r\n<img width=\"423\" alt=\"Screenshot 2023-05-10 at
4 03 24
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64\">\r\n\r\nRepeating
this process on this PR's branch will save a snooze with the\r\ncorrect
`dtstart` and consequently load the correct snooze
time.","sha":"213a69739f89bde0fefab284618968a77d1798b8"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157338","number":157338,"mergeCommit":{"message":"[RAM]
Fix snooze scheduler timezone handling (#157338)\n\n##
Summary\r\n\r\nCloses #156535 \r\n\r\nThe Snooze Scheduler was failing
to properly save and load snoozes if\r\nthe user selected a timezone
other than the Kibana default. This is\r\nbecause the datepicker only
converts timestamp values between UTC and\r\nthe default Kibana
timezone.\r\n\r\nThis PR fixes the issue by offsetting all dates that
come in and out of\r\nthe scheduler UI relative to local time.\r\n\r\nTo
test, create a snooze like this on `main` and make sure you
select\r\ntimezone America/Los_Angeles. (If your local timezone is
equivalent to\r\nAmerica/Los_Angeles, select a different
timezone)\r\n\r\n<img width=\"426\" alt=\"Screenshot 2023-05-10 at 3 58
57
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ab95c47c-30a0-44d5-bd9d-45fdb929193d\">\r\n\r\nOn
`main`, editing the snooze will (erroneously) display the
wrong\r\ntimes:\r\n\r\n<img width=\"423\" alt=\"Screenshot 2023-05-10 at
4 03 24
PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1445834/ff28ccdd-f491-43ce-87cd-d606c8d71c64\">\r\n\r\nRepeating
this process on this PR's branch will save a snooze with the\r\ncorrect
`dtstart` and consequently load the correct snooze
time.","sha":"213a69739f89bde0fefab284618968a77d1798b8"}},{"branch":"8.8","label":"v8.8.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Zacqary Adam Xeper <Zacqary@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.8.0 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAM][Security Solution] Timezones are not taken into consideration in rule snooze
6 participants