-
Notifications
You must be signed in to change notification settings - Fork 208
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
csi: add hooks in both Node and Controller Services #968
Conversation
/hold This is a WIP design. This code is being tested on openshift/aws-ebs-csi-driver-operator#104. |
Should there be a similar hook for DaemonSet? |
ef266f6
to
e7e6303
Compare
Added, but no operator is using it ATM |
/hold cancel I've tested this with openshift/aws-ebs-csi-driver-operator#104 and it works. |
@deads2k could you take a look, please? |
6ea769d
to
ecd6418
Compare
@@ -89,14 +92,16 @@ func NewCSIDriverControllerServiceController( | |||
deployInformer appsinformersv1.DeploymentInformer, | |||
optionalConfigInformer configinformers.SharedInformerFactory, | |||
recorder events.Recorder, | |||
optionalDeploymentHooks ...func(*appsv1.Deployment) error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to either give owner of the controller a way how to poke the controller for resync (i.e. the owner has informer on secrets / config maps / whatnot and is able to enqueue "fake" event into CSIDriverControllerServiceController' queue) or pass informers to watch into the NewCSIDriverControllerServiceController
?
I can see there is ResyncEvery(time.Minute)
below, so this PR will work even without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to address this in another PR?
Also, could you clarify a use case for poking the controller for resync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
/assign @deads2k |
/lgtm |
@@ -422,33 +469,6 @@ func TestSync(t *testing.T) { | |||
withFalseConditions(conditionProgressing)), | |||
}, | |||
}, | |||
{ | |||
// Deployment is fully deployed and its status is synced to CR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this rubs me the wrong way. Why did it need to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a duplicate of the test case right above, probably copied by mistake.
@@ -63,6 +64,8 @@ type CSIDriverNodeServiceController struct { | |||
operatorClient v1helpers.OperatorClient | |||
kubeClient kubernetes.Interface | |||
dsInformer appsinformersv1.DaemonSetInformer | |||
// Optional hook functions to modify the DaemonSet. | |||
optionalDaemonSetHooks []func(*appsv1.DaemonSet) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typed functions please. Also, make clear what happens on errors and where responsibility for identifying which function is failing lies in the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for _, fn := range c.optionalDaemonSetHooks { | ||
err := fn(required) | ||
if err != nil { | ||
return fmt.Errorf("error running hook function: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can at least give me an ordinal (i
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
donw
I'm curious what you're trying to replace/mutate. Some sorts of mutations are easier while you still have bytes (this is why we have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what you're trying to replace/mutate. Some sorts of mutations are easier while you still have bytes (this is why we have the replacePlaceholders).
As more CSI operators use these control loops, we want to give them freedom to mutate the deployment/daemonset without adding placeholders to library-go, specially if the mutation is specific to that operator, like this one: openshift/aws-ebs-csi-driver-operator#102
Most operators won't need this, and the default mutation approach should be the string replacements, but I figured for some situations mutating the object is better.
Does that make sense?
@@ -422,33 +469,6 @@ func TestSync(t *testing.T) { | |||
withFalseConditions(conditionProgressing)), | |||
}, | |||
}, | |||
{ | |||
// Deployment is fully deployed and its status is synced to CR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a duplicate of the test case right above, probably copied by mistake.
for _, fn := range c.optionalDaemonSetHooks { | ||
err := fn(required) | ||
if err != nil { | ||
return fmt.Errorf("error running hook function: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
donw
@@ -63,6 +64,8 @@ type CSIDriverNodeServiceController struct { | |||
operatorClient v1helpers.OperatorClient | |||
kubeClient kubernetes.Interface | |||
dsInformer appsinformersv1.DaemonSetInformer | |||
// Optional hook functions to modify the DaemonSet. | |||
optionalDaemonSetHooks []func(*appsv1.DaemonSet) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I understand the desire. I'd be somewhat interested in what you're combining because I've regretted it in the past. But I'm ok adding the option |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bertinatto, deads2k, jsafrane 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 |
CC @openshift/storage