From f47b2aa4b563bd49f88307e5c1adebafee6700b7 Mon Sep 17 00:00:00 2001 From: Stegen Smith Date: Fri, 15 May 2026 12:45:22 -0700 Subject: [PATCH 1/2] adding some debug logs --- internal/config/handler.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/config/handler.go b/internal/config/handler.go index 1a84aac..9d31b2f 100644 --- a/internal/config/handler.go +++ b/internal/config/handler.go @@ -303,11 +303,19 @@ func (bc *ButlerConfig) RunCMHandler() error { m.FileHashes = make(map[string]string) } + // DEBUG: log pre-merge state + log.Infof("Config::RunCMHandler()[count=%v][manager=%v]: DEBUG 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.Infof("Config::RunCMHandler()[count=%v][manager=%v]: DEBUG 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 @@ -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.Infof("Config::RunCMHandler()[count=%v][manager=%v]: DEBUG 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) From 6f70b8d982098224b14c784a093097b782f44ceb Mon Sep 17 00:00:00 2001 From: Stegen Smith Date: Fri, 15 May 2026 14:18:13 -0700 Subject: [PATCH 2/2] fixing up broken config comparieson --- VERSION | 2 +- internal/config/chan.go | 18 ++++++++---------- internal/config/handler.go | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/VERSION b/VERSION index bc80560..26ca594 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.0 +1.5.1 diff --git a/internal/config/chan.go b/internal/config/chan.go index 5a68a65..8a49fd7 100644 --- a/internal/config/chan.go +++ b/internal/config/chan.go @@ -228,6 +228,11 @@ 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 @@ -235,11 +240,6 @@ func (c *ConfigChanEvent) ComparePrimaryConfigHashes(opts map[string]*ManagerOpt ) 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 { @@ -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() { diff --git a/internal/config/handler.go b/internal/config/handler.go index 9d31b2f..a3d78d0 100644 --- a/internal/config/handler.go +++ b/internal/config/handler.go @@ -304,7 +304,7 @@ func (bc *ButlerConfig) RunCMHandler() error { } // DEBUG: log pre-merge state - log.Infof("Config::RunCMHandler()[count=%v][manager=%v]: DEBUG pre-merge m.FileHashes len=%d %#v", + 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 @@ -313,7 +313,7 @@ func (bc *ButlerConfig) RunCMHandler() error { aChanged, aHashes := AdditionalChan.CompareAdditionalConfigHashes(m.FileHashes) // DEBUG: log what compare returned - log.Infof("Config::RunCMHandler()[count=%v][manager=%v]: DEBUG pHashes=%#v aHashes=%#v pChanged=%v aChanged=%v", + 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 @@ -325,7 +325,7 @@ func (bc *ButlerConfig) RunCMHandler() error { } // DEBUG: log post-merge state and the *Manager identity to confirm pointer stability - log.Infof("Config::RunCMHandler()[count=%v][manager=%v]: DEBUG post-merge m.FileHashes len=%d %#v (m=%p)", + 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 {