Skip to content

Commit f12082c

Browse files
authored
RSDK-5140 Don't override a local config BindAddress with a default one from Cloud (#4985)
1 parent 964ead4 commit f12082c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

config/reader.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,25 @@ func fromReader(
377377

378378
if conn != nil && cfgFromDisk.Cloud != nil {
379379
cfg, err := readFromCloud(ctx, cfgFromDisk, nil, true, true, logger, conn)
380+
381+
// Special case: DefaultBindAddress is set from Cloud, but user has specified a non-default BindAddress in local config.
382+
// Keep the BindAddress from local config, and use Cloud options for everything else.
383+
// Note: DefaultBindAddress "from Cloud" is actually set with a constant in rdk.
384+
if err == nil && !cfgFromDisk.Network.BindAddressDefaultSet {
385+
if cfg.Network.BindAddressDefaultSet {
386+
logger.CInfof(ctx, "Using cloud config, but BindAddress is specified in local config (%v) "+
387+
"and not cloud config (default = %v). Using local's.",
388+
cfgFromDisk.Network.BindAddress,
389+
cfg.Network.BindAddress)
390+
cfg.Network.BindAddress = cfgFromDisk.Network.BindAddress
391+
cfg.Network.BindAddressDefaultSet = false
392+
} else {
393+
logger.CInfof(ctx, "Using cloud config, and BindAddress specified in both cloud config (%v) "+
394+
"and local config (%v). Using cloud's. Remove BindAddress from cloud config to use local's.",
395+
cfg.Network.BindAddress,
396+
cfgFromDisk.Network.BindAddress)
397+
}
398+
}
380399
return cfg, err
381400
}
382401

web/server/entrypoint.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,14 @@ func (s *robotServer) configWatcher(ctx context.Context, currCfg *config.Config,
352352
continue
353353
}
354354

355+
// Special case: the incoming config specifies the default BindAddress, but the current one in use is non-default.
356+
// Don't override the non-default BindAddress with the default one.
357+
// If this is the only difference, the next step, diff.NetworkEqual will be true.
358+
if processedConfig.Network.BindAddressDefaultSet && !currCfg.Network.BindAddressDefaultSet {
359+
processedConfig.Network.BindAddress = currCfg.Network.BindAddress
360+
processedConfig.Network.BindAddressDefaultSet = false
361+
}
362+
355363
// flag to restart web service if necessary
356364
diff, err := config.DiffConfigs(*currCfg, *processedConfig, s.args.RevealSensitiveConfigDiffs)
357365
if err != nil {
@@ -370,6 +378,12 @@ func (s *robotServer) configWatcher(ctx context.Context, currCfg *config.Config,
370378
}
371379
}
372380

381+
if currCfg.Network.BindAddress != processedConfig.Network.BindAddress {
382+
s.logger.Infof("Config watcher detected bind address change: updating %v -> %v",
383+
currCfg.Network.BindAddress,
384+
processedConfig.Network.BindAddress)
385+
}
386+
373387
// Update logger registry if log patterns may have changed.
374388
//
375389
// This functionality is tested in `TestLogPropagation` in `local_robot_test.go`.

0 commit comments

Comments
 (0)