operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

Graceful shutdown

Open elliotfehr opened this issue 4 years ago • 9 comments

Bug Report

What did you do?

Issued a SIGTERM to the operator-sdk while an ansible-runner was in progress.

What did you expect to see?

The operator-sdk should block shutdown until the graceful shutdown option has been exceeded

What did you see instead? Under which circumstances?

The operator-sdk exits immediately when receiving a shutdown signal.

Environment

Operator type: /language ansible

Kubernetes cluster type: vanilla

$ operator-sdk version be54561d10dd8da6bc78db129534d2df995fa993

$ go version (if language is Go) go version go1.15.5 darwin/amd64

$ kubectl version v1.19.10

Possible Solution

As far as I can tell the controller runtime manager expects runners to block until their execution is complete. Since the operator runs the ansible tasks in a goroutine, the process immediately exits when the controller receives a shutdown signal: https://github.com/operator-framework/operator-sdk/blob/master/internal/ansible/runner/runner.go#L255-L300

We also wait for either the proxy or manager to exit gracefully before shutting down here: https://github.com/operator-framework/operator-sdk/blob/master/internal/cmd/ansible-operator/run/cmd.go#L260-L261 and should likely check to make sure the manager has successfully completed all tasks before shutting down the proxy.

Additional context

Attempted adding in the ability to gracefully shutdown here: https://github.com/operator-framework/operator-sdk/pull/4571

Related to https://github.com/operator-framework/operator-sdk/issues/1843 and https://github.com/operator-framework/operator-sdk/pull/4571

elliotfehr avatar Jun 18 '21 02:06 elliotfehr

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Sep 19 '21 20:09 openshift-bot

/remove-lifecycle stale

elliotfehr avatar Sep 19 '21 21:09 elliotfehr

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Dec 18 '21 22:12 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Jan 17 '22 22:01 openshift-bot

/remove-lifecycle rotten

elliotfehr avatar Jan 17 '22 23:01 elliotfehr

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Apr 18 '22 05:04 openshift-bot

/remove-lifecycle stale

elliotfehr avatar May 04 '22 21:05 elliotfehr

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Aug 03 '22 01:08 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Sep 02 '22 08:09 openshift-bot

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar Oct 03 '22 00:10 openshift-bot

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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 kubernetes/test-infra repository.

openshift-ci[bot] avatar Oct 03 '22 00:10 openshift-ci[bot]