fix(BRE2-766): Backoff on ssh Attempt During Registration#307
Merged
fix(BRE2-766): Backoff on ssh Attempt During Registration#307
Conversation
There was a problem hiding this comment.
Pull request overview
Adds exponential backoff retry behavior when enabling SSH access during device registration, and refines authorized_keys handling to avoid unnecessary writes.
Changes:
- Retry
GrantSSHAccessToNodeusing exponential backoff rather than a single fixed-delay retry. - Adjust
InstallAuthorizedKeyto return whether it wrote a new entry, and suppress duplicate “added” messaging. - Add
github.com/cenkalti/backoff/v4dependency and update tests for the newInstallAuthorizedKeysignature.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/register/sshkeys.go | Adds transient/permanent error branching for rollback behavior; changes InstallAuthorizedKey to return (bool, error). |
| pkg/cmd/register/register.go | Replaces single retry with exponential backoff retry and adds backoff configuration helpers/constants. |
| pkg/cmd/enablessh/enablessh_test.go | Updates tests to match the new InstallAuthorizedKey return signature. |
| go.mod | Adds backoff dependency. |
| go.sum | Adds backoff checksums. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
drewmalin
commented
Mar 4, 2026
Comment on lines
+50
to
52
| } else if added { | ||
| t.Vprint(" Brev public key added to authorized_keys.") | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Mainly so that we don't keep (incorrectly) printing that we added keys -- InstallAuthorizedKey already no-ops if it can.
drewmalin
commented
Mar 4, 2026
Comment on lines
-45
to
-53
| _, err := client.GrantNodeSSHAccess(ctx, connect.NewRequest(&nodev1.GrantNodeSSHAccessRequest{ | ||
| ExternalNodeId: reg.ExternalNodeID, | ||
| UserId: targetUser.ID, | ||
| LinuxUser: osUser.Username, | ||
| })) | ||
| if err != nil { | ||
| if targetUser.PublicKey != "" { | ||
| if rerr := RemoveAuthorizedKey(osUser, targetUser.PublicKey); rerr != nil { | ||
| t.Vprintf(" %s\n", t.Yellow(fmt.Sprintf("Warning: failed to remove SSH key after failed grant: %v", rerr))) |
Contributor
Author
There was a problem hiding this comment.
Main change here -- wrap this logic in a backoff. This function is the one called by register, enable ssh, and grant ssh.
patelspratik
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example output for inline enable (during register):
Example output during explicit enable-ssh (post register):