-
Notifications
You must be signed in to change notification settings - Fork 385
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
Remove stack when directory is renamed #5250
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ import ( | |
"github.com/k0sproject/k0s/internal/pkg/file" | ||
"github.com/k0sproject/k0s/pkg/component/controller/leaderelector" | ||
"github.com/k0sproject/k0s/pkg/component/manager" | ||
"github.com/k0sproject/k0s/pkg/config" | ||
"github.com/k0sproject/k0s/pkg/constant" | ||
kubeutil "github.com/k0sproject/k0s/pkg/kubernetes" | ||
|
||
|
@@ -41,7 +40,7 @@ import ( | |
|
||
// Manager is the Component interface wrapper for Applier | ||
type Manager struct { | ||
K0sVars *config.CfgVars | ||
ManifestsDir string | ||
IgnoredStacks []string | ||
KubeClientFactory kubeutil.ClientFactoryInterface | ||
|
||
|
@@ -62,12 +61,12 @@ type stack = struct { | |
|
||
// Init initializes the Manager | ||
func (m *Manager) Init(ctx context.Context) error { | ||
err := dir.Init(m.K0sVars.ManifestsDir, constant.ManifestsDirMode) | ||
err := dir.Init(m.ManifestsDir, constant.ManifestsDirMode) | ||
if err != nil { | ||
return fmt.Errorf("failed to create manifest bundle dir %s: %w", m.K0sVars.ManifestsDir, err) | ||
return fmt.Errorf("failed to create manifest bundle dir %s: %w", m.ManifestsDir, err) | ||
} | ||
m.log = logrus.WithField("component", constant.ApplierManagerComponentName) | ||
m.bundleDir = m.K0sVars.ManifestsDir | ||
m.bundleDir = m.ManifestsDir | ||
|
||
m.LeaderElector.AddAcquiredLeaseCallback(func() { | ||
ctx, cancel := context.WithCancelCause(ctx) | ||
|
@@ -151,7 +150,7 @@ func (m *Manager) runWatchers(ctx context.Context) { | |
if dir.IsDirectory(event.Name) { | ||
m.createStack(ctx, stacks, event.Name) | ||
} | ||
case fsnotify.Remove: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. The unit test fails on Windows, whereas it works well on Linux. I suspect this is due to the implicit event order which is probably different between Windows and Linux. I can imagine how the Create event for the new name happening before the Rename event for the old name will screw things up. Maybe the fix is more involved than simply reacting on Rename events, as well. |
||
case fsnotify.Remove, fsnotify.Rename: | ||
m.removeStack(ctx, stacks, event.Name) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Windows unit test logs, I see paths in the logs like this:
stack="C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\TestManager_Rename2408267215\\001/lorem"
. Note the last slash, which should IMO be a backslash. IIUC the logged value is coming from fsnotify, so something is not normalizing path names there. Note that the slash is a valid separator on Windows, too, albeit not the canonical one.