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

Introducing a new Task specification #859

Merged
merged 56 commits into from
Oct 19, 2019
Merged

Introducing a new Task specification #859

merged 56 commits into from
Oct 19, 2019

Conversation

gerred
Copy link
Member

@gerred gerred commented Sep 25, 2019

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.

# operator.yaml
  ...
  tasks:
    deploy:
      resources:
        - deploy.yaml
    remove:
      reources:
        - deploy.yaml

  plans:
    deploy:
      strategy: serial
      phases:
        - name: phase
          strategy: serial
          steps:
            - name: step
              tasks:
                - deploy
    remove:
      strategy: serial
      phases:
        - name: phase
          strategy: serial
          steps:
            - name: step
              tasks:
                - remove
              delete: true

The new task definition requires specifying tasks name, kind and spec fields. Here is the same example using new Apply and Delete tasks kinds:

  tasks:
    - Name: deploy
      Kind: Apply
      Spec:
        resources:
          - deploy.yaml
    - Name: uninstall
      Kind: Delete
      Spec:
        resources:
          - deploy.yaml

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

@alenkacz alenkacz changed the base branch from master to av/instance-controller-v2 September 25, 2019 15:10
by embeding all task types into a separate `struct TaskSpec`. Additionally, renamed `CreateTask` into `ApplyTask` since that better reflects how we handle its resources.
Copy link
Member

@kensipe kensipe left a 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
@zen-dog zen-dog changed the title [WIP] Initial spike of Tasker Introducing a new Task specification Oct 14, 2019
Copy link
Member Author

@gerred gerred left a 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 🙃

pkg/engine/task/task_apply.go Show resolved Hide resolved
pkg/engine/task/task_apply.go Show resolved Hide resolved
}

// 2. - Kustomize them with metadata -
kustomized, err := kustomize(rendered, ctx.Meta, ctx.Enhancer)
Copy link
Member Author

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.

Copy link
Contributor

@zen-dog zen-dog Oct 15, 2019

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.

Copy link
Contributor

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 :)

Copy link
Member Author

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.

pkg/engine/task/task_delete.go Show resolved Hide resolved
@zen-dog
Copy link
Contributor

zen-dog commented Oct 15, 2019

I can't approve since it's my own PR

Lol, I can but I'm obviously biased 😆

Copy link
Contributor

@alenkacz alenkacz left a 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) :)

pkg/controller/instance/plan_execution_engine.go Outdated Show resolved Hide resolved
pkg/controller/instance/plan_execution_engine.go Outdated Show resolved Hide resolved
pkg/engine/task/task.go Outdated Show resolved Hide resolved
pkg/engine/task/task.go Outdated Show resolved Hide resolved
pkg/engine/task/task.go Outdated Show resolved Hide resolved
pkg/engine/task/task_apply.go Show resolved Hide resolved
}

// 2. - Kustomize them with metadata -
kustomized, err := kustomize(rendered, ctx.Meta, ctx.Enhancer)
Copy link
Contributor

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 :)

Copy link
Member

@kensipe kensipe left a 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

config/crds/kudo_v1alpha1_operatorversion.yaml Outdated Show resolved Hide resolved
config/crds/kudo_v1alpha1_operatorversion.yaml Outdated Show resolved Hide resolved
config/crds/kudo_v1alpha1_operatorversion.yaml Outdated Show resolved Hide resolved
pkg/engine/task/task.go Outdated Show resolved Hide resolved
pkg/engine/task/task.go Outdated Show resolved Hide resolved
return nil
}

func prettyPrint(key client.ObjectKey) string {
Copy link
Member

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.

Copy link
Contributor

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 :)

Copy link
Contributor

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
@zen-dog zen-dog merged commit 8827667 into master Oct 19, 2019
@zen-dog zen-dog deleted the gerred/tasker branch October 19, 2019 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The strategy on the plan level (for phases) is not honored
4 participants