-
Notifications
You must be signed in to change notification settings - Fork 12
Add the concept of reconcile Procedures #53
Conversation
Signed-off-by: John Strunk <jstrunk@redhat.com>
A reconcile Procedure is a collection of Actions that can fully reconcile the system state. There should be one Procedure for each reconcile (operator) version. Signed-off-by: John Strunk <jstrunk@redhat.com>
Signed-off-by: John Strunk <jstrunk@redhat.com>
|
Do we want to redo actions when they're listed as in both Procedure.actions and Procedure.actions[i].prereqs[j] or are we okay parsing the Procedure to generate a list of actions to be executed in the correct order? I can see this is a safety/perf tradeoff, and that it's good to at the very minimum ensure that the prereqs are expressed, but does it really help to actually run them each time?
|
The cached state of a Procedure's Actions' prereqs needs to be cleared in addition to just the state of the Actions themselves. Signed-off-by: John Strunk <jstrunk@redhat.com>
I think I clarified over chat, but just to log the answer here (and to make sure I did actually understand/answer the question)... Each Action has a cache:
action.Clear()), the Action.action func will not be re-run.The Procedure's Execute() starts by clearing that cache for all actions and their prereqs before evaluating the component Actions. This has the effect of permitting all Actions (including prereq actions) to execute at most once per invocation of Procedure.Execute() (aka, a controller reconcile cycle).
The benefits of the above are:
|
|
I see now :) LGTM! |
| // Get current reconcile version from CR | ||
|
|
||
| // If no current version, use highest version to reconcile | ||
| // otherwise, choose the highest compatible version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside "glustercluster" we could have "controller.go" instead of "glustercluster_controller.go"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sdk-chosen... not ideal, but 🤷♂️
pkg/reconcileaction/procedures.go
Outdated
| @@ -0,0 +1,134 @@ | |||
| package reconcileaction | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somehow I dont like reconcileaction as the package name. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rename to reconciler. That would give reconciler.Action and reconciler.Procedure which seem pretty good. The caveat is that controller-runtime has a reconcile package that gets imported already, so we'll have reconcile.foo and reconciler.foo running around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reconsiler looks good to me. Our reconsiler can be imported by a different name , an ex: greconsiler
| // Procedure defines the complete "procedure" (the set of Action) necessary to | ||
| // completely reconcile the state. | ||
| type Procedure struct { | ||
| minVersion int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of minVersion , why dont we define a dict of "compatible versions" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "version" here is meant to be just numeric procedure versions, numbered independently of the operator release version (i.e., an operator release may not require a new version at all, or it may introduce multiple depending on upgrade requirements). As such, I really expect the simple >= compatibility test to be sufficient for this. Since it's encapsulated from the rest of the code, we could switch it later w/ little difficulty should it become necessary. Sound reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnStrunk hmmm.. compatible version array or dict would sustain better compared to >= , but >= could be a start or first version. so, lets keep it as this for now.
|
@JohnStrunk few comments from my side. |
Signed-off-by: John Strunk <jstrunk@redhat.com>
|
@JohnStrunk I want to clarify some things:
|
|
LGTM .. Merging .. |
Describe what this PR does
In #51 reconcile Actions were introduced. This PR brings in the concept of a Procedure as a collection of Actions. A single Procedure should fully define the steps necessary to reconcile the operator state.
Multiple Procedures may exist within the operator to handle upgrades. Each Procedure has a minVersion from which it can upgrade.
Is there anything that requires special attention?
There is currently just pseudo-code to plug this into the actual sdk reconcile function.
Related issues:
Follow-on to #51