-
Notifications
You must be signed in to change notification settings - Fork 41
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
Ssh key #788
base: main
Are you sure you want to change the base?
Ssh key #788
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dirien The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @dirien! |
The committers listed above are authorized under a signed CLA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @dirien!
You are correct that if there are no SSH keys associated with a project or user a 422 will be returned in response to a device creation request, unless either SSH keys are provided in the request (as you are adding here) or no_ssh_keys is provided. The latter is useful when deploying in private or Layer-2 modes with operating systems that do not come SSH-ready or will not be accessed publicly.
Generally, the DeviceCreateIn*Request changes look good, according to https://deploy.equinix.com/developers/api/metal/#tag/Devices/operation/createDevice.
I left some comments on the request's particulars.
} | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the unused code
@@ -180,6 +180,26 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal | |||
|
|||
serverCreateOpts := metal.CreateDeviceRequest{} | |||
|
|||
var sshKeyInput []metal.SSHKeyInput | |||
if len(packetMachineSpec.SSHKeys) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave out the if
conditional. The for loop will only append sshKeyInput if SSHKeys exist (and are >0).
Likewise, if the SSHKeys are nil or 0, sshKeyInput will be nil when sent to the Request object.
if len(packetMachineSpec.SSHKeys) > 0 { | ||
for _, key := range packetMachineSpec.SSHKeys { | ||
sshKeyInput = append(sshKeyInput, metal.SSHKeyInput{ | ||
Label: metal.PtrString(fmt.Sprintf("cluster-api-provider-packet-%s", req.MachineScope.Name())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All SSHKeys will have the same label per machine. Should we use a tag for the repeated values and a unique value per label? I'm pretty sure labels are optional. If we can't find a meaningful unique label, we could omit them. The tag would tell us what we need to know about the SSHKey. If Label is required, perhaps it could suffix the label you've provided with some tail bytes of the SSH Key? (not the comment section of the key).
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
What this PR does / why we need it:
Creation of virtual machines on equinix failed with "422 Unprocessable Entity Error" due to the missing of on ssh key. This is now fixed with this PR.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #