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

DEVPROD-4798 Remove old SSH Key #7713

Merged
merged 9 commits into from
Apr 16, 2024

Conversation

ybrill
Copy link
Contributor

@ybrill ybrill commented Apr 5, 2024

DEVPROD-4798

Description

Once upon a time there was a map of ssh keys that were supposedly present on the app servers and each distro had a setting that configured which ssh key to use for that distro. In practice, there's only a single ssh key that we use for every distro.

This PR removes references to the old ssh key and the distro ssh key. All SSHing will use the key path that's set for the Kanopy ssh key.

Testing

I'll make sure we can still SSH in staging when I can get the lock.

@ybrill
Copy link
Contributor Author

ybrill commented Apr 8, 2024

Pairs nicely with evergreen-ci/ui#41

@khelif96 khelif96 requested a review from a team April 9, 2024 04:52
Copy link
Contributor

@khelif96 khelif96 left a comment

Choose a reason for hiding this comment

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

There are a few steps in order to safely remove these fields from the UI. I tried to break it down as best as I could but feel free to reach out if it doesn't make sense.

@@ -138,7 +138,6 @@ input DistroInput {
providerSettingsList: [Map!]!
setup: String!
setupAsSudo: Boolean!
sshKey: String!
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is set as a required field on a mutation input in order to safely deploy this we would need to split this pr up into multiple parts and deploys.

  1. This would need to be set to optional (Remove the ! and add/remove any necessary logic needed to safely handle the field not always being there) (Also add a @deprecated directive to the field.)
  2. Merge and deploy just this change.
  3. Update the UI pr to no longer rely on this field and the corresponding sshKey field below
  4. Merge and deploy the UI changes.
  5. Finally remove this field and the other field below.
  6. Merge and deploy this pr.

@@ -287,7 +286,6 @@ type Distro {
providerSettingsList: [Map!]!
setup: String!
setupAsSudo: Boolean!
sshKey: String!
Copy link
Contributor

Choose a reason for hiding this comment

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

This field would not be removable until step 5 from above

@@ -9,7 +9,6 @@ type SpruceConfig {
containerPools: ContainerPoolsConfig
githubOrgs: [String!]!
jira: JiraConfig
keys: [SSHKey!]!
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above this is not removable until step 5 from above. The UI should no longer rely on this at that point.

@ybrill
Copy link
Contributor Author

ybrill commented Apr 9, 2024

Thank you for the clear explanation @khelif96!
I opened #7725 for step 1.

Jira JiraConfig `yaml:"jira" bson:"jira" json:"jira" id:"jira"`
JIRANotifications JIRANotificationsConfig `yaml:"jira_notifications" json:"jira_notifications" bson:"jira_notifications" id:"jira_notifications"`
Keys map[string]string `yaml:"keys" bson:"keys" json:"keys"`
// TODO (DEVPROD-4798): remove KanopySSHKeyPath after the cutover to Kanopy.
Copy link
Contributor

Choose a reason for hiding this comment

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

do we not want to remove KanopySSHKeyPath anymore, re this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The approach of this PR is to remove the old Keys map instead of removing the new KanopySSHKeyPath. The thinking is that the distros all use the same key (they always have and will continue to use the same key for the foreseeable future), so the Keys map and corresponding distro setting was just extra complexity.

We could potentially rename KanopySSHKeyPath to SSHKeyPath if we want to.

@ybrill
Copy link
Contributor Author

ybrill commented Apr 10, 2024

After the Spruce deploy tomorrow we'll be up to step 5 (of these steps)! 🥳

@ybrill ybrill requested review from khelif96 and ablack12 April 10, 2024 22:35
Copy link
Contributor

@khelif96 khelif96 left a comment

Choose a reason for hiding this comment

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

Graphql changes LGTM!

Copy link
Contributor

@ablack12 ablack12 left a comment

Choose a reason for hiding this comment

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

🚀

config.go Outdated
for _, key := range c.Keys {
catcher.ErrorfWhen(c.SSHKeyPairs[i].PrivatePath(c) == key, "cannot overwrite the legacy SSH key '%s'", key)
}
catcher.ErrorfWhen(c.SSHKeyPairs[i].PrivatePath(c) == c.KanopySSHKeyPath, "cannot overwrite the legacy SSH key '%s'", c.KanopySSHKeyPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: key path ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ybrill
Copy link
Contributor Author

ybrill commented Apr 16, 2024

Verified that SSH is working on staging (by adding a public key)

@ybrill ybrill merged commit 330831b into evergreen-ci:main Apr 16, 2024
6 of 8 checks passed
@ybrill ybrill deleted the DEVPROD-4798_ssh_key_2 branch April 16, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants