Skip to content
Merged
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
18 changes: 8 additions & 10 deletions internal/config/chan.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,18 @@ func (c *ConfigChanEvent) CopyAdditionalConfigFiles(destDir string) bool {

// ComparePrimaryConfigHashes compares hashes of primary config files without writing to disk.
// This is used in watch-only mode. Returns true if any file has changed, along with updated hashes.
//
// The returned map contains ONLY entries for primary-config files this call inspected.
// The caller is responsible for merging it into its own stored-hash map; this function
// does NOT pre-seed newHashes with all of storedHashes (doing so would cause additional/primary
// hash maps to clobber each other when both are merged into m.FileHashes by the caller).
func (c *ConfigChanEvent) ComparePrimaryConfigHashes(opts map[string]*ManagerOpts, storedHashes map[string]string) (bool, map[string]string) {
var (
primaryConfigs []string
hasChanged bool
)
newHashes := make(map[string]string)

// Copy existing hashes
for k, v := range storedHashes {
newHashes[k] = v
}

// Get list of primary config files in order
for _, opt := range opts {
for _, config := range opt.PrimaryConfig {
Expand Down Expand Up @@ -275,15 +275,13 @@ func (c *ConfigChanEvent) ComparePrimaryConfigHashes(opts map[string]*ManagerOpt

// CompareAdditionalConfigHashes compares hashes of additional config files without writing to disk.
// This is used in watch-only mode. Returns true if any file has changed, along with updated hashes.
//
// The returned map contains ONLY entries for additional-config files this call inspected.
// See ComparePrimaryConfigHashes for the rationale.
func (c *ConfigChanEvent) CompareAdditionalConfigHashes(storedHashes map[string]string) (bool, map[string]string) {
var hasChanged bool
newHashes := make(map[string]string)

// Copy existing hashes
for k, v := range storedHashes {
newHashes[k] = v
}

log.Debugf("ConfigChanEvent::CompareAdditionalConfigHashes(): entering")

for _, f := range c.GetTmpFileMap() {
Expand Down
12 changes: 12 additions & 0 deletions internal/config/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,19 @@ func (bc *ButlerConfig) RunCMHandler() error {
m.FileHashes = make(map[string]string)
}

// DEBUG: log pre-merge state
log.Debugf("Config::RunCMHandler()[count=%v][manager=%v]: pre-merge m.FileHashes len=%d %#v",
cmHandlerCounter, m.Name, len(m.FileHashes), m.FileHashes)

// Compare primary config hashes
pChanged, pHashes := PrimaryChan.ComparePrimaryConfigHashes(m.ManagerOpts, m.FileHashes)
// Compare additional config hashes
aChanged, aHashes := AdditionalChan.CompareAdditionalConfigHashes(m.FileHashes)

// DEBUG: log what compare returned
log.Debugf("Config::RunCMHandler()[count=%v][manager=%v]: pHashes=%#v aHashes=%#v pChanged=%v aChanged=%v",
cmHandlerCounter, m.Name, pHashes, aHashes, pChanged, aChanged)

// Merge the new hashes back
for k, v := range pHashes {
m.FileHashes[k] = v
Expand All @@ -316,6 +324,10 @@ func (bc *ButlerConfig) RunCMHandler() error {
m.FileHashes[k] = v
}

// DEBUG: log post-merge state and the *Manager identity to confirm pointer stability
log.Debugf("Config::RunCMHandler()[count=%v][manager=%v]: post-merge m.FileHashes len=%d %#v (m=%p)",
cmHandlerCounter, m.Name, len(m.FileHashes), m.FileHashes, m)

if pChanged || aChanged {
ReloadManager = append(ReloadManager, m.Name)
log.Infof("Config::RunCMHandler()[count=%v][manager=%v]: watch-only mode detected changes, will trigger reload", cmHandlerCounter, m.Name)
Expand Down
Loading