Skip to content
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

fix: use interpolated address when performing health checks #18584

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/allocrunner/alloc_runner_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (ar *allocRunner) initRunnerHooks(config *clientconfig.Config) error {
}

// Create a taskenv.TaskEnv which is used for read only purposes by the
// newNetworkHook.
// newNetworkHook and newChecksHook.
builtTaskEnv := newEnvBuilder().Build()

// Create the alloc directory hook. This is run first to ensure the
Expand All @@ -138,7 +138,7 @@ func (ar *allocRunner) initRunnerHooks(config *clientconfig.Config) error {
newConsulGRPCSocketHook(hookLogger, alloc, ar.allocDir, config.ConsulConfig, config.Node.Attributes),
newConsulHTTPSocketHook(hookLogger, alloc, ar.allocDir, config.ConsulConfig),
newCSIHook(alloc, hookLogger, ar.csiManager, ar.rpcClient, ar, ar.hookResources, ar.clientConfig.Node.SecretID),
newChecksHook(hookLogger, alloc, ar.checkStore, ar),
newChecksHook(hookLogger, alloc, ar.checkStore, ar, builtTaskEnv),
}
if config.ExtraAllocHooks != nil {
ar.runnerHooks = append(ar.runnerHooks, config.ExtraAllocHooks...)
Expand Down
8 changes: 7 additions & 1 deletion client/allocrunner/checks_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/nomad/client/allocrunner/interfaces"
"github.com/hashicorp/nomad/client/serviceregistration/checks"
"github.com/hashicorp/nomad/client/serviceregistration/checks/checkstore"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
)
Expand Down Expand Up @@ -82,6 +83,7 @@ type checksHook struct {
shim checkstore.Shim
checker checks.Checker
allocID string
taskEnv *taskenv.TaskEnv

// fields that get re-initialized on allocation update
lock sync.RWMutex
Expand All @@ -96,6 +98,7 @@ func newChecksHook(
alloc *structs.Allocation,
shim checkstore.Shim,
network structs.NetworkStatus,
taskEnv *taskenv.TaskEnv,
) *checksHook {
h := &checksHook{
logger: logger.Named(checksHookName),
Expand All @@ -104,6 +107,7 @@ func newChecksHook(
shim: shim,
network: network,
checker: checks.New(logger),
taskEnv: taskEnv,
}
h.initialize(alloc)
return h
Expand Down Expand Up @@ -208,8 +212,10 @@ func (h *checksHook) Prerun() error {
return nil
}

interpolatedServices := taskenv.InterpolateServices(h.taskEnv, group.NomadServices())

// create and start observers of nomad service checks in alloc
h.observe(h.alloc, group.NomadServices())
h.observe(h.alloc, interpolatedServices)

return nil
}
Expand Down
Loading