From 69dff6c8cce29b50a40d98fb104ea56244f0a91d Mon Sep 17 00:00:00 2001 From: Andrew Li Date: Fri, 13 Feb 2026 18:04:28 -0800 Subject: [PATCH] Remove unneeded noise from the cleanup watcher in case the plugin state directory hasn't been created yet. PiperOrigin-RevId: 869961059 --- internal/plugin/manager/cleanup.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/plugin/manager/cleanup.go b/internal/plugin/manager/cleanup.go index 23e3902..35e0536 100644 --- a/internal/plugin/manager/cleanup.go +++ b/internal/plugin/manager/cleanup.go @@ -39,6 +39,10 @@ func (m *PluginManager) retryFailedRemovals(ctx context.Context) (bool, error) { pluginInstallLoc := filepath.Join(baseState(), pluginInstallDir) pluginDirs, err := os.ReadDir(pluginInstallLoc) if err != nil { + if errors.Is(err, os.ErrNotExist) { + galog.V(1).Debugf("Plugin install directory %q does not exist, nothing to clean up", pluginInstallLoc) + return true, nil + } return true, fmt.Errorf("failed to read plugin install directory: %w", err) } @@ -58,7 +62,7 @@ func (m *PluginManager) retryFailedRemovals(ctx context.Context) (bool, error) { nameIndex := strings.LastIndex(p.Name(), "_") pluginName := p.Name()[:nameIndex] pluginRevision := p.Name()[nameIndex+1:] - galog.Debugf("Checking plugin %q, revision %q", pluginName, pluginRevision) + galog.V(1).Debugf("Checking plugin %q, revision %q", pluginName, pluginRevision) // We want to avoid cleaning up plugins that currently have a request in progress. // This is to prevent a race condition where the plugin is removed in the // middle of an installation request. @@ -81,10 +85,10 @@ func (m *PluginManager) retryFailedRemovals(ctx context.Context) (bool, error) { } // Check if the link points to a plugin directory that is no longer cached // by the guest agent. - galog.Debugf("Checking link %q", link) + galog.V(1).Debugf("Checking link %q", link) if _, ok := failedRemovals[filepath.Base(dest)]; ok { linkPath := filepath.Join(pluginInstallLoc, link) - galog.Debugf("Removing link %q", linkPath) + galog.V(1).Debugf("Removing link %q", linkPath) if err := os.Remove(linkPath); err != nil { galog.Debugf("Unable to remove link %q: %v", linkPath, err) }