concourse / time-resource

a resource for triggering on an interval
Apache License 2.0
44 stars 33 forks source link

New version not produced when it should be #25

Closed jleben closed 4 years ago

jleben commented 6 years ago

Here are steps to reproduce the issue:

Prepare file named test-in with the following contents (note that time is earlier than start)

{
  "source": {
    "start": "1:10",
    "stop": "2:00"
  },
  "version": { "time": "2018-03-26T01:00:00Z" }
}

Current UTC time is between start and stop:

$ date -uIs
2018-03-26T01:19:19+00:00

Checking the resource does not produce a new version:

$ cat test-in | docker run --rm -i time-resource /opt/resource/check
[{"time":"2018-03-26T01:00:00Z"}]

However, changing the input time to one day earlier does:

$ cat test-in | docker run --rm -i time-resource /opt/resource/check
[{"time":"2018-03-25T01:00:00Z"},{"time":"2018-03-26T01:24:48.364798202Z"}]

It appears the comparison of start with respect to the input time is off by 1 hour. Observe the following:

Current time in Vancouver is: 2018-03-25T18:34:34-07:00

The following input produces a new version:

{
  "source": {
    "start": "18:00",
    "stop": "19:00",
    "location": "America/Vancouver"
  },
  "version": { "time": "2018-03-25T16:59:00-07:00" }
}

However, changing the input time to one minute later 2018-03-25T17:00:00-07:00 does not produce a new version.

jleben commented 6 years ago

Hmm, looking at the code, I see it only compares the current day of previous time and now. This logic works as long as the configuration of the resource never changes since in that case one expects at most one trigger a day. However, if one changes the configuration, then Concourse might have a cached version that's less than a day ago since the start of the new configuration.

jleben commented 6 years ago

This is fixed by my PR: https://github.com/concourse/time-resource/pull/27

vito commented 4 years ago

27 was merged; closing