Skip to content

Commit

Permalink
Merge pull request #2 from rohantmp/designDoc
Browse files Browse the repository at this point in the history
Initial LVM operator design doc
  • Loading branch information
nbalacha authored Dec 6, 2021
2 parents 4f4f7b5 + 6c6c6c9 commit 14f48c6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# lvm-operator
Operator that manages Topolvm

# Contents
- [docs/design](doc/design/)
19 changes: 14 additions & 5 deletions controllers/lvmcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand All @@ -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)
}
}

Expand All @@ -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, "")
}
}
Expand All @@ -115,10 +115,19 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, req ctrl.Request,

}

// NOTE: when updating this, please also update doc/design/README.md
type reconcileUnit interface {
getDescription() string

// 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.
Expand Down
43 changes: 43 additions & 0 deletions doc/design/README.md
Original file line number Diff line number Diff line change
@@ -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
}
```

0 comments on commit 14f48c6

Please sign in to comment.