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

Stop Vault token renew on task exit #2495

Merged
merged 1 commit into from
Mar 28, 2017
Merged

Stop Vault token renew on task exit #2495

merged 1 commit into from
Mar 28, 2017

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Mar 28, 2017

This PR fixes an oversight in which the client would attempt to renew a
token even after the task exits.

Fixes #2475

This PR fixes an oversight in which the client would attempt to renew a
token even after the task exits.

Fixes #2475
}
delete(c.heap.heapMap, req.id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers sake, there are so many things called heap. The c.heap.Remove method has this definition:

func (h *vaultClientHeap) Remove(id string) error {
	if entry, ok := h.heapMap[id]; ok {
		heap.Remove(&h.heap, entry.index)
		delete(h.heapMap, id)
		return nil
	}

	return fmt.Errorf("heap doesn't contain entry for %v", id)
}

Thus the delete(c.heap.heapMap, req.id) is not necessary

@dadgar dadgar merged commit 87474b7 into master Mar 28, 2017
@dadgar dadgar deleted the b-vault-stop-renew branch March 28, 2017 18:14
@stevenscg
Copy link

@dadgar I'm running 0.5.6-rc1 in the same cluster and config as yesterday, but still seeing the worker node trying to call renew-self like before.

I thought there might have been something lingering so I removed the dispatch job, GCd, restarted the nomad agent, added the job back, and dispatched 1 instance of it. Same issue.

It seems like the worker doesn't get notified that the server revoked the token. Or if it does get notified, it isn't registering that fact locally.

Timing is about the same as previous test runs given my shortened vault TTLs:

Mar 29 15:39:17 - http request to dispatch

Mar 29 15:39:17 - client: starting task context for 'scan' (alloc 'b7544935-685a-1b3e-3888-a15a84e54550')

Mar 29 15:42:43 ip-10-101-27-196 nomad[3082]: client: task "scan" for alloc "b7544935-685a-1b3e-3888-a15a84e54550" completed successfully

2017-03-29T15:42:43Z (vault log entry. good revoke via accessor by the nomad leader server)

Mar 29 15:54:47 ip-10-101-27-196 nomad: 2017/03/29 15:54:47.350455 [ERR] client.vault: renewal of token failed: failed to renew the vault token: Error making API request.

@dadgar
Copy link
Contributor Author

dadgar commented Mar 29, 2017

@stevenscg You on linux-64bit? Would you be amenable to me giving you a build with lots of debug logs?

@stevenscg
Copy link

@dadgar Yes. linux-64bit.

@stevenscg
Copy link

@dadgar And yes, I should be able to test a custom build. Might be late tonight/early tomorrow though.

@dadgar
Copy link
Contributor Author

dadgar commented Mar 29, 2017

@stevenscg I am hitting it now as well which is odd because I ran the same tests for the original PR. Hopefully I can just get to the bottom of this and get you a test build.

@dadgar
Copy link
Contributor Author

dadgar commented Mar 29, 2017

@stevenscg Funny why it didn't work. When I built the PR I had this as the defer:

defer func() {
  token := getToken()
  StopRenewal(token)
  log.Println("Stopping renewal of token", token)
}()

And when I was ready to submit the PR changed to:

defer StopRenewal(getToken())

Which changed when the token's value was captured and broke it! Super subtle. This #2503 fixes it and adds tests. So we should be good to go!

@dadgar
Copy link
Contributor Author

dadgar commented Mar 29, 2017

@stevenscg Let me know how it goes:
nomad.zip

@stevenscg
Copy link

@dadgar I've been running that build for hours without an issue. I am going to add some more tasks, but this looks fixed to me.

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add metadata to vault client requests
3 participants