weaveworks / pipeline-controller

This repository contains the Pipeline CRD and associated controller for Weave GitOps Enterprise.
1 stars 4 forks source link

fix: pull_request strategy "nothing to commit" after failed promotion #185

Closed yitsushi closed 1 year ago

yitsushi commented 1 year ago

With Pull Request strategy, we try to:

  1. Create a branch
  2. Patch manifest
  3. Commit changes
  4. Push changes
  5. Create Pull Request

If the 5th step failed (for example invalid credentials, API rate limit), it failed on committing changes as all changes were committed earlier. Same applied to pushing changes, "up-to-date" response counts as an error (I don't think it should, but that's an external library).

We had a check if the working directory is dirty or not, if it was clean we simply returned without an error.

With this patch, if the working directory is dirty we try to commit, and try to push. If push error message is "already up-to-date" we can ignore the error and proceed with pull request creation.

Sadly, I couldn't find a way to check if push error is "up-to-date", so I went with the simple string comparison. It will break if they ever change the message in git, but that's very unlikely.

Fixes #163