-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add description field to the migration plan and add support for execution from specified step #235
base: main
Are you sure you want to change the base?
Changes from all commits
4c429b5
aee87f7
32ec719
4a021e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,11 @@ const ( | |
// PlanExecutor drives the execution of a plan's steps and | ||
// uses the configured `executors` to execute those steps. | ||
type PlanExecutor struct { | ||
executors []Executor | ||
plan Plan | ||
callback ExecutorCallback | ||
executors []Executor | ||
plan Plan | ||
callback ExecutorCallback | ||
LastSuccessfulStep int | ||
StartIndex int | ||
} | ||
|
||
// Action represents an action to be taken by the PlanExecutor. | ||
|
@@ -69,6 +71,14 @@ func WithExecutorCallback(cb ExecutorCallback) PlanExecutorOption { | |
} | ||
} | ||
|
||
// WithStartIndex configures a StartIndex for a PlanExecutor | ||
// to modify the starting index of the execution | ||
func WithStartIndex(startIndex int) PlanExecutorOption { | ||
sergenyalcin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return func(pe *PlanExecutor) { | ||
pe.StartIndex = startIndex | ||
} | ||
} | ||
|
||
// ExecutorCallback is the interface for the callback implementations | ||
// to be notified while executing each Step of a migration Plan. | ||
type ExecutorCallback interface { | ||
|
@@ -103,14 +113,15 @@ func NewPlanExecutor(plan Plan, executors []Executor, opts ...PlanExecutorOption | |
|
||
func (pe *PlanExecutor) Execute() error { //nolint:gocyclo // easier to follow this way | ||
ctx := make(map[string]any) | ||
for i := 0; i < len(pe.plan.Spec.Steps); i++ { | ||
for i := pe.StartIndex; i < len(pe.plan.Spec.Steps); i++ { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have access to a logger in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have access to a logger. One option can be adding a log to callback implementation. |
||
var r CallbackResult | ||
if pe.callback != nil { | ||
r = pe.callback.StepToExecute(pe.plan.Spec.Steps[i], i) | ||
switch r.Action { | ||
case ActionCancel: | ||
return nil | ||
case ActionSkip: | ||
pe.LastSuccessfulStep = i | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left that up to the reviews to talk about. In family-migrator, we return the skip action for the steps that the user has run manually. We should consider successful steps that are run manually and that the user validates it. However, the skip action is a much more general action. Therefore, we can specify another type of action for such situations. (For manually performed steps) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or the another option can be that changing the name of the This field is used for caching mechanism for plan. Please see this PR I think, other approach can be moving this logic (storing the last performed step) to the migrator side. |
||
continue | ||
case ActionContinue, ActionRepeat: | ||
} | ||
|
@@ -124,6 +135,7 @@ func (pe *PlanExecutor) Execute() error { //nolint:gocyclo // easier to follow t | |
} | ||
} else if pe.callback != nil { | ||
r = pe.callback.StepSucceeded(pe.plan.Spec.Steps[i], i, diag) | ||
pe.LastSuccessfulStep = i | ||
} | ||
|
||
switch r.Action { | ||
|
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.
Where do we read
LastSuccessfulStep
?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.
We read this value in the family-migrator. Please see this PR.