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

fix: Updated the TTLcontroller to fix issue related to TTL default settings. Fixes #1923 #2044

Closed
wants to merge 0 commits into from

Conversation

NikeNano
Copy link
Contributor

@NikeNano NikeNano commented Jan 23, 2020

With this PR I intend to fix PR #1923

After having a discussion with @simster7 (who also pointed out that further internal discussions are needed) I have updated the TTLcontroller to also handle default settings which can be supplied to the controller config map.

Please see the discussion here for background.

This is an initial approach, I think that it might be suitable to merge or combine:
https://github.com/argoproj/argo/blob/faa9dbb59753a068c64a1aa5923e3e359c0866d8/workflow/ttlcontroller/ttlcontroller.go#L200

and

https://github.com/argoproj/argo/blob/faa9dbb59753a068c64a1aa5923e3e359c0866d8/workflow/ttlcontroller/ttlcontroller.go#L218

Since it is a lot of duplicated code. Especially with the updates in this PR.

Last but not least I love feedback and @simster7 pointer out that a completely different solutions might be the best, however I leave this here as a start to the discussion.

Checklist:

  • [CHECK ] Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • [ CHECK] The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • [CHECK ] I have written unit and/or e2e tests for my change. PRs without these are unlike to be merged.
  • Optional. I've added My organization is added to the README.
  • [ CHECK] I've signed the CLA and required builds are green.

Fixes #1923

@NikeNano
Copy link
Contributor Author

I will fix the broken tests.

@alexec alexec changed the title Updated the TTLcontroller to fix issue related to TTL default settings #1923 feat: Updated the TTLcontroller to fix issue related to TTL default settings #1923 Jan 24, 2020
@alexec alexec changed the title feat: Updated the TTLcontroller to fix issue related to TTL default settings #1923 fix: Updated the TTLcontroller to fix issue related to TTL default settings. Fixes #1923 Jan 24, 2020
@codecov
Copy link

codecov bot commented Jan 24, 2020

Codecov Report

Merging #2044 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2044   +/-   ##
=======================================
  Coverage   13.13%   13.13%           
=======================================
  Files          72       72           
  Lines       25084    25084           
=======================================
  Hits         3294     3294           
  Misses      21375    21375           
  Partials      415      415

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77e11fc...77e11fc. Read the comment docs.

@NikeNano
Copy link
Contributor Author

@alexec thanks for the help!

workflow/config/config.go Outdated Show resolved Hide resolved
@alexec alexec self-assigned this Jan 30, 2020
@alexec alexec added this to In progress in Argo Workflows OSS Kanban Board via automation Jan 30, 2020
@alexec alexec moved this from In progress to Waiting for review or in review in Argo Workflows OSS Kanban Board Jan 30, 2020
@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 3, 2020

@alexec what is codecov? Do you have any feedback on the way it is implemented? Is there something that you think could be improved, change or improved?

@alexec
Copy link
Contributor

alexec commented Feb 3, 2020

codeCov indicates how much unit test coverage your code has. This is only applicable to change which can have unit tests.

@alexec alexec added this to the v2.6 milestone Feb 3, 2020
Copy link
Contributor

@alexec alexec 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 approving this, but I'd like to hold it to v2.5 so we won't merge just yet.

workflow/ttlcontroller/ttlcontroller_test.go Outdated Show resolved Hide resolved

func TestTTLDefault(t *testing.T) {
controller := newTTLControllerDefaultTTL()
var ten int32 = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

:)

Argo Workflows OSS Kanban Board automation moved this from Waiting for review or in review to Reviewer approved Feb 3, 2020
Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

I think we should have a discussion on what the best way to provide for custom values are. Many users have requested this feature for different specs, so this pattern of adding a field on the config map could end up not scaling well. It would be easy to see a different default* field for every aspect of the workflow spec, and in my opinion that would create clutter.

Perhaps we should add override fields under a struct called workflowOverrides or the like?

In practice this would look something like:

...
workflowOverrides:
  ttlStrategy: ...
...

Argo Workflows OSS Kanban Board automation moved this from Reviewer approved to Waiting for review or in review Feb 3, 2020
@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 4, 2020

I'm approving this, but I'd like to hold it to v2.5 so we won't merge just yet.

