From 567d870a4729b08f7b943be6b42ae7ab9583d06d Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Mon, 26 Oct 2020 21:09:32 -0700 Subject: [PATCH] clear cache when recovering salt to fix rare msgpack errors --- agent/agent_windows.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agent/agent_windows.go b/agent/agent_windows.go index e428a22..37f9355 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -457,6 +457,13 @@ func (a *WindowsAgent) RecoverSalt() { _, _ = CMD(a.Nssm, []string{"stop", saltSVC}, 120, false) a.ForceKillSalt() + time.Sleep(2 * time.Second) + cacheDir := filepath.Join(a.SystemDrive, "\\salt", "var", "cache", "salt", "minion") + a.Logger.Debugln("Clearing salt cache in", cacheDir) + err := os.RemoveAll(cacheDir) + if err != nil { + a.Logger.Debugln(err) + } _, _ = CMD("ipconfig", []string{"flushdns"}, 15, false) a.Logger.Debugln("Salt recovery completed on", a.Hostname) }