-
Notifications
You must be signed in to change notification settings - Fork 101
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
Introducing a new Task specification #859
Conversation
by embeding all task types into a separate `struct TaskSpec`. Additionally, renamed `CreateTask` into `ApplyTask` since that better reflects how we handle its resources.
c37d2c7
to
2ccde6d
Compare
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'm wonder if this is mispackaged... what do you think of a package named task
then you would have task.Apply
, task.Kubernetes
, task.Multi
, task.Output
, task.Builder
... you get it. using the package as part of communication is really growing on me...
also... nice start!
# Conflicts: # cmd/manager/main.go # pkg/apis/kudo/v1alpha1/instance_types.go # pkg/controller/instance/instance_controller.go # pkg/controller/instance/plan_execution_engine.go # pkg/controller/instance/plan_execution_engine_test.go # pkg/kudoctl/cmd/plan/plan_history.go # pkg/util/health/ready.go # test/integration/upgrade-command/01-assert.yaml
# Conflicts: # go.mod # go.sum # pkg/controller/instance/plan_execution_engine.go # pkg/controller/instance/plan_execution_engine_test.go
for task.go, task_apply.go and task_delete.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.
super nice! just a few clarifications really, I love how this was made. I can't approve since it's my own PR 🙃
} | ||
|
||
// 2. - Kustomize them with metadata - | ||
kustomized, err := kustomize(rendered, ctx.Meta, ctx.Enhancer) |
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.
why do we need to kustomize them? is it because of the name decoration we do? sounds about right, just worth documenting since it looks a little odd on first look.
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'm not sure we have to. This logic got adopted from master and I didn't question it. I'd also rather tackle this in a separate PR.
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.
yeah I actually think we don't have to. To be honest, I think that the DeleteTask should not even accept resources, specifying the identifier of that resource should be enough but it would probably need some API design... having resources there is easier now :)
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.
@alenkacz how would we know the templating of those names? I know at least for one operator where the name is (or is becoming) a Go template, potentially.
Lol, I can but I'm obviously biased 😆 |
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.
Okay, first pass done 👍 I like how the logic is getting broken into smaller and smaller pieces, we really came a long way from that super ugly controller we had in the beginning, love it. Especially how delete and apply are separated now. It will be a great ground work for future tasks.
I left few comments, some of them are just to start a conversation and does not have to be addressed in this PR (I tried to mark them in an obvious way) :)
} | ||
|
||
// 2. - Kustomize them with metadata - | ||
kustomized, err := kustomize(rendered, ctx.Meta, ctx.Enhancer) |
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.
yeah I actually think we don't have to. To be honest, I think that the DeleteTask should not even accept resources, specifying the identifier of that resource should be enough but it would probably need some API design... having resources there is easier now :)
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.
this general looks good and I'm ok with it landed the way it is... the biggest issue for me is consistency around errors and fatal
return nil | ||
} | ||
|
||
func prettyPrint(key client.ObjectKey) string { |
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'm not a fan of this being here... the naming is off. task.prettyPrint
seems like it would pretty print a task... but this pretty prints a objectkey. It is private and isn't a big deal, but it seems like it would have utility in other areas of code.
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 am actually fine with this tiny code duplication, but no strong feelings here :)
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.
A common purpose prettyPrint
method would need a new file, more error handling etc. I decided to keep it small and narrow-purposed for now.
# Conflicts: # pkg/controller/instance/instance_controller.go # pkg/controller/instance/plan_execution_engine.go # pkg/controller/instance/plan_execution_engine_test.go
We introduce a new
Task
specification, which will allow us to better encapsulate different kinds of tasks (e.g. Helm, Pipe-tasks, etc) in the future. Here is how the API changed:Before: tasks were a list of resources, which were applied in step with an optional
delete: true
signaling, that resources have to be deleted.The new task definition requires specifying tasks
name
,kind
andspec
fields. Here is the same example using newApply
andDelete
tasks kinds:Its usage from the step is almost the same, merely
delete: true
has been removed.Additionally, plan execution logic was reworked, It now respects phases strategy and propagates fatal and transient execution errors differently (see this comment for more information).
Fixes: #839