@NikeNano NikeNano closed this Feb 4, 2020
Argo Workflows OSS Kanban Board automation moved this from Waiting for review or in review to Done Feb 4, 2020
@NikeNano NikeNano reopened this Feb 4, 2020
Argo Workflows OSS Kanban Board automation moved this from Done to In progress Feb 4, 2020
@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 4, 2020

Perhaps we should add override fields under a struct called workflowOverrides or the like?

In practice this would look something like:

...
workflowOverrides:
  ttlStrategy: ...
...

I think it sounds good to do a solution that is applicable for a wider scope than the TTLcontroller :) .

I don't think it would be good to overwrite the workflow with the default values based upon when argo finds a new resource since it will then not be possible to backtrack what the original input workflow was then. Or do you mean to keep both the original input workflow and an updated copy with the values populated/overwritten based upon the defaults?

I think we should have a discussion on what the best way to provide for custom values ar

Cool, I would be happy to join if possible :). I would also be happy to contribute and work on the wider implementation of default values.

@alexec alexec removed this from the v2.6 milestone Feb 6, 2020
@alexec alexec removed this from In progress in Argo Workflows OSS Kanban Board Feb 6, 2020
@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 7, 2020

I can start to look at a solution for handling default values in general for argo workflows, should I create a new issue for that @alexec where we could have the discussion about it?

@zhujl1991
Copy link
Contributor

I think we should have a discussion on what the best way to provide for custom values are. Many users have requested this feature for different specs, so this pattern of adding a field on the config map could end up not scaling well. It would be easy to see a different default* field for every aspect of the workflow spec, and in my opinion that would create clutter.

Perhaps we should add override fields under a struct called workflowOverrides or the like?

In practice this would look something like:

...
workflowOverrides:
  ttlStrategy: ...
...

How about adding a field in https://github.com/argoproj/argo/blob/3293c83f6170ad4dc022067bb37f12d07d2834c1/workflow/config/config.go#L11 of type https://github.com/argoproj/argo/blob/3293c83f6170ad4dc022067bb37f12d07d2834c1/pkg/apis/workflow/v1alpha1/workflow_types.go#L140 ? Then instead of adding a bunch of default fields in WorkflowControllerConfig, we can decide which fields are used as default in code.

Also, as I mentioned here and here, compared with the method of adding default logic in separate places, the code will be cleaner to handle all these default logics in a function called something like func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv1.Workflow) right after we get the structured workflow https://github.com/argoproj/argo/blob/affc235cd07bb01ee0ef8bb226b7a4c6470dc1e7/workflow/controller/controller.go#L349

@simster7
Copy link
Member

simster7 commented Feb 13, 2020

@NikeNano @zhujl1991 I will bring this issue and all your suggestions up at an internal meeting soon to find the right direction for this

@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 13, 2020

https://github.com/argoproj/argo/blob/3293c83f6170ad4dc022067bb37f12d07d2834c1/workflow/config/config.go#L11

of type
https://github.com/argoproj/argo/blob/3293c83f6170ad4dc022067bb37f12d07d2834c1/pkg/apis/workflow/v1alpha1/workflow_types.go#L140

? Then instead of adding a bunch of default fields in WorkflowControllerConfig, we can decide which fields are used as default in code.

This sounds good!

Also, as I mentioned here and here, compared with the method of adding default logic in separate places, the code will be cleaner to handle all these default logics in a function called something like func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv1.Workflow) right after we get the structured workflow

https://github.com/argoproj/argo/blob/affc235cd07bb01ee0ef8bb226b7a4c6470dc1e7/workflow/controller/controller.go#L349

I also see scenarios where user specified values should be over written by defaults. As a admin I for example don't want to have workflows living for ever, but set a maximum time to live and if users have specs exceed this cap it to the maximum.

@NikeNano
Copy link
Contributor Author

Would be happy to work on this together @zhujl1991 if you are interested :)

@NikeNano
Copy link
Contributor Author

Any updates on this @simster7?

@alexec
Copy link
Contributor

alexec commented Feb 24, 2020

@jessesuen @sarabala1979 @simster7 @dtaniwaki every time I see something like this I think we should have a config item that is a workflow spec and we should use that as the base and mail-merge each template with it when they are created.

That would allow cluster wide or namespace wide features to be added to every workflow, such as exit handlers, TTL, PDBs, etc etc - thoughts?

Alex

@simster7
Copy link
Member

