From 68b18487e14bec1f50923da7b2b9a843ade8b41c Mon Sep 17 00:00:00 2001 From: Rohan CJ Date: Fri, 3 Dec 2021 13:06:56 +0530 Subject: [PATCH 1/3] rename getDescription method to getName Signed-off-by: Rohan CJ --- controllers/lvmcluster_controller.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/lvmcluster_controller.go b/controllers/lvmcluster_controller.go index 995e22a41..69a93823e 100644 --- a/controllers/lvmcluster_controller.go +++ b/controllers/lvmcluster_controller.go @@ -82,7 +82,7 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request, for _, unit := range unitList { err := unit.ensureDeleted(r, *lvmCluster) if err != nil { - return result, fmt.Errorf("failed cleaning up: %s %w", unit.getDescription(), err) + return result, fmt.Errorf("failed cleaning up: %s %w", unit.getName(), err) } } } @@ -91,7 +91,7 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request, for _, unit := range unitList { err := unit.ensureCreated(r, *lvmCluster) if err != nil { - return result, fmt.Errorf("failed reconciling: %s %w", unit.getDescription(), err) + return result, fmt.Errorf("failed reconciling: %s %w", unit.getName(), err) } } @@ -101,8 +101,8 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request, for _, unit := range unitList { err := unit.updateStatus(r, *lvmCluster) if err != nil { - failedStatusUpdates = append(failedStatusUpdates, unit.getDescription()) - unitError := fmt.Errorf("failed updating status for: %s %w", unit.getDescription(), err) + failedStatusUpdates = append(failedStatusUpdates, unit.getName()) + unitError := fmt.Errorf("failed updating status for: %s %w", unit.getName(), err) logger.Error(unitError, "") } } @@ -116,7 +116,7 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request, } type reconcileUnit interface { - getDescription() string + getName() string ensureCreated(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error ensureDeleted(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error // each unit will have updateStatus called induvidually so From 84cd9e0748f4e72e3f8520cc7fe1f00573aca706 Mon Sep 17 00:00:00 2001 From: Rohan CJ Date: Fri, 3 Dec 2021 13:06:13 +0530 Subject: [PATCH 2/3] add doc comments to reconcileUnit interface Signed-off-by: Rohan CJ --- controllers/lvmcluster_controller.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/lvmcluster_controller.go b/controllers/lvmcluster_controller.go index 69a93823e..194eb94a2 100644 --- a/controllers/lvmcluster_controller.go +++ b/controllers/lvmcluster_controller.go @@ -116,9 +116,17 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request, } type reconcileUnit interface { + + // getName should return a camelCase name of this unit of reconciliation getName() string + + // ensureCreated should check the resources managed by this unit ensureCreated(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error + + // ensureDeleted should wait for the resources to be cleaned up ensureDeleted(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error + + // updateStatus should optionally update the CR's status about the health of the managed resource // each unit will have updateStatus called induvidually so // avoid status fields like lastHeartbeatTime and have a // status that changes only when the operands change. From 6c6c6c9e15487455b96e034b7cc5f76f0ed9d874 Mon Sep 17 00:00:00 2001 From: Rohan CJ Date: Fri, 3 Dec 2021 13:35:14 +0530 Subject: [PATCH 3/3] add design doc for lvmcluster operator Signed-off-by: Rohan CJ --- README.md | 3 ++ controllers/lvmcluster_controller.go | 1 + doc/design/README.md | 43 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 doc/design/README.md diff --git a/README.md b/README.md index b4305415d..605d654db 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # lvm-operator Operator that manages Topolvm + +# Contents +- [docs/design](doc/design/) diff --git a/controllers/lvmcluster_controller.go b/controllers/lvmcluster_controller.go index 194eb94a2..876d33f31 100644 --- a/controllers/lvmcluster_controller.go +++ b/controllers/lvmcluster_controller.go @@ -115,6 +115,7 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request, } +// NOTE: when updating this, please also update doc/design/README.md type reconcileUnit interface { // getName should return a camelCase name of this unit of reconciliation diff --git a/doc/design/README.md b/doc/design/README.md new file mode 100644 index 000000000..74d7c7867 --- /dev/null +++ b/doc/design/README.md @@ -0,0 +1,43 @@ +# Operator design + +# Controllers and their managed resources + + +- **lvmcluster-controller:** Running in the operator deployment, it will create all resources that are don't require information from the node. When applicable, the health of the underlying resource is updated in the LVMCluster status and errors are also exposed as events. Overall success also passed on as an event.: + - vgmanager daemonset + - this will require + - lvmd daemonset + - CSIDriver CR + - CSI Driver Controller Deployment (controller is the name of the csi-component) + - CSI Driver Daemonset + - needs an initContainer to block until lvmd config file is read + - StorageClass (TBD) +- **The vg-manager:** A daemonset with one instance per selected node, will create all resources that require knowledge from the node. Errors and PVs being added to a volumegroup will be passed on as events. + - volumegroups + - lvmd config file + + + +Each unit of reconciliation should implement the reconcileUnit interface. +This will be run by the controller, and errors and success will be propogated to the status and events. +This interface is defined in [lvmcluster_controller.go](../../controllers/lvmcluster_controller.go) + +``` +type reconcileUnit interface { + + // getName should return a camelCase name of this unit of reconciliation + getName() string + + // ensureCreated should check the resources managed by this unit + ensureCreated(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error + + // ensureDeleted should wait for the resources to be cleaned up + ensureDeleted(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error + + // updateStatus should optionally update the CR's status about the health of the managed resource + // each unit will have updateStatus called induvidually so + // avoid status fields like lastHeartbeatTime and have a + // status that changes only when the operands change. + updateStatus(*LVMClusterReconciler, lvmv1alpha1.LVMCluster) error +} +``` \ No newline at end of file