Mender-artifact hangs

I’m trying to use mender-artifact to modify files inside a mender artifact built with mender-convert without success (see update below).

I downloaded precompiled binary and placed it inside mender-convert/output/

Checking version and obtaining help works fine:

$ ./mender-artifact -v
mender-artifact version 3.0.1

But as soon as I invoke any command on a mender artifact (I tried cat, cp, validate), it just hangs forever, loading one CPU core to 100%.

./mender-artifact cat raspberry_hub_raspbian04.2019_Scanner5.1.0_mender.mender:/etc/hosts

As I said, .mender artifact is the output of the latest mender-convert. I can open it as a tarball, contents seem to be correct.

UPDATE
I downloaded the demo artifact and tried to use mender-artifact with it and it worked, but cat command took couple of seconds. So considering that my artifact is ~10x bigger than the demo one, I waited a bit more and bingo it actually worked. But it took ~3 minutes.

The cp command took twice as long:

~/mender-convert/output $ date +%R && ./mender-artifact cp mender.conf raspberry_hub_raspbian04.2019_Scanner5.1.0m_mender.mender:/etc/mender/mender.conf && date +%R
19:26
19:33

I understand that limitation probably comes from the fact that the artifact should be uncompressed and compressed back every time.
But considering that I have a dozen of files (config, identity, inventory and some state-scripts) to copy into the artifact generated by mender-convert, is there a more efficient workflow to do so?
Maybe mounting .ext4 and use mender-artifact to generate the artifact is a viable idea? If yes, can I somehow ask mender-convert to not generate the .mender file?

In any case, I think a note about performance limitations of mender-artifact should be placed in the docs. Or the program itself should output the info to console that it may take a while.

I think you have figured out the most optimal approach. Unfortunately mender-convert is not very extend currently but this is something that we are looking at to make it easier to make custom modifications during a conversion process, e.g inserting configuration files, application files etc.

If yes, can I somehow ask mender-convert to not generate the .mender file?

No this is currently not optional.

In any case, I think a note about performance limitations of mender-artifact should be placed in the docs. Or the program itself should output the info to console that it may take a while.

Good points, and makes sense to add more information. Probably the tool it self should be aware of time necessary and print something.

I have created a task for it, so it is not forgotten,

https://tracker.mender.io/browse/MEN-2609

Also pull-requests are welcome :smiley:

@ster good points, and indeed these slow operations can be annoying.

As you mention, decompression/compression is one thing, but there are also checksums (verified and generated) to ensure that the artifact is not corrupted before you cat/modify and to ensure integrity can be checked after modification as well.

As one idea, would it help your workflow if cp / install took several files that could be copied in one operation? Or are there many other operations you need to do in the same go (e.g. cat)?

Regardless I think mender-artifact should inform about these slow operations, and also support some kind of progress indicator. We can follow up with more in-depth discussions on that in the ticket @mirzak created (https://tracker.mender.io/browse/MEN-2609).

As one idea, would it help your workflow if cp / install took several files that could be copied in one operation?

Yes It would help a bit, but according to mender-artifact cp --help, it doesn’t seem to support copying multiple files in one run. Please correct me if I’m wrong.

Anyway, as I also need to add Artifact state scripts to already created mender artifacts and mender-artifact doesn’t support this, I ended up with the following workflow as the most time efficient:

  1. run mender-convert and kill it as soon as it starts creating .mender file
  2. mount .sdimg and copy all files inside (mender.config, identity, inventiry, client state-scripts)
  3. mount .ext4 and perform the same copying
  4. create mender artifact from .ext4, adding artifact state scripts using mender-artifact write rootfs-image .... --script <artifactScript>

Hello,
I am interested in this issue as well, and noticed the latest version of mender-artifact is 3.2.1
Where could I find the release information or if this is a planned feature to take a look at?

Regards

Never mind.
https://docs.mender.io/2.2/release-information/release-notes-changelog#mender-221