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 csi driver and controller plugin deployment #13

Closed
wants to merge 1 commit into from
Closed

csi: add csi driver and controller plugin deployment #13

wants to merge 1 commit into from

Conversation

leelavg
Copy link
Contributor

@leelavg leelavg commented Dec 9, 2021

Signed-off-by: Leela Venkaiah G [email protected]

r.Log.Error(err, "unable to retrieve csi controller deployment", "TopolvmController", cd.Name)
return err
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

The deployment should be deleted here.

Copy link
Contributor

Choose a reason for hiding this comment

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

For a deployment, an ownerReference should be enough for cleanup.
Not for cluster scoped objects or complex cleanups though.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the expected behaviour if the lvmcluster object is deleted? Shouldn't the deployment be deleted as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • I understood that if lvm cr is deleted then controller will also be deleted due to owner ref
  • However I'm unsure whether dependents will be deleted after realizing deletestamp on owner or owner needs to be deleted (like actual deletion ~Not found)🤔

Copy link
Contributor

@nbalacha nbalacha Dec 9, 2021

Choose a reason for hiding this comment

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

At what point will the deployment be deleted? As soon as the delete operation is performed or after the finalizer is removed from the LvmController? The operator waits for all resources to be deleted before removing the finalizer.

If it is deleted before the finalizer is removed, then this method should return an error as long as the deployment resource exists in order to prevent the premature removal of the finalizer. If not, this is not a good candidate for the resource manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nbalacha

  • I did some testing using configmaps with finalizers and ownerreferences and here's the gist in current context
  1. If controller deployment were to depend on lvmcluster CR, if I set non-blocking ownerref on deployment and you set finalizer on CR, when you remove the finalizer then only controller deployment will be deleted
  2. However the current reconciler only removes the finalizer when all the units get deleted, in this case I do not depend on lvm CR to be the owner and listen to reconciler to delete deployment whenever it's called
  • I see two ways out of it
  1. You do not change the reconcile and send delete op to the resource units and I'll add deletion logic
  2. You can just remove the finalizer and send a delete op to the resource units and reconcile for nil (because some resources like csidriver is cluster scoped and doesn't respect ownerref)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets stick with the current approach for now - the ensureDeleted will effectively be a noop for topolvm-controller. The lvmcluster controller will remove the finalizer when all resource managers return nil . The LVMCluster object will then be removed followed the topolvm-controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • uh oh, just saw this review after adding tests
  • anyways will raise separate PRs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • I'm continuing with a non-blocking owner reference and also implementing custom logic for controller deletion
  • We can decide what exactly to be used as it's not of utmost importance as of now

controllers/defaults.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jmolmo jmolmo left a comment

Choose a reason for hiding this comment

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

Just minor things... probably only for discussion. LGTM

}

// TODO: Remove custom generation of TLS certs, find where it's being used in the first place in Topolvm Code
iContainers := []corev1.Container{*getInitContainer()}
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not have any way to avoid the creation and use of self-signed certs. "cert manager" can provide certificates in a secret. if we verify the secret exists we can use these certificates, if the secret does not exist, then we can create self signed certificates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • ack, I wasn't able to confirm where does topolvm actually use these certs and I mean that in the comment.
  • for now we are going with manual generation of certs using initContainer and replacing it with cert-manager is being investigated


ssCertGenerator := &corev1.Container{
Name: "self-signed-cert-generator",
Image: "alpine/openssl",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to make very easy to change this image. What about to use a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • for now we just need to generate and use those certs, so changing base image would have any effect in openssl?

controllers/topolvm_csi_driver.go Outdated Show resolved Hide resolved
@jmolmo jmolmo mentioned this pull request Dec 9, 2021
Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

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

General comments:
Please split the csiDriver and the csiController changes into 2 separate PRs.
Please remove the design doc changes from this PR. That can go in a separate PR.

controllers/defaults.go Outdated Show resolved Hide resolved
@leelavg
Copy link
Contributor Author

leelavg commented Dec 9, 2021

Thanks all for your early reviews, I'll address them at the earliest 😀

@nbalacha
Copy link
Contributor

nbalacha commented Dec 9, 2021

Does the topolvm-controller need anything special wrt SCCs?

@leelavg
Copy link
Contributor Author

leelavg commented Dec 9, 2021

Does the topolvm-controller need anything special wrt SCCs?

Afair, normal rbac would do, I will add them (rbac) based on topolvm helm chart.

@leelavg
Copy link
Contributor Author

leelavg commented Dec 10, 2021

Does the topolvm-controller need anything special wrt SCCs?

after referring to topolvm controller rbac, I don't see the need for SCC, those will be need for vgmanager and nodeplugin.

@@ -95,7 +95,11 @@ func (r *LVMClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// errors returned by this will be updated in the reconcileSucceeded condition of the LVMCluster
func (r *LVMClusterReconciler) reconcile(ctx context.Context, instance *lvmv1alpha1.LVMCluster) (ctrl.Result, error) {
resourceList := []resourceManager{}
// TODO: Resource deletion should be in reverse order of install
resourceList := []resourceManager{
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be split up amongst the 2 PRs (CSIDriver and topolvm-controller)


// get the desired state of topolvm controller deployment
controllerDeployment := getControllerDeployment(lvmCluster)
result, err := cutil.CreateOrUpdate(ctx, r.Client, controllerDeployment, func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to update only if there is a change in the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Topolvm Controller deployment is resistant to LVM Cluster CR Updates
  • After first creation the result will mostly be Unchanged
  • Current implementation is used only to facilitate upgrade due to change in images, if both desired and existing state is same then it'll be Unchanged

// Let's make sure our Schedule string value was properly converted/handled.
Expect(lvmCluster1.Status.Ready).Should(Equal(true))

By("Confirming deletion of lvm cluster")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move the deletion to a separate test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • this is all part of It("Reconciles an LvmCluster, " if I were to move it to a separate test then I think I need to deploy again and then delete

controllers/lvmcluster_controller_test.go Outdated Show resolved Hide resolved
@leelavg leelavg closed this Dec 14, 2021
@leelavg leelavg deleted the csi-controller branch December 21, 2021 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants