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

csi: add hooks in both Node and Controller Services #968

Merged
merged 2 commits into from
Jan 6, 2021

Conversation

bertinatto
Copy link
Member

CC @openshift/storage

@bertinatto
Copy link
Member Author

bertinatto commented Dec 9, 2020

/hold

This is a WIP design. This code is being tested on openshift/aws-ebs-csi-driver-operator#104.

@jsafrane
Copy link
Contributor

Should there be a similar hook for DaemonSet?

@bertinatto bertinatto force-pushed the add-hook branch 3 times, most recently from ef266f6 to e7e6303 Compare December 10, 2020 19:24
@bertinatto bertinatto changed the title csi: add controller deployment hook csi: add hooks in both Node and Controller Services Dec 10, 2020
@bertinatto
Copy link
Member Author

Should there be a similar hook for DaemonSet?

Added, but no operator is using it ATM

@bertinatto
Copy link
Member Author

/hold cancel

I've tested this with openshift/aws-ebs-csi-driver-operator#104 and it works.

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 10, 2020
@bertinatto
Copy link
Member Author

@deads2k could you take a look, please?

@bertinatto bertinatto force-pushed the add-hook branch 3 times, most recently from 6ea769d to ecd6418 Compare December 11, 2020 12:30
@@ -89,14 +92,16 @@ func NewCSIDriverControllerServiceController(
deployInformer appsinformersv1.DeploymentInformer,
optionalConfigInformer configinformers.SharedInformerFactory,
recorder events.Recorder,
optionalDeploymentHooks ...func(*appsv1.Deployment) error,
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack

@bertinatto
Copy link
Member Author

/assign @deads2k

@jsafrane
Copy link
Contributor

jsafrane commented Jan 5, 2021

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 5, 2021
@@ -422,33 +469,6 @@ func TestSync(t *testing.T) {
withFalseConditions(conditionProgressing)),
},
},
{
// Deployment is fully deployed and its status is synced to CR
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

donw

@deads2k
Copy link
Contributor

deads2k commented Jan 6, 2021

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).

Copy link
Member Author

@bertinatto bertinatto left a 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
Copy link
Member Author

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)
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

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

done

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 6, 2021
@deads2k
Copy link
Contributor

deads2k commented Jan 6, 2021

Does that make sense?

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

@deads2k
Copy link
Contributor

deads2k commented Jan 6, 2021

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 6, 2021
@openshift-ci-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 6, 2021
@openshift-merge-robot openshift-merge-robot merged commit c4d0b9c into openshift:master Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants