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

Design doc #2

Merged
merged 3 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.:
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 be a separate pod, not part of the operator deployment.

Copy link
Contributor Author

@rohantmp rohantmp Dec 3, 2021

Choose a reason for hiding this comment

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

This is referring to the mian reconcile loop in the operator deployment. This is not referring to the CSI driver component topolvmcluster-controller.

- 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
}
```