Skip to content

Return exit code #54

Closed
Closed

Description

@royjs

I am deploying with Helm from CI and it would be really helpful to have the commands return a different exit code based on whether there is some changes or not. From CI I usually don't care about the actual changes but I want to know if something changed or not.

My suggestion would be to have a --detailed-exit-code flag similar to terraform plan or git diff

The best would probably to do like terraform and return something like this:

  • 0 if no error and no diff
  • 1 if there is an error
  • 2 if no error but a diff

This change would also allow to implement the same flag in helmfile. See roboll/helmfile#133

Any thoughts?

Activity

  1. travisgroth commented on Jun 2, 2018

    @travisgroth
    Contributor

    I'd like to see this as well so that a helm deployment is only triggered if there is an actual difference. The lack of information as to whether a deployment is needed has been our biggest issue with helm and integrating it into more 'driverless' automation.

    The exit code is actually easy to implement in helm-diff based on my testing, but helm itself will treat any non-zero exit code as an error. So, this should probably be coupled with a change in helm to define an exit code contract to signal failure versus a code that should be passed back to the caller.

  2. royjs commented on Jun 4, 2018

    @royjs
    Author

    @travisgroth thanks for looking into this, I didn't have time to do it yet.
    It looks like it is a little more complicated than what I thought.
    Were you planning on opening an issue in the helm project ? I can also do it if you prefer

  3. travisgroth commented on Jun 4, 2018

    @travisgroth
    Contributor

    @royjs it probably makes sense for you to initiate the issues across the 3 projects, but I'll chime in on the discussion. Assuming there is an agreement on the path forward and the interface, I may be able to do a PR for one or more of these since I've already wandered through the code path.

  4. mumoshu commented on Jul 20, 2018

    @mumoshu
    Collaborator

    @travisgroth @royjs @cmeury Would you be able to participate in the helm part of this issue at helm/helm#4170? As a workaround, I was trying to bypass helm's plugin system, hence call helm-diff directly. But turned out it isn't very feasible as explained in the issue. I'm now eager to implement this in helm. Appreciate your support there 😃

  5. mumoshu commented on Jul 25, 2018

    @mumoshu
    Collaborator

    helm/helm#4367 was merged to the upstream to resolve helm/helm#4170.

    It should be good to start returning the separate exit code for no error but diff now.

  6. added 3 commits that reference this issue on Jul 25, 2018
    78fbf73
    516360d
    49155f3
  7. added a commit that references this issue on Jul 25, 2018
    05029fe
  8. mumoshu commented on Jul 25, 2018

    @mumoshu
    Collaborator

    #78 in combination with helm built from the current master seems to work:

    $ helm211dev diff upgrade myrelease stable/mysql --detailed-exitcode
    ...
    $ echo $?
    2
    

    @royjs @travisgroth @cmeury Could you verify that it works for you?

    For your reference, helm can be build from master by running make build && cp bin/helm path/to/your/bin/helm211dev.

  9. mumoshu commented on Jul 25, 2018

    @mumoshu
    Collaborator

    I'm not going to close this until helm 2.11 is released. It may take a few months, because helm is still 2.10.rc-1 today.

  10. royjs commented on Jul 25, 2018

    @royjs
    Author

    @mumoshu I just tried it and the exit code works fine. The only issue I had is that the helm-diff usage is printed after the diff where a change is detected. Did you see the same behaviour?

  11. mumoshu commented on Aug 21, 2018

    @mumoshu
    Collaborator

    @royjs Hey. Thanks for the report! Yes, and it should be fixed by #79.

  12. mumoshu commented on Aug 21, 2018

    @mumoshu
    Collaborator

    FYI, helm 2.10 has already been released with the feature.

  13. mumoshu commented on Aug 21, 2018

    @mumoshu
    Collaborator

    I'm going to closing this after #81, bumping helm dependency to 2.10

  14. mumoshu commented on Aug 27, 2018

    @mumoshu
    Collaborator

    Released v2.9.0+3 and v2.10.0+1 that includes this feature. Closing as resolved, but please feel free to try and report any issue! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions