Skip to content

Commit

Permalink
fix health validation and path
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstokes committed Oct 29, 2024
1 parent 213f960 commit b6c42aa
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/apm/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,24 @@ func (i *HealthInjector) Inject(ctx context.Context, inst v1alpha2.Instrumentati
return pod, err
}

// inject Health instrumentation spec env vars.
for _, env := range inst.Spec.Agent.Env {
idx := getIndexOfEnv(container.Env, env.Name)
if idx == -1 {
container.Env = append(container.Env, env)
}
}

heathFileIdx := getIndexOfEnv(container.Env, envHealthFleetControlFile)
if heathFileIdx == -1 {
return pod, fmt.Errorf("missing required %q env variable", envHealthFleetControlFile)
}
healthMountPath := filepath.Base(container.Env[heathFileIdx].Value)
healthMountPath := filepath.Dir(container.Env[heathFileIdx].Value)
if healthMountPath == "" {
return pod, fmt.Errorf("env variable %q configured incorrectly. requires a full path", envHealthFleetControlFile)
}

// inject Health instrumentation spec env vars.
for _, env := range inst.Spec.Agent.Env {
idx := getIndexOfEnv(container.Env, env.Name)
if idx == -1 {
container.Env = append(container.Env, env)
}
if healthMountPath == "/" {
return pod, fmt.Errorf("env variable %q configured incorrectly. cannot be the root", envHealthFleetControlFile)
}

//set defaults
Expand Down

0 comments on commit b6c42aa

Please sign in to comment.