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

Ssh key #788

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Ssh key #788

wants to merge 1 commit into from

Conversation

dirien
Copy link

@dirien dirien commented Sep 12, 2024

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 #

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dirien
Once this PR has been reviewed and has the lgtm label, please assign fabriziopandini for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @dirien!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-packet 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-packet has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

Copy link

linux-foundation-easycla bot commented Sep 12, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 12, 2024
Copy link
Member

@displague displague left a 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.

}
}

/*
Copy link
Member

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 {
Copy link
Member

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())),
Copy link
Member

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).

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants