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

release_charm.yaml: Continue if .charm file already uploaded to Charmhub #22

Open
carlcsaposs-canonical opened this issue Mar 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@carlcsaposs-canonical
Copy link
Contributor

If release_charm.yaml fails after successfully uploading the .charm files to Charmhub, it will fail during the upload .charm file step on subsequent retries, unless a new build is created.

This means that the entire workflow has to be restarted if release_charm.yaml fails after uploading the .charm files but before releasing the charm.

Example:
Workflow fails after .charm files uploaded: https://github.com/canonical/mysql-router-operator/actions/runs/4510876749/attempts/1
Re-try fails to upload .charm files: https://github.com/canonical/mysql-router-operator/actions/runs/4510876749/attempts/2
Entire workflow has to be restarted to pass: https://github.com/canonical/mysql-router-operator/actions/runs/4510876749/attempts/3

Error from logs

ERROR:root:Starting to push 'mysql-router_ubuntu-20.04-amd64.charm'
Uploading... (--->)
Uploading... (<---)
Uploading bytes ended, id f7c2b006-1524-4520-97dd-066d3f55b0ba
Upload f7c2b006-1524-4520-97dd-066d3f55b0ba started, got status url /v1/charm/mysql-router/revisions/review?upload-id=f7c2b006-1524-4520-97dd-066d3f55b0ba
Status checked: {'revisions': [{'errors': None, 'revision': None, 'status': 'new', 'upload-id': 'f7c2b006-1524-4520-97dd-066d3f55b0ba'}]}
Status checked: {'revisions': [{'errors': None, 'revision': 68, 'status': 'new', 'upload-id': 'f7c2b006-1524-4520-97dd-066d3f55b0ba'}]}
Status checked: {'revisions': [{'errors': [{'code': 'review-error', 'message': "Cannot insert package. An upload with that digest (SHA3-384: 'c94c30cfad784dc68f458bc2e802f2e0a520218371eb2fee94cef8ec6a01f9bf60370f928c8bb9723ee6d3ddc07607f8') already exists in the database. Revision of the existing package is: 67"}], 'revision': 68, 'status': 'rejected', 'upload-id': 'f7c2b006-1524-4520-97dd-066d3f55b0ba'}]}

Traceback (most recent call last):
  File "/home/runner/work/mysql-router-operator/mysql-router-operator/caller-repo/../workflow-repo/release_charm.py", line 47, in <module>
    output = run(["charmcraft", "upload", "--format", "json", charm_file])
  File "/home/runner/work/mysql-router-operator/mysql-router-operator/caller-repo/../workflow-repo/release_charm.py", line 29, in run
    process.check_returncode()
  File "/usr/lib/python3.10/subprocess.py", line 456, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['charmcraft', 'upload', '--format', 'json', PosixPath('mysql-router_ubuntu-20.04-amd64.charm')]' returned non-zero exit status 1.

Solution

Parse the error; if it has already been uploaded to charmhub, catch the error

@carlcsaposs-canonical carlcsaposs-canonical added the enhancement New feature or request label Mar 24, 2023
@carlcsaposs-canonical
Copy link
Contributor Author

@carlcsaposs-canonical
Copy link
Contributor Author

Workaround: restart the Build charm job that the Release job depends on

(Note: in most data platform repos, there are two Build charm jobs—one in the Tests that's cached and one for the release that's not cached—re-trigger the top-level Build charm job that's not cached)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant