Skip to content

Commit

Permalink
Oops, rename health check instances too
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt committed Jul 11, 2023
1 parent b608a0f commit 505cbf3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion internals/overlord/checkstate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func newChecker(config *plan.Check, p *plan.Plan) checker {
Group: config.Exec.Group,
WorkingDir: config.Exec.WorkingDir,
}
merged, err := plan.MergeServiceContext(p, config.Exec.Context, overrides)
merged, err := plan.MergeServiceContext(p, config.Exec.ServiceContext, overrides)
if err != nil {
// Context service name has already been checked when plan was loaded.
panic("internal error: " + err.Error())
Expand Down
20 changes: 10 additions & 10 deletions internals/overlord/checkstate/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ func (s *CheckersSuite) TestExecContextNoOverride(c *C) {
chk := newChecker(&plan.Check{
Name: "exec",
Exec: &plan.ExecCheck{
Command: "sleep 1",
Context: "svc1",
Command: "sleep 1",
ServiceContext: "svc1",
},
}, &plan.Plan{Services: map[string]*plan.Service{
"svc1": {
Expand Down Expand Up @@ -382,14 +382,14 @@ func (s *CheckersSuite) TestExecContextOverride(c *C) {
chk := newChecker(&plan.Check{
Name: "exec",
Exec: &plan.ExecCheck{
Command: "sleep 1",
Context: "svc1",
Environment: map[string]string{"k": "v"},
UserID: &userID,
User: "user",
GroupID: &groupID,
Group: "group",
WorkingDir: "/working/dir",
Command: "sleep 1",
ServiceContext: "svc1",
Environment: map[string]string{"k": "v"},
UserID: &userID,
User: "user",
GroupID: &groupID,
Group: "group",
WorkingDir: "/working/dir",
},
}, &plan.Plan{Services: map[string]*plan.Service{
"svc1": {
Expand Down
28 changes: 14 additions & 14 deletions internals/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,14 @@ func (c *TCPCheck) Merge(other *TCPCheck) {

// ExecCheck holds the configuration for an exec health check.
type ExecCheck struct {
Command string `yaml:"command,omitempty"`
Context string `yaml:"context,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
UserID *int `yaml:"user-id,omitempty"`
User string `yaml:"user,omitempty"`
GroupID *int `yaml:"group-id,omitempty"`
Group string `yaml:"group,omitempty"`
WorkingDir string `yaml:"working-dir,omitempty"`
Command string `yaml:"command,omitempty"`
ServiceContext string `yaml:"service-context,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
UserID *int `yaml:"user-id,omitempty"`
User string `yaml:"user,omitempty"`
GroupID *int `yaml:"group-id,omitempty"`
Group string `yaml:"group,omitempty"`
WorkingDir string `yaml:"working-dir,omitempty"`
}

// Copy returns a deep copy of the exec check configuration.
Expand All @@ -460,8 +460,8 @@ func (c *ExecCheck) Merge(other *ExecCheck) {
if other.Command != "" {
c.Command = other.Command
}
if other.Context != "" {
c.Context = other.Context
if other.ServiceContext != "" {
c.ServiceContext = other.ServiceContext
}
for k, v := range other.Environment {
if c.Environment == nil {
Expand Down Expand Up @@ -729,11 +729,11 @@ func CombineLayers(layers ...*Layer) (*Layer, error) {
Message: fmt.Sprintf("plan check %q command invalid: %v", name, err),
}
}
_, contextExists := combined.Services[check.Exec.Context]
if check.Exec.Context != "" && !contextExists {
_, contextExists := combined.Services[check.Exec.ServiceContext]
if check.Exec.ServiceContext != "" && !contextExists {
return nil, &FormatError{
Message: fmt.Sprintf("plan check %q context specifies non-existent service %q",
name, check.Exec.Context),
Message: fmt.Sprintf("plan check %q service context specifies non-existent service %q",
name, check.Exec.ServiceContext),
}
}
_, _, err = osutil.NormalizeUidGid(check.Exec.UserID, check.Exec.GroupID, check.Exec.User, check.Exec.Group)
Expand Down
6 changes: 3 additions & 3 deletions internals/plan/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,15 +824,15 @@ var planTests = []planTest{{
command: foo '
`},
}, {
summary: `Invalid exec check context`,
error: `plan check "chk1" context specifies non-existent service "nosvc"`,
summary: `Invalid exec check service context`,
error: `plan check "chk1" service context specifies non-existent service "nosvc"`,
input: []string{`
checks:
chk1:
override: replace
exec:
command: foo
context: nosvc
service-context: nosvc
`},
}, {
summary: "Simple layer with log targets",
Expand Down

0 comments on commit 505cbf3

Please sign in to comment.