simster7 commented Feb 24, 2020

we should have a config item that is a workflow spec and we should use that as the base and mail-merge each template with it when they are created

Sure. I think what's at issue here is how this should be implemented. Are we thinking of some sort of JSON or strategic patch logic? Or simply add fields present in the config map to workflows when they are created, and override the config items with workflow items if they are present?

@alexec
Copy link
Contributor

alexec commented Feb 24, 2020

Sure. I think what's at issue here is how this should be implemented. Are we thinking of some sort of JSON or strategic patch logic? Or simply add fields present in the config map to workflows when they are created, and override the config items with workflow items if they are present?

The solution I'm proposing would fix this issue, but also a class of issue where you want to have defaults in your workflow. Instead of having to code each one, we could simply have a " blueprint workflow spec" (yes - I know this is a bad name for it) that all created workflow are based on. Example:

apiVersion: v1
kind: ConfigMap
metadata:
  name: workflow-controller-configmap
data:
  workflowBlueprint: |
    spec:
      ttlStrategy:
        secondsAfterSuccess: 30

Submitted workflow:

metadata:
  generateName: hello-world-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay:latest
argo submit hello-world.yaml

Created workflow:

metadata:
  generateName: hello-world-
spec:
  ttlStrategy:
    secondsAfterSuccess: 30
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay:latest

@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 24, 2020

workflowBlueprint

Sounds good!

argo submit hello-world.yaml

But you still mean that the handling of the default should be in the controller and not the CLI right?

How would senarios with contradicting values be handled? Or Scenario where the uses suggest

metadata:
  generateName: hello-world-
spec:
  ttlStrategy:
    secondsAfterSuccess: 30
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay:latest

and and the "Blueprint" is :

apiVersion: v1
kind: ConfigMap
metadata:
  name: workflow-controller-configmap
data:
  workflowBlueprint: |
    spec:
      ttlStrategy:
        secondsAfterSuccess: 25

Which should be selected?

@alexec
Copy link
Contributor

alexec commented Feb 24, 2020

Which should be selected?

I think workflow must take precedence over the blueprint. I.e. the blue print provides defaults.

@NikeNano
Copy link
Contributor Author

NikeNano commented Feb 24, 2020

Which should be selected?

I think workflow must take precedence over the blueprint. I.e. the blue print provides defaults.

I think it would be good to be able to override. We use kubeflow and as a admin it would be great to be able to set default that over rides the user for example to limit the TTL time for workflows to avoid having to clean up.

@zhujl1991
Copy link
Contributor

Sure. I think what's at issue here is how this should be implemented. Are we thinking of some sort of JSON or strategic patch logic? Or simply add fields present in the config map to workflows when they are created, and override the config items with workflow items if they are present?

The solution I'm proposing would fix this issue, but also a class of issue where you want to have defaults in your workflow. Instead of having to code each one, we could simply have a " blueprint workflow spec" (yes - I know this is a bad name for it) that all created workflow are based on. Example:

apiVersion: v1
kind: ConfigMap
metadata:
  name: workflow-controller-configmap
data:
  workflowBlueprint: |
    spec:
      ttlStrategy:
        secondsAfterSuccess: 30

Submitted workflow:

metadata:
  generateName: hello-world-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay:latest
argo submit hello-world.yaml

Created workflow:

metadata:
  generateName: hello-world-
spec:
  ttlStrategy:
    secondsAfterSuccess: 30
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay:latest

@alexec If I understand you correctly, your proposal is the same as the approach I proposed here, right? This feature is hi-pri for us. If everyone can agree on this approach, I can implement it.

@jessesuen @sarabala1979 @simster7 @dtaniwaki

@alexec
Copy link
Contributor

alexec commented Feb 26, 2020

@alexec If I understand you correctly, your proposal is the same as the approach I proposed here, right?

Yes. That is what I think. I'd like to get feedback from @jessesuen @sarabala1979 @simster7 @dtaniwaki,

E.g. how could misuse bite people in the bum?

@simster7
Copy link
Member

That would be my ideal solution as well. Feel free to start work on this @zhujl1991 @NikeNano

@NikeNano
Copy link
Contributor Author

@simster7 I will start to work on this and then update this/or make a new PR related to setting max min ttl times.

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.

Provide a way to set default Workflow options that will apply to all workflows
5 participants