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

WI: set identity to client secret if missing #15121

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .changelog/15121.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
wi: Fixed a bug where clients running pre-1.4.0 allocations would erase the token used to query service registrations after upgrade
```
8 changes: 6 additions & 2 deletions client/allocrunner/taskrunner/identity_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func (h *identityHook) Prestart(ctx context.Context, req *interfaces.TaskPrestar
defer h.lock.Unlock()

token := h.tr.alloc.SignedIdentities[h.taskName]
h.tr.setNomadToken(token)
if token != "" {
h.tr.setNomadToken(token)
}
return nil
}

Expand All @@ -45,6 +47,8 @@ func (h *identityHook) Update(_ context.Context, req *interfaces.TaskUpdateReque
defer h.lock.Unlock()

token := h.tr.alloc.SignedIdentities[h.taskName]
h.tr.setNomadToken(token)
if token != "" {
h.tr.setNomadToken(token)
}
return nil
}
4 changes: 4 additions & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ func NewTaskRunner(config *Config) (*TaskRunner, error) {
return nil, err
}

// Use the client secret only as the initial value; the identity hook will
// update this with a workload identity if one is available
tr.setNomadToken(config.ClientConfig.Node.SecretID)

// Initialize the runners hooks. Must come after initDriver so hooks
// can use tr.driverCapabilities
tr.initHooks()
Expand Down