Rendering: periodically refresh remote plugin version (#45505)
* #44449: refresh image renderer version on a schedule * #44449: simplify
This commit is contained in:
@@ -29,8 +29,9 @@ var netClient = &http.Client{
|
||||
}
|
||||
|
||||
var (
|
||||
remoteVersionFetchInterval time.Duration = time.Second * 15
|
||||
remoteVersionFetchRetries uint = 4
|
||||
remoteVersionFetchInterval time.Duration = time.Second * 15
|
||||
remoteVersionFetchRetries uint = 4
|
||||
remoteVersionRefreshInterval = time.Minute * 15
|
||||
)
|
||||
|
||||
func (rs *RenderingService) renderViaHTTP(ctx context.Context, renderKey string, opts Opts) (*RenderResult, error) {
|
||||
@@ -251,3 +252,26 @@ func (rs *RenderingService) getRemotePluginVersion() (string, error) {
|
||||
}
|
||||
return info.Version, nil
|
||||
}
|
||||
|
||||
func (rs *RenderingService) refreshRemotePluginVersion() {
|
||||
newVersion, err := rs.getRemotePluginVersion()
|
||||
if err != nil {
|
||||
rs.log.Info("Failed to refresh remote plugin version", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
if newVersion == "" {
|
||||
// the image-renderer could have been temporary unavailable - skip updating the version
|
||||
rs.log.Debug("Received empty version when trying to refresh remote plugin version")
|
||||
return
|
||||
}
|
||||
|
||||
currentVersion := rs.Version()
|
||||
if currentVersion != newVersion {
|
||||
rs.versionMutex.Lock()
|
||||
defer rs.versionMutex.Unlock()
|
||||
|
||||
rs.log.Info("Updating remote plugin version", "currentVersion", currentVersion, "newVersion", newVersion)
|
||||
rs.version = newVersion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user