Mender-cli force upload option?

Good day,

as part of our CI workflow we would like to not only manage our production releases with mender,
but also our main and stable builds.
To that end, i am building a pipeline utilizing mender-cli to transfer built mender artifacts to our mender instance.

This requires overwriting artifacts with that same name, since we do not want to progressively clutter out our mender instance with every main build. Simply uploading another artifact of the same name fails with a 409 http error, which is expected since the same occurs in the web ui. (Though the error message there is somewhat baffling, as it states “[…]An artifact with the same name has conflicting depends[…]”, even though the artifact has no depends)

I was expecting to find a “force” flag or similar on the “mender-cli artifacts upload” command,
or at least an option to delete artifacts by name rather than just id. However, as it stands, its seems i would need to build a custom solution to query all images using “mender-cli artifacts list”, parse the output for the id’s, delete those, and finally upload the new artifacts.

Is there any way to achieve this without building what imo should probably be a feature of mender-cli in the first place? Or, is there any chance of getting this feature into mender-cli in the near future?

Hi @adrian,

Unfortunately there is no means to replace an artifact at the moment. What might be a workaround for you is to first delete the old artifact of the given name by calling to the API and then uploading the new one.
The API Docs give you an idea how to do it.

Greetz,
Josef

Hi @TheYoctoJester ,

thanks for your suggestion. The API endpoint you suggested hat actually escaped my notice, but it only allows deleting by id, which the the mender-cli tool already supports itself. However, in order to delete and then upload, i need either a way to delete by name, or determine the id programmatically.

Neither operation seems to be supported by the API or cli tool. I could build a custom parser for the human-readable output of “mender-cli artifacts list”, but i would like to avoid such a fragile and temporary solution.

The issue is that i can only ever know the name of the artifact (since i set it as part of the pipeline run), but the id is generated by mender upon upload.

If there truly is now way to determine the id, or handle artifacts by name i will have to go with the custom parser solution, but this seems like a rather glaring gap in functionality, for a workflow i imagine to be fairly common.

In any case, thank you for your time, and i will let you know if i figure something out

Greetings
adrian

1 Like

Update:
I completely missed the fact that the /artifacts/list endpoint responds with both the name and id of each artifact, so that is the route i will take for now.

It is absolutely better than trying to parse the “mender-cli artifacts list” output, but i maintain that a more direct way to retrieve a list of id’s for a given artifact name, or even just force an overwrite when uploading, would be very useful functionality.

In any case, thank you again for putting me on the right track, and have a nice day :slight_smile:

Greetings
adrian

1 Like