Skip to content

Graceful shutdown timeout #4571

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

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/fragments/ansible-drain-time.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
entries:
- description: >
For Ansible-based operators, allow passing a --drain-time to configure the duration the manager should wait before stopping.
Copy link
Member

Choose a reason for hiding this comment

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

Why call this --drain-time? Does this terminology come from somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No real reason or preference here. Any suggestions for what to name it?

Copy link
Member

Choose a reason for hiding this comment

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

--graceful-shutdown-timeout

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 all references!

kind: "addition"
breaking: false
7 changes: 7 additions & 0 deletions internal/ansible/flags/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Flags struct {
ProbeAddr string
LeaderElectionID string
LeaderElectionNamespace string
DrainTime time.Duration
AnsibleArgs string
}

Expand Down Expand Up @@ -109,6 +110,12 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
" holding the leader lock (required if running locally with leader"+
" election enabled).",
)
flagSet.DurationVar(&f.DrainTime,
"drain-time",
30*time.Second,
"The amount of time that will be spent waiting"+
" for runners to gracefully exit.",
)
flagSet.StringVar(&f.AnsibleArgs,
"ansible-args",
"",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/ansible-operator/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func run(cmd *cobra.Command, f *flags.Flags) {
LeaderElectionResourceLock: resourcelock.ConfigMapsResourceLock,
LeaderElectionNamespace: f.LeaderElectionNamespace,
ClientBuilder: clientbuilder.NewUnstructedCached(),
GracefulShutdownTimeout: &f.DrainTime,
}

namespace, found := os.LookupEnv(k8sutil.WatchNamespaceEnvVar)
Expand Down