зеркало из https://github.com/mozilla/mig.git
[minor] add a results delay configuration value
This supports including a small delay following action expiry before attempting to retrieve results from the API.
This commit is contained in:
Родитель
9ce12422e1
Коммит
0ba9cb93a7
|
@ -13,3 +13,4 @@
|
|||
; If the private key has a passphrase associated with it, this must be
|
||||
; set to the correct value.
|
||||
passphrase = "passphrase" ; Private key passphrase
|
||||
delayresults = "30s" ; Duration after action expiry to fetch action results
|
||||
|
|
|
@ -36,11 +36,18 @@ An example configuration file for use by mig-runner is shown below.
|
|||
|
||||
[client]
|
||||
clientconfpath = "default" ; Path to client conf, default for $HOME/.migrc
|
||||
delayresults = "30s"; Duration after action expiry to fetch results
|
||||
|
||||
If the GPG key used by mig-runner is protected by a passphrase, the
|
||||
`passphrase` option can be included under the client section. If this is
|
||||
specified this passphrase will be used to access the private key.
|
||||
|
||||
The `delayresults` value is optional. If not set, the runner will attempt
|
||||
to fetch action results when the action has expired. If this is set to a
|
||||
duration string value, the runner will wait the specified duration after
|
||||
action expiry before fetching results (for example to ensure all results
|
||||
are written to the database by the scheduler).
|
||||
|
||||
The `directory` option specifies the root directory that stores all the
|
||||
mig-runner related control information. A typical runner directory may look
|
||||
something like this.
|
||||
|
|
|
@ -28,6 +28,7 @@ type Context struct {
|
|||
Client struct {
|
||||
ClientConfPath string
|
||||
Passphrase string
|
||||
DelayResults string
|
||||
}
|
||||
Logging mig.Logging
|
||||
|
||||
|
|
|
@ -112,11 +112,23 @@ func processResults() {
|
|||
continue
|
||||
}
|
||||
|
||||
resDelay := ctx.Client.DelayResults
|
||||
|
||||
// See if any actions have expired, if so grab the results
|
||||
oldres := reslist
|
||||
reslist = reslist[:0]
|
||||
for _, x := range oldres {
|
||||
if time.Now().After(x.Action.ExpireAfter) {
|
||||
extime := x.Action.ExpireAfter
|
||||
if resDelay != "" {
|
||||
d, err := time.ParseDuration(resDelay)
|
||||
if err != nil {
|
||||
mlog("results error for %v: %v", x.EntityName, err)
|
||||
mlog("%v: ignoring specified results delay", x.EntityName)
|
||||
} else {
|
||||
extime = extime.Add(d)
|
||||
}
|
||||
}
|
||||
if time.Now().After(extime) {
|
||||
err := getResults(x)
|
||||
if err != nil {
|
||||
mlog("results error for %v: %v", x.EntityName, err)
|
||||
|
|
Загрузка…
Ссылка в новой задаче