concourse / pool-resource

atomically manages the state of the world (e.g. external environments)
Apache License 2.0
54 stars 36 forks source link

Make evident how much time the resource is waiting to acquire a lock #41

Closed marco-m closed 5 years ago

marco-m commented 5 years ago

While the resource polls the backing store attempting to acquire a lock, it prints a dot . to stdout without newline, as shown in the picture:

pool-waiting

This is fine to give visual feedback that something is happening (I see the dots increasing) and I am happy with the fact that no newline is added.

BUT, a side effect is that the only timestamp on the left of the text acquiring lock on: ... is updated each time a new dot is printed. This means that a user cannot know for how long the resource is attempting to acquire the lock (it is possible to obtain the information indirectly by looking at the "started" header in the GUI, but it is confusing).

Additional problem is that the lock takes a lot of time to be acquired, the .... line continues horizontally towards the right forever in the web UI, there is no line wrapping.

I will provide a PR that will add an initial text with newline, so that the first timestamp will be fixed. Something along the lines of

12:01:03 pool resorce starting            <= this timestamp allows me to know when we started
12:22:11 acquiring lock ...               <= this timestamp keeps changing, this is fine
12:22:12 lock acquired, wait time 21 min  <= I will add this if I find a simple way to keep state
marco-m commented 5 years ago

Minimal fix is printing the "Starting" on the first line:

pool-starting

As you can see, the resource started at 17:07:09, did 8 polls (the 8 dots), the time of the last poll is 17:14:29, and so the elapsed time waiting can be calculated as around 7 minutes.

marco-m commented 5 years ago

With the new version of the PR:

acquire, no wait:

acquire-no-wait

acquire, wait:

acquire-wait

claim, no wait:

claim-no-wait

claim, wait:

claim-wait