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

CNF-12656: Handle SIGTERM for stateroot setup job #498

Conversation

pixelsoccupied
Copy link
Contributor

@pixelsoccupied pixelsoccupied commented May 10, 2024

This PR aims to handle the case when Stateroot setup job may be in-progress and an unexpected SIGTERM is received (e.g moving to Idle while Prep in progress).

The solution is broken into to two parts:

k8s:

  • The max wait time before a SIGKILL is sent is determined with TerminationGracePeriodSeconds. This is now set to 60 secs (default 30)
  • PreStop lifecycle handler was investigated but not useful in our case. Generally it's used to delay the container from getting SIGTERM and in the meantime k8s does other housekeeping tasks (e.g de-registering Ingress) to avoid any race conditions.

Handler in the code:

  • Every app is expected to have it's own signal handler. In this case if seed image is present we allow the rest of the stateroot setup to go through by sleeping at most time set with TerminationGracePeriodSeconds before shutting down.

/cc @donpenney @jc-rh

@openshift-ci-robot
Copy link

openshift-ci-robot commented May 10, 2024

@pixelsoccupied: This pull request references CNF-12656 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

In response to this:

This PR aims to handle the case when Stateroot setup job may be in-progress and an unexpected SIGTERM is received (e.g moving to Idle while Prep in progress).

The solution is broken into to two parts:

k8s:

  • The max wait time before a SIGKILL is sent is determined with TerminationGracePeriodSeconds. This is now set to 60 secs (default 30)
  • PreStop lifecycle handler was investigated but not useful in our case. Generally it's used to delay the container from getting SIGTERM and in the meantime k8s does other housekeeping tasks (e.g de-registering Ingress) to avoid any race conditions.

Handler in the code:

  • Every app is expected to have it's own signal handler. In this case are simply canceling context and sleep at most time set with TerminationGracePeriodSeconds before shutting down.

/cc @donpenney @jc-rh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from donpenney and jc-rh May 10, 2024 16:12
@pixelsoccupied pixelsoccupied force-pushed the handle-sigterm-stateroot branch 3 times, most recently from 210168d to 0e165cb Compare May 12, 2024 20:07
@openshift-ci-robot
Copy link

openshift-ci-robot commented May 12, 2024

@pixelsoccupied: This pull request references CNF-12656 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

In response to this:

This PR aims to handle the case when Stateroot setup job may be in-progress and an unexpected SIGTERM is received (e.g moving to Idle while Prep in progress).

The solution is broken into to two parts:

k8s:

  • The max wait time before a SIGKILL is sent is determined with TerminationGracePeriodSeconds. This is now set to 60 secs (default 30)
  • PreStop lifecycle handler was investigated but not useful in our case. Generally it's used to delay the container from getting SIGTERM and in the meantime k8s does other housekeeping tasks (e.g de-registering Ingress) to avoid any race conditions.

Handler in the code:

  • Every app is expected to have it's own signal handler. In this case if seed image is present we allow the rest of the stateroot setup to go through by sleeping at most time set with TerminationGracePeriodSeconds before shutting down.

/cc @donpenney @jc-rh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@pixelsoccupied pixelsoccupied force-pushed the handle-sigterm-stateroot branch 3 times, most recently from 76d225c to 5e2b8d2 Compare May 13, 2024 14:33
@pixelsoccupied
Copy link
Contributor Author

/hold
will update the graceperiod to 30 mins + document this behaviour

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 13, 2024
@pixelsoccupied pixelsoccupied force-pushed the handle-sigterm-stateroot branch 4 times, most recently from 09a5d77 to 7fad35f Compare May 13, 2024 18:43
@pixelsoccupied
Copy link
Contributor Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 13, 2024
@pixelsoccupied pixelsoccupied force-pushed the handle-sigterm-stateroot branch 3 times, most recently from c944c6c to 0ff2418 Compare May 13, 2024 20:19
@pixelsoccupied
Copy link
Contributor Author

/retest

@pixelsoccupied
Copy link
Contributor Author

/test ibu-e2e-flow

controllers/idle_handlers.go Outdated Show resolved Hide resolved
docs/image-based-upgrade.md Outdated Show resolved Hide resolved
docs/image-based-upgrade.md Outdated Show resolved Hide resolved
docs/image-based-upgrade.md Outdated Show resolved Hide resolved
@pixelsoccupied pixelsoccupied force-pushed the handle-sigterm-stateroot branch 2 times, most recently from e994064 to 03f40f2 Compare May 14, 2024 13:47
@pixelsoccupied pixelsoccupied force-pushed the handle-sigterm-stateroot branch 3 times, most recently from 1ac37dd to d93f532 Compare May 15, 2024 15:12
Copy link
Collaborator

@donpenney donpenney left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 15, 2024
Copy link
Contributor

openshift-ci bot commented May 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jc-rh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 15, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit fb1ee6b into openshift-kni:main May 15, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants