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(cli): Add cost optimization nudges for Argo CLI #5168

Merged
merged 7 commits into from
Feb 25, 2021

Conversation

dinever
Copy link
Member

@dinever dinever commented Feb 23, 2021

Hi guys, this one closes #4548

Demo:

Screen Shot 2021-02-23 at 12 47 45 AM

This is my first contribution to Argo. Would❤️ to hear some feedback. Thanks!

Checklist:

@dinever dinever force-pushed the cost-optitmiztion-cli branch 3 times, most recently from 5e20696 to 50bb8af Compare February 23, 2021 06:47
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.

Great! Thanks for submitting this. This looks great so far. Two things:

  • Users should be able to turn off nudges. I now see that our CLI does not store any state anywhere. Not sure that we would want to add a CLI config/data store (e.g. in ~/.argo/config) just for this, but that is a possibility. Do you have any other ideas for this?
  • We have another nudge in our UI:
    if (!execSpec(workflow).securityContext) {
    return <SecurityNudge>This workflow does not have security context set. It maybe possible to set this to run it more securely.</SecurityNudge>;
    }

    Could we add that as well?

completed, incomplete := countCompletedWorkflows(wfList)
if completed > 100 || incomplete > 100 {
_, _ = fmt.Fprint(w, "\n")
fmt.Fprintf(w, "You have at least ")
Copy link
Member

Choose a reason for hiding this comment

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

Should this also disregard returned values for consistency?

Suggested change
fmt.Fprintf(w, "You have at least ")
_, _ = fmt.Fprintf(w, "You have at least ")

@simster7 simster7 self-assigned this Feb 23, 2021
@dinever
Copy link
Member Author

dinever commented Feb 23, 2021

Thanks for the review @simster7!

Not sure that we would want to add a CLI config/data store (e.g. in ~/.argo/config) just for this, but that is a possibility.

I'm happy to implement this. However, a config data store feels like an overkill for this nudges use case unless we have other use cases that can benefit from it as well.

Another option is that we can add a --disable-nudges option for the CLI so that users can choose to disable it.

Let me know what you think. Thanks!

Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
@dinever
Copy link
Member Author

dinever commented Feb 24, 2021

Hi @simster7,

Thanks for the review! I made some changes based on your feedback.

  1. af3f1f6: Added a --no-nudges option for the CLI impacted. User can choose to not print the nudges
  2. ffe487f: Added a security nudge for argo get
    Screen Shot 2021-02-24 at 1 14 19 AM
  3. c610490: Discard return values for fmt.Print and fmt.Printf for consistency

Let me know your thoughts. Thanks!

Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
@alexec
Copy link
Contributor

alexec commented Feb 24, 2021

My thoughts on this:

  1. Great stuff!
  2. I'm not sure it is worth it to make it possible to disable nudges in the CLI. Instead, let's see if people ask for that feature.
  3. Should we do security nudges too?
  4. Nudges need to use "exec spec". I think there is Workflow.ExecSpec() for that.

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.

This LGTM, I'd like @alexec to also take a look since he wrote the initial nudges

@simster7
Copy link
Member

simster7 commented Feb 24, 2021

Should we do security nudges too?

I think security nudges are already implemented.

Nudges need to use "exec spec". I think there is Workflow.ExecSpec() for that.

Exec spec is only generated and kept in the controller... this is all CLI code

_, _ = fmt.Fprintf(w, "%d completed ", completed)
}
_, _ = fmt.Fprint(w, "workflows. Reducing the total number of workflows will reduce your costs.\n")
_, _ = fmt.Fprint(w, "Learn more at https://argoproj.github.io/argo-workflows/cost-optimisation/\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move the security nudge code here please?

if completed > 100 {
_, _ = fmt.Fprintf(w, "%d completed ", completed)
}
_, _ = fmt.Fprint(w, "workflows. Reducing the total number of workflows will reduce your costs.\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

minor - could you use Fprintln?

… pkg

Signed-off-by: Peixuan Ding <dingpeixuan911@gmail.com>
@alexec alexec merged commit 4881111 into argoproj:master Feb 25, 2021
This was referenced Mar 1, 2021
@dinever dinever deleted the cost-optitmiztion-cli branch April 15, 2021 19:20
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.

Add cost optimization nudges on the CLI
3 participants