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

KEP-17: Pipe task implementation #1105

Merged
merged 19 commits into from
Dec 5, 2019
Merged

KEP-17: Pipe task implementation #1105

merged 19 commits into from
Dec 5, 2019

Conversation

zen-dog
Copy link
Contributor

@zen-dog zen-dog commented Nov 25, 2019

Summary:
as defined in KEP-0017 we introduce a new Pipe task. Given a task specification like:

tasks:
  - name: genfiles
    kind: Pipe
    spec:
      pod: pipe-pod.yaml
      pipe:
        - file: /tmp/foo.txt
          kind: Secret # or ConfigMap
          key: foo

KUDO will:

  • create a Pod with the provided pipe-pod.yaml
  • wait for the successful execution of the container
  • copy out specified pipe files
  • store them in the API server (in the above example as a Secret)
  • the secret can be referenced in the subsequent resources as {{Pipes.foo}}

For more information about the implementation please consult the KEP-0017.

Fixes: #774

Summary:
as defined in KEP-0017 we introduce a new Pipe task. Given a task specification like:
```
tasks:
  - name: genfiles
    kind: Pipe
    spec:
      container: container.yaml
      pipe:
        - file: /tmp/foo.txt
          kind: Secret # or ConfigMap
          key: foo
```
KUDO will:
- create a Pod with the provided `container.yaml`
- wait for successful execution of the container
- copy out specified pipe files
- store them in the API server (in the above example as a Secret)
- the secret can be referenced in the subsequent resources as `{{Pipes.foo}}`

For more information about the implementation please consult the KEP-0017.

Fixes: #774
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.

I did not do a very deep review so far but I liked what I saw 👍 left couple of minor comments :)

pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Show resolved Hide resolved
pkg/engine/task/task_pipe.go Show resolved Hide resolved
pkg/engine/task/task_pipe.go Outdated Show resolved Hide resolved
}

var (
pipeFileKeyRe = regexp.MustCompile(`^[a-zA-Z0-9_\-]+$`) //a-z, A-Z, 0-9, _ and - are allowed
Copy link
Member

Choose a reason for hiding this comment

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

This is basically a param-name, right? Do we have a specification/pattern for params somewhere else already? Might be good to reuse that, if we have it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can see we're only testing for invalid characters. Am I being too strict here? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm. We should allow all parameter names that K8s allows. Otherwise we might run into a problem where some application expects a parameter name of "option=rw,size=2300". We just had that case in Marathon, where some application abused the parameter name to pass multiple things :-/

In any case, the validation should be the same as is used in the verify that you linked.

@zen-dog zen-dog requested a review from nfnt as a code owner November 27, 2019 16:25
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

This looks great! Found a few nits though, all unrelated to the actual implementation.

pkg/engine/task/task_apply.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
pkg/engine/task/task.go Show resolved Hide resolved
pkg/engine/task/task_pipe.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Show resolved Hide resolved
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 would really like to see more tests around the mapping to a template file...
however this LGTM!

keps/0017-pipe-tasks.md Outdated Show resolved Hide resolved
keps/0017-pipe-tasks.md Outdated Show resolved Hide resolved
keps/0017-pipe-tasks.md Outdated Show resolved Hide resolved
keps/0017-pipe-tasks.md Outdated Show resolved Hide resolved
@@ -107,21 +110,19 @@ spec:
volumes:
- name: cert
secret:
secretName: {{.Pipes.Certificate}}
secretName: {{.Pipes.Mycertificate}}
Copy link
Member

Choose a reason for hiding this comment

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

it looks like pipe keys are generated to guarantee uniques based on phase and step... but then are flatten in the template... is that true?

Copy link
Contributor Author

@zen-dog zen-dog Dec 4, 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 I understand the question but:

  • pipe keys are not generated but chosen by the user e.g. {{.Pipes.Mycertificate}} in line 56 above
  • the actual name of the secret (where the file is stored) is generated by KUDO and is an implementation detail. I mentioned it here for completeness

pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
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.

I guess nothing is really a blocker for me - there's definitely a lot of possible improvements, but we can iterate on that. The only part I am really concerned is the tricky code around streams and goroutines - it's not really tested that much and I personally would be really scared to touch it in any way. I wonder if we can still do better there :)

pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Show resolved Hide resolved
pkg/engine/task/task_pipe.go Outdated Show resolved Hide resolved
@zen-dog zen-dog changed the title KEP-0017: Pipe task implementation KEP-17: Pipe task implementation Dec 4, 2019
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

This looks in a great shape already, my comments are mostly minor and around Goroutine use. Need to do another pass though tomorrow at pkg/engine/task/* because that's a lot of code.

pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

Finally could look at task_pipe.go. It looks great, though I'm concerned with leaking resources in some of the code.

pkg/engine/task/pod_exec.go Outdated Show resolved Hide resolved
pkg/engine/task/task_pipe.go Show resolved Hide resolved
additionally PodExec caller can now differentiate between command execution failures (exit code > 0) and other errors
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

Looks great!

@zen-dog zen-dog merged commit ead3d4c into master Dec 5, 2019
@zen-dog zen-dog deleted the ad/pipe-task branch December 5, 2019 14:08
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.

Tracking Issue: Pipe-Tasks
6 participants