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

feat: Allow for setting default configurations for workflows, Fixes #1923, #2044 #2331

Merged
merged 26 commits into from
Mar 6, 2020

Conversation

NikeNano
Copy link
Contributor

This is a work in progress but would be happy for some initial feedback.

This is a bug fix for issue which is also discussed here. This PR aims to allow for having default values set for workflows. Which would allow for easier configurations of Arog workflows and also help for admin of jobs.

This is implemented after suggestions from @zhujl1991

@codecov
Copy link

codecov bot commented Feb 28, 2020

Codecov Report

Merging #2331 into master will increase coverage by 0.01%.
The diff coverage is 31.81%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2331      +/-   ##
=========================================
+ Coverage   13.38%   13.4%   +0.01%     
=========================================
  Files          70      70              
  Lines       24232   24254      +22     
=========================================
+ Hits         3244    3251       +7     
- Misses      20579   20590      +11     
- Partials      409     413       +4
Impacted Files Coverage Δ
workflow/config/config.go 33.33% <ø> (ø) ⬆️
workflow/controller/controller.go 2.5% <31.81%> (+1.9%) ⬆️

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 efb8a1a...c5f5f2d. Read the comment docs.

@alexec alexec changed the title Allow for setting default configurations for workflows, Fixes #1923, #2044[NOT DONE] feat: Allow for setting default configurations for workflows, Fixes #1923, #2044[NOT DONE] Feb 28, 2020

// Workflow defaults
//[TODO] fix the representation
WorkflowDefaults *wfv1.WorkflowSpec `json:"workflowDefaults,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should call this defautWorkflowSpec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it be capital "d" to keep it consistent? DefautWorkflowSpec

@NikeNano
Copy link
Contributor Author

Will uppdate based upon your comments!

workflow/controller/controller.go Outdated Show resolved Hide resolved
workflow/controller/controller_test.go Outdated Show resolved Hide resolved
workflow/controller/controller_test.go Outdated Show resolved Hide resolved
@NikeNano
Copy link
Contributor Author

NikeNano commented Mar 4, 2020

Working on adding more test and fixing the current issues. Hope to have it done during the weekend.

@alexec
Copy link
Contributor

alexec commented Mar 4, 2020

Looks good. Did you want to add some docs for this? Maybe an example?

@markterm
Copy link
Contributor

markterm commented Mar 5, 2020

It could be quite useful for this to support default exit handlers

@NikeNano
Copy link
Contributor Author

NikeNano commented Mar 5, 2020

It could be quite useful for this to support default exit handlers

Where can I find more info/examples on this @mark9white ?

@markterm
Copy link
Contributor

markterm commented Mar 5, 2020

We have a generic handler like this that applies to all our workflows:

spec:
    onExit: exit-handler
  templates:
    ...
    - name: exit-handler
      steps:
        - - name: notify
            templateRef:
              name: slack-template
              template: send-slack-message
            arguments:
              parameters:
                - name: message
                  value: "Workflow {{workflow.name}} {{workflow.status}}"
                - name: channel
                  value: "dev-support-alerts"
            when: "{{workflow.status}} != Succeeded"

Though thinking about it an alternative solution would be to have a way to provide a templateRef to onExit and just onExit would need to be provided in the default workflow configuration.

@NikeNano
Copy link
Contributor Author

NikeNano commented Mar 5, 2020

@alexec I would be happy do to an example but I suggest to make that a separate PR. I am kind of happy with the test now. Would you like me to add some more test cases? Added some short documentation as well.

workflow/config/config.go Outdated Show resolved Hide resolved
workflow/controller/controller.go Outdated Show resolved Hide resolved
workflow/controller/controller_test.go Show resolved Hide resolved
@zhujl1991
Copy link
Contributor

LGTM

@NikeNano NikeNano changed the title feat: Allow for setting default configurations for workflows, Fixes #1923, #2044[NOT DONE] feat: Allow for setting default configurations for workflows, Fixes #1923, #2044 Mar 6, 2020
@NikeNano
Copy link
Contributor Author

NikeNano commented Mar 6, 2020

support default exit handlers

@mark9white I dont really understand if this is suited here or not(because my lack of knowledge). Do you have an opinion about it @alexec ?

@alexec alexec merged commit 3890a12 into argoproj:master Mar 6, 2020
@alexec alexec added this to the v2.7 milestone Mar 6, 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.

Very minor comments! Two minutes too late... @NikeNano Could you open a separate PR and address these?

@@ -64,6 +64,8 @@ type WorkflowControllerConfig struct {

// Config customized Docker Sock path
DockerSockPath string `json:"dockerSockPath,omitempty"`

DefautWorkflowSpec *wfv1.WorkflowSpec `json:"workflowDefaults,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Please add a docstring above this, like the rest of the configs

// workflowController. Values in the workflow will be given the upper hand over the defaults.
// The defaults for the workflow controller is set in the WorkflowController.Config.DefautWorkflowSpec
func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv1.Workflow) error {
//var workflowSpec *wfv1.WorkflowSpec = &wf.Spec
Copy link
Member

Choose a reason for hiding this comment

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

Remove this unused line?

if err != nil {
return err
}
// https://github.com/kubernetes/apimachinery/blob/2373d029717c4d169463414a6127cd1d0d12680e/pkg/util/strategicpatch/patch.go#L94
Copy link
Member

Choose a reason for hiding this comment

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

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.

6 participants