Skip to content

Commit

Permalink
fix: pebble do not stop for default services start error
Browse files Browse the repository at this point in the history
This reverts commit 1281c96
and reverts the hard-error behaviour introduced in
4098a71. Pebble should no longer,
at least not due to this commit, exit with non-zero error code if
waiting for the "change" (of default services start) to be ready
returns any errors.
  • Loading branch information
rebornplusplus committed Jul 24, 2023
1 parent 1281c96 commit c01f729
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
33 changes: 0 additions & 33 deletions internals/cli/cmd_enter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,36 +269,3 @@ func (s *PebbleSuite) TestEnterSubCommandWaits(c *C) {

c.Check(svcStartTime.Before(subCmdExecTime), Equals, true)
}

// TestEnterDefaultServiceStartError tests whether default service
// start errors are reported with non-zero exit codes. Note that,
// for now this is only tested for
//
// pebble enter --run <subcommand> [args..]
//
// Discussions about having this error reporting for “pebble run“
// and similar scenarios can be found at:
// - https://github.com/canonical/pebble/pull/257#discussion_r1259070650
// - https://github.com/canonical/pebble/issues/167
func (s *PebbleSuite) TestEnterDefaultServiceStartError(c *C) {
layerTemplate := dumbDedent(`
services:
srv:
override: replace
command: unknownBinary123
startup: enabled
`)
layerPath := filepath.Join(s.pebbleDir, "layers", "001-stat.yaml")
writeTemplate(layerPath, layerTemplate, nil)

cmd := []string{"pebble", "enter", "--run", "stop", "srv1"}
restore := fakeArgs(cmd...)
defer restore()

exitCode := cli.PebbleMain()
c.Check(exitCode, Equals, 1)
stderr := s.Stderr()
c.Check(stderr, Matches, "^(?s)cannot run pebble: error starting default services.*")
c.Check(stderr, Matches, "(?s).*Start service .* executable file not found in \\$PATH.*")
c.Check(s.Stdout(), Equals, "")
}
2 changes: 1 addition & 1 deletion internals/cli/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ out:
}
case chgErr := <-autoStartReady:
if chgErr != nil {
return fmt.Errorf("error starting default services: %w", chgErr)
logger.Noticef("Error starting default services: %v", chgErr)
}
notifyReady()
case <-stop:
Expand Down

0 comments on commit c01f729

Please sign in to comment.