publish bundle fails with `'.' is not a file`.
Bug Description
Publish bundle for latest/edge bundle fails with the following error
Error: Error running subcommand ``charmcraft upload --release latest/edge``: `'.' is not a file.
Here is the run where this first occured. We hadn't run this since 3 months ago, so it could be that something changed in the action.
This could be an issue with upload-bundle action but more investigation is needed.
To Reproduce
Merge a PR modifying latest/edge bundle.
Environment
GH runner
Relevant Log Output
Run canonical/charming-actions/[email protected]
with:
credentials: ***
github-token: ***
bundle-path: ./releases/latest/edge/
channel: latest/edge
charmcraft-channel: latest/edge
/usr/bin/sudo snap install charmcraft --classic --channel latest/edge
charmcraft (edge) 2.5.5.post85+g75722ac from Canonical** installed
/usr/bin/sudo snap install juju-bundle --classic
juju-bundle 0.4.0 from Kenneth Koski (kennethkoski) installed
/snap/bin/juju-bundle publish --destructive-mode --serial --release latest/edge
Ensuring valid credentials with `charmcraft whoami`.
name: Michal Huckko
username: michalhucko
id: TdvDVO8EijykLIQGmU3P3FWRaEHfEJUW
permissions:
- account-register-package
- account-view-packages
- package-manage
- package-view
Error: Error running subcommand ``charmcraft upload --release latest/edge``: `'.' is not a file.
Full execution log: '/home/runner/.local/state/charmcraft/log/charmcraft-20240219-084250.355679.log'
`
Error: The process '/snap/bin/juju-bundle' failed with exit code 1
Error: Error: The process '/snap/bin/juju-bundle' failed with exit code 1
at ExecState._setResult (/home/runner/work/_actions/canonical/charming-actions/1.0.0/dist/upload-bundle/index.js:2600:25)
at ExecState.CheckComplete (/home/runner/work/_actions/canonical/charming-actions/1.0.0/dist/upload-bundle/index.js:2583:18)
at ChildProcess.<anonymous> (/home/runner/work/_actions/canonical/charming-actions/1.0.0/dist/upload-bundle/index.js:2477:27)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1100:16)
at Socket.<anonymous> (node:internal/child_process:458:11)
at Socket.emit (node:events:513:28)
at Pipe.<anonymous> (node:net:301:12)
No charmcraft logs generated, skipping artifact upload.
Additional Context
No response
Thank you for reporting us your feedback!
The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-5348.
This message was autogenerated
To troubleshoot the issue, I tried to trace the order of execution of the Github action. Here's what I have gathered:
- The issue occurs when triggering the release-bundle-to-charmhub.yaml action.
- That action calls the run-tests-and-publish-bundle.yaml action.
- This in turn calls the upload-bundle action from the
charming-actionsrepo. - That action invokes an index.js file, and specifically the publish function.
- The function calls the
juju-bundleexecutable from the terminal. The executable'smain.rsis here. - The publish subcommand is called, which creates a temporary directory in
/tmpwith aREADME.md, abundle.yaml, and acharmcraft.yaml. In the last line of the function, theupload_charmhubfunction for the Bundle object is called, with the temporary directory and the specified channel as argument. - The
upload_charmhub()function is derived from thejuju-rsinterface for Rust, and specifically this function. - The function calls
charmcraft packfrom the terminal, as seen here, and captures the output. To receive the actual name of the produced.zipfile, it uses this iteration chain. As explained in the comment, it tries to capture the produced file's name by getting everything between the first two single quote characters.
Here lies the issue. Calling charmcraft pack returns a message like the following:
Packaged kubeflow.zip
Because kubeflow.zip is not enclosed with quotes, the first while statement iterates through the whole sequence, and thus an empty string is returned. When the function then tries to call charmcraft upload here, it does with an empty string as a path "". Charmcraft upload reads this as putting "." as an argument and outputs the exact error message described in this issue. You can check this yourself by running charmcraft upload "".
Proposed fix: this chained iteration should be changed to capture the output properly, maybe by getting all output after the first space character " ".
I couldn't find more information on where the command output is specified for charmcraft upload on the charmcraft repo. I assume that in the past the filename would be enclosed in quotes, but a change was made and it isn't reflected in the rust-libjuju interface.