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

centralize registration of exit handlers #230

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

lstocchi
Copy link
Contributor

@lstocchi lstocchi commented Nov 29, 2024

this PR centralizes the registration of exit handlers so that we can register an exit handler from anywhere and it will be invoked before terminating vfkit.

The PR also registers an exit handler to remove the ignition socket.

It resolves #229

Copy link

openshift-ci bot commented Nov 29, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

// This method is useful when a caller wishes to execute a func before a shutdown.
func RegisterExitHandler(handler func()) {
exitHandlers = append(exitHandlers, handler)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The use of a global variable means RegisterExitHandler should not be called from multiple go routines simultaneously. The next commit will call it from a go routine which is not the main one, it's safer to add a mutex to protect accesses to exitHandlers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated 👍

Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
Copy link
Collaborator

@cfergeau cfergeau left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Copy link

openshift-ci bot commented Jan 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfergeau

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-merge-bot openshift-merge-bot bot merged commit 9c685bc into crc-org:main Jan 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to register exit handlers
2 participants