This repository was archived by the owner on Sep 30, 2024. It is now read-only.
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
cmd/repo-updater/repos/conf.GetUpdateInterval() can return negative durations (panic: non-positive interval for NewTicker) #3535
Open
Description
- Sourcegraph version: 3.3.0
- Platform information: N/A
Steps to reproduce:
- In the site config, set
"repoListUpdateInterval": 9999999999
- Restart Sourcegraph
Expected behavior:
The repositories are updated every 9,999,999,999 minutes.
Actual behavior:
repo-updater panics because GetUpdateInterval
returns a non-positive duration:
https://github.com/sourcegraph/sourcegraph/blob/89ac13c006da9145efb6d674157865d9643cef71/cmd/repo-updater/repos/conf.go#L9-L15
- We should handle the case where
v < 0
. Conventionally, negative durations for intervals means to wait forever. This means that references toGetUpdateInterval
should check this and not actually run their tasks. - We should handle the case where
time.Duration(v) * time.Minute
exceeds the maximum Duration. See proposal: time/v2: make Duration safer to use golang/go#20757