Hi @chadlwilliams,
As @hansen already said, when you execute Snapshot actions, it returns an action ID, not a snapshot ID.
API docs states it:
Name: id, Type: number, Description: A unique identifier for each Droplet action event. This is used to reference a specific action that was requested.
It’s not wrong ID, it’s just an action ID which you can use to ‘trace’ snapshot execution.
Until creation is not complete, you will not have snapshot ID.
Action ID alongside Action endpoints is used to check action (in your case snapshot) details. You can learn more about it in API docs: Retrieve a Droplet Action or Retrieve an existing Action.
There is result difference between above two, but Retrieve a Droplet Action
requires you to provide Droplet ID while Retrieve an existing Action
doesn’t.
When you query any of above Action endpoints, you get status
of Action as well as other important details.
If creation is in progress, status will be in-progress
. Once it completes (successfully), it will be completed
Workaround is to query Action endpoint, with ID you got when executed snapshot request, until progress is not in-progress
. Once it is completed
, execute Get Snapshot to obtain its ID.
Reason why we check is it not in-progress
is we don’t know what status
will be in case of fail, so you don’t risk stuck-ing into infinity loop.
For example, something similar happens in doctl
. It is querying Action endpoint every 5 seconds until Actions status is not in-progress
. If you are more interested in it, you can see how does actionWait
code looks like on GitHub.
Only thing you could pay attention here is rate limit. Rate limit is how much API requests you can execute per time unit. Once remaining rate limit reaches zero, you will not be able to execute API requests until limit restarts. API docs states that it’s currently limited to 5,000 requests per hour per token.
In most of cases you are safe, but for example if you are checking status for 10 snapshots in same time every 5 seconds, you can run out of it. If you get in problem like this, just raise time and you will be good to go.
If you get into any problem, feel free to ask anything.
Maybe I went to much into details, but hopefully it will be helpful to you.
@chadlwilliams
You’re using this?
https://developers.digitalocean.com/documentation/v2/#snapshot-a-droplet
Seems like the
id
is actually not the ID of the snapshot, but of the action (which doesn’t really make any sense to me)Hopefully one of the moderators from DO will be able to answer this - probably won’t get an answer before Monday. Otherwise just ping me and I’ll see if we can find someone.
Yep, that’s exactly the problem :)