Docker Service updatedAt timestamp

398 views Asked by At

Docker Swarm API client has the following meta information for a service:

Meta.UpdatedAt

Is this the timestamp of last user-initiated update (e.g. change service configuration) OR is it a timestamp of any change on service, that even Docker Swarm performs?

For example, if my swarm service has 5 tasks spread across cluster, and then Docker for some reason move one task from one node to another node (so the service configuration is NOT changed); would it update this field?

1

There are 1 answers

1
abronan On BEST ANSWER

Short answer: No this won't.

If you look at the source code, meta.UpdatedAt is changed through the touchMeta method that is called by update. For a service, the method handling this is UpdateService, which is linked to the docker service update cli command. So technically, meta.UpdatedAt is updated only when you use docker service update.

You can test this quickly by following this scenario on your local machine or cluster:

$ docker service create --name redis --replicas 5 redis

$ docker service inspect --format='{{.Meta.UpdatedAt}}' redis
2017-01-07 15:16:14.910287822 +0000 UTC

$ docker rm -f <some-redis-task-id>

# Swarm should re-schedule the forced removed task onto another node

$ docker service inspect --format='{{.Meta.UpdatedAt}}' redis
2017-01-07 15:16:14.910287822 +0000 UTC

The meta.UpdatedAt field should be left unchanged.

Now call docker service update redis --replicas 10 and you should see the new timestamp.