How to pass userdata using amc launch

I’ve read the docs on passing user data into an instance when creating it, but it doesn’t give an example of what the amc command would look like when passing in data. I’ve tried several things that result in a instance starting that will not let me view the session so I assume it is hanging.

The docs only say:

  • --userdata takes a string and stores the provided data in the /var/lib/anbox/userdata file in the instance.

It doesn’t say what format the string should be in.

First I tried passing values and then a single value straight in like this:

amc launch <app-name> ....... --userdata="field1=testvalue1,field2=testvalue2"
amc launch <app-name> ....... --userdata="field1=testvalue"

Then I tried creating a json file in the directory I was currently in and passing it in like this:

amc launch <app-name> ....... --userdata-path="my-user-data.json"

For my use case I’d rather pass the values straight in, but I’d like to know how to do both.

Launching an instance in this way makes an instance that says it’s running, but when I try to join the session I see a message saying “Session is not active yet. Connecting…”.

When I run:

amc show <instance>

It says there are no stored logs.

Is there another way to get error logs and what am I doing wrong with the userdata parameter.

Hello @al-p ,

I think you have used the --enable-streaming option to launch a stream-ready instance.
Could you file a bug for this at Bugs : Anbox Cloud?

Also, thank you for your feedback on the documentation. It should have a full example of the command with the option, we will fix that as well as part of this bug.

For the time being, adding the userdata directly as part of the app or using an addon for the app to consume through a hook can be a workaround.

Given a bit more context:
The issue here is that whenever an instance is launched with the amc launch --enable-streaming command, the /var/lib/anbox/userdata file, which is supposed to include the session info, gets overridden by the data specified by the user via the --userdata or --userdata-path option. Because of this, people cannot join the same session even after the instance is up and running (from the AMS perspective, its status is running).

As @keirthana mentioned, as an immediate step, you could put the userdata file into an addon or an application alongside the manifest file, and you can make use of ${APP_DIR} or ${ADDON_DIR} to locate the userdata file (depending on where the file is placed) in a hook.

Best regards,
Gary

Thanks @keirthana and @gary-wzl77

I’ve created a bug to track this issue.

Is it possible to send -enable-streaming to a started instance which did not have streaming enabled on launch?

I was just thinking that could be another workaround, plus we don’t always need streaming, but we’ve always added it in case we need to go in manually to debug.

It is not possible to change the enable-streaming attribute during an instance’s runtime.
Due to the issue mentioned above, the only way to provision the userdata into an instance from the CLI for now is to drop the --enable-streaming option, which may not be desirable in your case.

Best regards,
Gary