Skip to content

RSDK-5140 Don't override a local config BindAddress with a default one from Cloud #4985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Infof("Using cloud config, but BindAddress is specified in local config (%v) "+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer using logger.CInfof, even if it wouldn't matter in this case

"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.Infof("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
}

Expand Down
14 changes: 14 additions & 0 deletions web/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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`.
Expand Down
Loading