Bump sigs.k8s.io/controller-runtime to v0.14.4 (#5507)
* Bump sigs.k8s.io/controller-runtime to v0.14.4 * Update gofmt
This commit is contained in:
94
vendor/sigs.k8s.io/controller-runtime/pkg/manager/manager.go
generated
vendored
94
vendor/sigs.k8s.io/controller-runtime/pkg/manager/manager.go
generated
vendored
@@ -18,6 +18,7 @@ package manager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -35,8 +36,8 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/cache"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/cluster"
|
||||
"sigs.k8s.io/controller-runtime/pkg/config"
|
||||
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/config" //nolint:staticcheck
|
||||
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
|
||||
"sigs.k8s.io/controller-runtime/pkg/healthz"
|
||||
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
|
||||
"sigs.k8s.io/controller-runtime/pkg/leaderelection"
|
||||
@@ -93,7 +94,11 @@ type Manager interface {
|
||||
GetLogger() logr.Logger
|
||||
|
||||
// GetControllerOptions returns controller global configuration options.
|
||||
GetControllerOptions() v1alpha1.ControllerConfigurationSpec
|
||||
//
|
||||
// Deprecated: In a future version, the returned value is going to be replaced with a
|
||||
// different type that doesn't rely on component configuration types.
|
||||
// This is a temporary warning, and no action is needed as of today.
|
||||
GetControllerOptions() v1alpha1.ControllerConfigurationSpec //nolint:staticcheck
|
||||
}
|
||||
|
||||
// Options are the arguments for creating a new Manager.
|
||||
@@ -142,18 +147,36 @@ type Options struct {
|
||||
LeaderElection bool
|
||||
|
||||
// LeaderElectionResourceLock determines which resource lock to use for leader election,
|
||||
// defaults to "configmapsleases". Change this value only if you know what you are doing.
|
||||
// Otherwise, users of your controller might end up with multiple running instances that
|
||||
// defaults to "leases". Change this value only if you know what you are doing.
|
||||
//
|
||||
// If you are using `configmaps`/`endpoints` resource lock and want to migrate to "leases",
|
||||
// you might do so by migrating to the respective multilock first ("configmapsleases" or "endpointsleases"),
|
||||
// which will acquire a leader lock on both resources.
|
||||
// After all your users have migrated to the multilock, you can go ahead and migrate to "leases".
|
||||
// Please also keep in mind, that users might skip versions of your controller.
|
||||
//
|
||||
// Note: before controller-runtime version v0.7, it was set to "configmaps".
|
||||
// And from v0.7 to v0.11, the default was "configmapsleases", which was
|
||||
// used to migrate from configmaps to leases.
|
||||
// Since the default was "configmapsleases" for over a year, spanning five minor releases,
|
||||
// any actively maintained operators are very likely to have a released version that uses
|
||||
// "configmapsleases". Therefore defaulting to "leases" should be safe since v0.12.
|
||||
//
|
||||
// So, what do you have to do when you are updating your controller-runtime dependency
|
||||
// from a lower version to v0.12 or newer?
|
||||
// - If your operator matches at least one of these conditions:
|
||||
// - the LeaderElectionResourceLock in your operator has already been explicitly set to "leases"
|
||||
// - the old controller-runtime version is between v0.7.0 and v0.11.x and the
|
||||
// LeaderElectionResourceLock wasn't set or was set to "leases"/"configmapsleases"/"endpointsleases"
|
||||
// feel free to update controller-runtime to v0.12 or newer.
|
||||
// - Otherwise, you may have to take these steps:
|
||||
// 1. update controller-runtime to v0.12 or newer in your go.mod
|
||||
// 2. set LeaderElectionResourceLock to "configmapsleases" (or "endpointsleases")
|
||||
// 3. package your operator and upgrade it in all your clusters
|
||||
// 4. only if you have finished 3, you can remove the LeaderElectionResourceLock to use the default "leases"
|
||||
// Otherwise, your operator might end up with multiple running instances that
|
||||
// each acquired leadership through different resource locks during upgrades and thus
|
||||
// act on the same resources concurrently.
|
||||
// If you want to migrate to the "leases" resource lock, you might do so by migrating to the
|
||||
// respective multilock first ("configmapsleases" or "endpointsleases"), which will acquire a
|
||||
// leader lock on both resources. After all your users have migrated to the multilock, you can
|
||||
// go ahead and migrate to "leases". Please also keep in mind, that users might skip versions
|
||||
// of your controller.
|
||||
//
|
||||
// Note: before controller-runtime version v0.7, the resource lock was set to "configmaps".
|
||||
// Please keep this in mind, when planning a proper migration path for your controller.
|
||||
LeaderElectionResourceLock string
|
||||
|
||||
// LeaderElectionNamespace determines the namespace in which the leader
|
||||
@@ -175,6 +198,12 @@ type Options struct {
|
||||
// LeaseDuration time first.
|
||||
LeaderElectionReleaseOnCancel bool
|
||||
|
||||
// LeaderElectionResourceLockInterface allows to provide a custom resourcelock.Interface that was created outside
|
||||
// of the controller-runtime. If this value is set the options LeaderElectionID, LeaderElectionNamespace,
|
||||
// LeaderElectionResourceLock, LeaseDuration, RenewDeadline and RetryPeriod will be ignored. This can be useful if you
|
||||
// want to use a locking mechanism that is currently not supported, like a MultiLock across two Kubernetes clusters.
|
||||
LeaderElectionResourceLockInterface resourcelock.Interface
|
||||
|
||||
// LeaseDuration is the duration that non-leader candidates will
|
||||
// wait to force acquire leadership. This is measured against time of
|
||||
// last observed ack. Default is 15 seconds.
|
||||
@@ -201,6 +230,7 @@ type Options struct {
|
||||
|
||||
// HealthProbeBindAddress is the TCP address that the controller should bind to
|
||||
// for serving health probes
|
||||
// It can be set to "0" or "" to disable serving the health probe.
|
||||
HealthProbeBindAddress string
|
||||
|
||||
// Readiness probe endpoint name, defaults to "readyz"
|
||||
@@ -223,6 +253,9 @@ type Options struct {
|
||||
// It is used to set webhook.Server.CertDir if WebhookServer is not set.
|
||||
CertDir string
|
||||
|
||||
// TLSOpts is used to allow configuring the TLS config used for the webhook server.
|
||||
TLSOpts []func(*tls.Config)
|
||||
|
||||
// WebhookServer is an externally configured webhook.Server. By default,
|
||||
// a Manager will create a default server using Port, Host, and CertDir;
|
||||
// if this is set, the Manager will use this server instead.
|
||||
@@ -268,7 +301,11 @@ type Options struct {
|
||||
// Controller contains global configuration options for controllers
|
||||
// registered within this manager.
|
||||
// +optional
|
||||
Controller v1alpha1.ControllerConfigurationSpec
|
||||
//
|
||||
// Deprecated: In a future version, the type of this field is going to be replaced with a
|
||||
// different struct that doesn't rely on component configuration types.
|
||||
// This is a temporary warning, and no action is needed as of today.
|
||||
Controller v1alpha1.ControllerConfigurationSpec //nolint:staticcheck
|
||||
|
||||
// makeBroadcaster allows deferring the creation of the broadcaster to
|
||||
// avoid leaking goroutines if we never call Start on this manager. It also
|
||||
@@ -358,14 +395,19 @@ func New(config *rest.Config, options Options) (Manager, error) {
|
||||
}
|
||||
}
|
||||
|
||||
resourceLock, err := options.newResourceLock(leaderConfig, leaderRecorderProvider, leaderelection.Options{
|
||||
LeaderElection: options.LeaderElection,
|
||||
LeaderElectionResourceLock: options.LeaderElectionResourceLock,
|
||||
LeaderElectionID: options.LeaderElectionID,
|
||||
LeaderElectionNamespace: options.LeaderElectionNamespace,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var resourceLock resourcelock.Interface
|
||||
if options.LeaderElectionResourceLockInterface != nil && options.LeaderElection {
|
||||
resourceLock = options.LeaderElectionResourceLockInterface
|
||||
} else {
|
||||
resourceLock, err = options.newResourceLock(leaderConfig, leaderRecorderProvider, leaderelection.Options{
|
||||
LeaderElection: options.LeaderElection,
|
||||
LeaderElectionResourceLock: options.LeaderElectionResourceLock,
|
||||
LeaderElectionID: options.LeaderElectionID,
|
||||
LeaderElectionNamespace: options.LeaderElectionNamespace,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Create the metrics listener. This will throw an error if the metrics bind
|
||||
@@ -403,7 +445,9 @@ func New(config *rest.Config, options Options) (Manager, error) {
|
||||
port: options.Port,
|
||||
host: options.Host,
|
||||
certDir: options.CertDir,
|
||||
tlsOpts: options.TLSOpts,
|
||||
webhookServer: options.WebhookServer,
|
||||
leaderElectionID: options.LeaderElectionID,
|
||||
leaseDuration: *options.LeaseDuration,
|
||||
renewDeadline: *options.RenewDeadline,
|
||||
retryPeriod: *options.RetryPeriod,
|
||||
@@ -420,6 +464,8 @@ func New(config *rest.Config, options Options) (Manager, error) {
|
||||
// AndFrom will use a supplied type and convert to Options
|
||||
// any options already set on Options will be ignored, this is used to allow
|
||||
// cli flags to override anything specified in the config file.
|
||||
//
|
||||
// Deprecated: This method will be removed in a future release.
|
||||
func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options, error) {
|
||||
if inj, wantsScheme := loader.(inject.Scheme); wantsScheme {
|
||||
err := inj.InjectScheme(o.Scheme)
|
||||
@@ -485,6 +531,8 @@ func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options,
|
||||
}
|
||||
|
||||
// AndFromOrDie will use options.AndFrom() and will panic if there are errors.
|
||||
//
|
||||
// Deprecated: This method will be removed in a future release.
|
||||
func (o Options) AndFromOrDie(loader config.ControllerManagerConfiguration) Options {
|
||||
o, err := o.AndFrom(loader)
|
||||
if err != nil {
|
||||
@@ -493,7 +541,7 @@ func (o Options) AndFromOrDie(loader config.ControllerManagerConfiguration) Opti
|
||||
return o
|
||||
}
|
||||
|
||||
func (o Options) setLeaderElectionConfig(obj v1alpha1.ControllerManagerConfigurationSpec) Options {
|
||||
func (o Options) setLeaderElectionConfig(obj v1alpha1.ControllerManagerConfigurationSpec) Options { //nolint:staticcheck
|
||||
if obj.LeaderElection == nil {
|
||||
// The source does not have any configuration; noop
|
||||
return o
|
||||
|
||||
Reference in New Issue
Block a user