Skip to content

Commit

Permalink
fix(config): ignore first change notification in ListenForCustomConfi…
Browse files Browse the repository at this point in the history
…gChanges (#315)

The first change notification causes issues with values that have
been overriden. It needs to be ignored, similar to regular config
ListenForChanges.

Fixes #314

Signed-off-by: Jennifer Williams <[email protected]>
  • Loading branch information
jenmwms authored Mar 28, 2022
1 parent e2d14c6 commit 6332299
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bootstrap/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ func (cp *Processor) ListenForCustomConfigChanges(

configClient.WatchForChanges(updateStream, errorStream, configToWatch, sectionName)

isFirstUpdate := true

for {
select {
case <-cp.ctx.Done():
Expand All @@ -318,6 +320,14 @@ func (cp *Processor) ListenForCustomConfigChanges(
cp.lc.Error(ex.Error())

case raw := <-updateStream:
// Config Provider sends an update as soon as the watcher is connected even though there are not
// any changes to the configuration. This causes an issue during start-up if there is an
// envVars override of one of the Writable fields, so we must ignore the first update.
if isFirstUpdate {
isFirstUpdate = false
continue
}

cp.lc.Infof("Updated custom configuration '%s' has been received from the Configuration Provider", sectionName)
changedCallback(raw)
}
Expand Down

0 comments on commit 6332299

Please sign in to comment.