Deployments created via REST are not discovered by device

Hi there,

I use a REST call to create a deployment for a specific device ID. When I sudo mender check-update on my device to force the client to check for a server update, I see that the deployment status is updated to pending, but the device does not seem to find any update info, and thus cannot be updated.

If I create a deployment for the same device and artifact using the GUI, after sudo mender check-updateing on the device the deployment immediately jumps into ‘inprogress’ and awaits user confirmation.

This used to work when creating a deployment via REST before the major bump. Has something changed on this front? Has anyone experienced a similar issue?

Many thanks!

Hi @donasmi,

I’m not aware of any issues here, recently used this very mechanism.
Which “major version” bump are you referring to? There should not have been anything that affects this. The sudo mender invocation suggests that this is a debianoid image on Mender Client 3.X, but can you please give a few more details? Eventually check the logs?

Greets,
Josef

Thanks for responding so quickly!
We are using mender client 3.5.2.
I checked the journal and it doesn’t really give me a lot of info. For the deployment that I create via REST, I see the following once I force check for an update on the server:

Jan 24 17:53:30 x mender[6861]: time="2024-01-24T17:53:30+01:00" level=info msg="Forcing state machine to: update-check"
Jan 24 17:53:30 x mender[6861]: time="2024-01-24T17:53:30+01:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Jan 24 17:53:30 x mender[6861]: time="2024-01-24T17:53:30+01:00" level=info msg="State transition: update-check [Sync] -> check-wait [Idle]"
Jan 24 17:59:03 x mender[6861]: time="2024-01-24T17:59:03+01:00" level=info msg="State transition: check-wait [Idle] -> inventory-update [Sync]"
Jan 24 17:59:04 x mender[6861]: time="2024-01-24T17:59:04+01:00" level=info msg="State transition: inventory-update [Sync] -> check-wait [Idle]"
Jan 24 17:59:05 x mender[6861]: time="2024-01-24T17:59:05+01:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Jan 24 17:59:05 x mender[6861]: time="2024-01-24T17:59:05+01:00" level=info msg="State transition: update-check [Sync] -> check-wait [Idle]"

But maybe I create the deployment incorrectly?
This is my rest call to deploy one artifact to one device ID:

headers = _authenticate(
        {
            "Content-Type": "application/json",
            "Accept": "application/json",
        }
    )
    data = {
        "name": "production",
        "artifact_name": f"{artifact_name}",
        "devices": [f"{device_id}"],
        "phases": [],
        "retries": 0,
    }

    response = requests.post(
        f"{MENDER_SERVER_URI}/api/management/v1/deployments/deployments",
        json=data,
        headers=headers,
    )

Does this seem right?

Hi @donasmi,

Looks about right, indeed. My code is slightly different (and also, JS), but the key parts are:

const artifact_name = "...";
const device_id = "...";
const token = "...";
const req = {
  method: "POST",
  url: "https://hosted.mender.io/api/management/v1/deployments/deployments",
  headers: {
    'Accept': 'application/json', 
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json'
  },
  {
    data: {
    name: device_id,
    artifact_name: artifact_name,
    devices: [
      device_id
    ],
    all_devices: false
  }
};

axios(req)
.then((response) => {
...
})
.catch((error) => {
...
})

Maybe setting the empty phases property is getting into the way here, but that’s really just guessing.

Greets,
Josef

Hi @TheYoctoJester ,

Indeed, I removed “phases” and added all_devices: false, and now the deployment is picked up and the device can be upgraded.

Thank you so much for your support! :pray:

1 Like