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

OCPBUGS-24588: use new workload controller with preconditions #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions pkg/operator/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ type OperatorControllerConfig struct {
GuestDaemonSetHooks []csidrivernodeservicecontroller.DaemonSetHookFunc
// List of informers that should be added to the guest DaemonSet controller.
GuestDaemonSetInformers []factory.Informer

// List of functions that should return true if we want the controller to sync normally.
// Returning false or error will degrade the cluster with OperatorCondition.Reason set to "PreconditionNotFulfilled"
// and any errors returned are shown as OperatorCondition.Message
Preconditions []deploymentcontroller.PreconditionFunc

// List of hooks should be run on the storage classes.
// No informers here, because StorageClassController does not accept any.
StorageClassHooks []csistorageclasscontroller.StorageClassHookFunc
Expand Down Expand Up @@ -116,6 +122,20 @@ func (o *OperatorControllerConfig) AddStorageClassHookBuilders(c *clients.Client
}
}

func (o *OperatorControllerConfig) AddPreconditions(preconditionFuncs ...deploymentcontroller.PreconditionFunc) {
for _, f := range preconditionFuncs {
o.Preconditions = append(o.Preconditions, f)
}
}

func (o *OperatorControllerConfig) GetPreconditions() []func(context.Context) (bool, error) {
var funcs []func(context.Context) (bool, error)
for _, precondition := range o.Preconditions {
funcs = append(funcs, precondition)
}
return funcs
}

type DeploymentHookBuilder func(c *clients.Clients) (deploymentcontroller.DeploymentHookFunc, []factory.Informer)
type DaemonSetHookBuilder func(c *clients.Clients) (csidrivernodeservicecontroller.DaemonSetHookFunc, []factory.Informer)
type StorageClassHookBuilder func(c *clients.Clients) csistorageclasscontroller.StorageClassHookFunc
Expand Down
6 changes: 4 additions & 2 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
).WithCSIConfigObserverController(
csiOperatorControllerConfig.GetControllerName("DriverCSIConfigObserverController"),
c.ConfigInformers,
).WithCSIDriverControllerService(
).WithCSIDriverControllerServiceWorkload(
csiOperatorControllerConfig.GetControllerName("DriverControllerServiceController"),
controlPlaneNamespace,
a.GetAsset,
generated_assets.ControllerDeploymentAssetName,
c.ControlPlaneKubeClient,
c.ControlPlaneKubeInformers.InformersFor(controlPlaneNamespace),
c.ControlPlaneKubeInformers,
c.ConfigInformers,
csiOperatorControllerConfig.GetPreconditions(),
controlPlaneControllerInformers,
controllerHooks...,
)
Expand Down