diff --git a/config/reader.go b/config/reader.go index bd5f0a560f8..dbc486034f7 100644 --- a/config/reader.go +++ b/config/reader.go @@ -377,6 +377,25 @@ func fromReader( if conn != nil && cfgFromDisk.Cloud != nil { cfg, err := readFromCloud(ctx, cfgFromDisk, nil, true, true, logger, conn) + + // Special case: DefaultBindAddress is set from Cloud, but user has specified a non-default BindAddress in local config. + // Keep the BindAddress from local config, and use Cloud options for everything else. + // Note: DefaultBindAddress "from Cloud" is actually set with a constant in rdk. + if err == nil && !cfgFromDisk.Network.BindAddressDefaultSet { + if cfg.Network.BindAddressDefaultSet { + logger.CInfof(ctx, "Using cloud config, but BindAddress is specified in local config (%v) "+ + "and not cloud config (default = %v). Using local's.", + cfgFromDisk.Network.BindAddress, + cfg.Network.BindAddress) + cfg.Network.BindAddress = cfgFromDisk.Network.BindAddress + cfg.Network.BindAddressDefaultSet = false + } else { + logger.CInfof(ctx, "Using cloud config, and BindAddress specified in both cloud config (%v) "+ + "and local config (%v). Using cloud's. Remove BindAddress from cloud config to use local's.", + cfg.Network.BindAddress, + cfgFromDisk.Network.BindAddress) + } + } return cfg, err } diff --git a/web/server/entrypoint.go b/web/server/entrypoint.go index f7761d50352..dbd471b7970 100644 --- a/web/server/entrypoint.go +++ b/web/server/entrypoint.go @@ -351,6 +351,14 @@ func (s *robotServer) configWatcher(ctx context.Context, currCfg *config.Config, continue } + // Special case: the incoming config specifies the default BindAddress, but the current one in use is non-default. + // Don't override the non-default BindAddress with the default one. + // If this is the only difference, the next step, diff.NetworkEqual will be true. + if processedConfig.Network.BindAddressDefaultSet && !currCfg.Network.BindAddressDefaultSet { + processedConfig.Network.BindAddress = currCfg.Network.BindAddress + processedConfig.Network.BindAddressDefaultSet = false + } + // flag to restart web service if necessary diff, err := config.DiffConfigs(*currCfg, *processedConfig, s.args.RevealSensitiveConfigDiffs) if err != nil { @@ -369,6 +377,12 @@ func (s *robotServer) configWatcher(ctx context.Context, currCfg *config.Config, } } + if currCfg.Network.BindAddress != processedConfig.Network.BindAddress { + s.logger.Infof("Config watcher detected bind address change: updating %v -> %v", + currCfg.Network.BindAddress, + processedConfig.Network.BindAddress) + } + // Update logger registry if log patterns may have changed. // // This functionality is tested in `TestLogPropagation` in `local_robot_test.go`.