Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt committed Sep 20, 2024
1 parent 06f5b05 commit d5d4999
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions module/modmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ func (mgr *Manager) newOnUnexpectedExitHandler(mod *module) func(exitCode int) b
if orphanedResourceNames := mgr.attemptRestart(mgr.restartCtx, mod); orphanedResourceNames != nil {
if mgr.removeOrphanedResources != nil {
mgr.removeOrphanedResources(mgr.restartCtx, orphanedResourceNames)
mgr.logger.Debugw("Removed resources after failed module restart", "module", mod.cfg.Name, "resources", orphanedResourceNames)
}
return false
}
Expand Down
12 changes: 8 additions & 4 deletions module/modmanager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ func TestModuleReloading(t *testing.T) {

testutils.WaitForAssertion(t, func(tb testing.TB) {
tb.Helper()
test.That(tb, logs.FilterMessageSnippet("Error while restarting crashed module").Len(),
test.ShouldEqual, 3)
test.That(tb, logs.FilterMessageSnippet("Removed resources after failed module restart").Len(),
test.ShouldEqual, 1)
})

ok = mgr.IsModularResource(rNameMyHelper)
Expand All @@ -546,6 +546,8 @@ func TestModuleReloading(t *testing.T) {
test.ShouldEqual, 1)
test.That(t, logs.FilterMessageSnippet("Module successfully restarted").Len(),
test.ShouldEqual, 0)
test.That(t, logs.FilterMessageSnippet("Error while restarting crashed module").Len(),
test.ShouldEqual, 3)

// Assert that RemoveOrphanedResources was called once.
test.That(t, dummyRemoveOrphanedResourcesCallCount.Load(), test.ShouldEqual, 1)
Expand Down Expand Up @@ -587,7 +589,7 @@ func TestModuleReloading(t *testing.T) {

testutils.WaitForAssertion(t, func(tb testing.TB) {
tb.Helper()
test.That(tb, logs.FilterMessageSnippet("Will not attempt to restart crashed module").Len(),
test.That(tb, logs.FilterMessageSnippet("Removed resources after failed module restart").Len(),
test.ShouldEqual, 1)
})

Expand All @@ -598,11 +600,13 @@ func TestModuleReloading(t *testing.T) {
test.That(t, err.Error(), test.ShouldContainSubstring, "not connected")

// Assert that logs reflect that test-module crashed and was not
// successfully restarted.
// restarted.
test.That(t, logs.FilterMessageSnippet("Module has unexpectedly exited").Len(),
test.ShouldEqual, 1)
test.That(t, logs.FilterMessageSnippet("Module successfully restarted").Len(),
test.ShouldEqual, 0)
test.That(t, logs.FilterMessageSnippet("Will not attempt to restart crashed module").Len(),
test.ShouldEqual, 1)

// Assert that RemoveOrphanedResources was called once.
test.That(t, dummyRemoveOrphanedResourcesCallCount.Load(), test.ShouldEqual, 1)
Expand Down

0 comments on commit d5d4999

Please sign in to comment.