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

Update SSH keys via MCD #115

Merged

Conversation

kikisdeliveryservice
Copy link
Contributor

@kikisdeliveryservice kikisdeliveryservice commented Oct 5, 2018

Allow MCD to update SSH Keys.

We are only allowing one user named "core" and only updating the field SSHAuthorizedKeys for this user.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 5, 2018
@kikisdeliveryservice
Copy link
Contributor Author

/assign @ashcrow

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 5, 2018
Copy link
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

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

The logic looks sound! Some nits and recommendations but nothing that is blocking. Good work!

break
}
}
// length of Users is different, we don't do those kinds of changes, so nope.
Copy link
Member

Choose a reason for hiding this comment

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

I'm stuck between an attempted addition of a new user should noop (as it's doing here) or if we should raise the irreconcilable flag as the user was attempting to do something we are not going to do. @sdemos thoughts?

pkg/daemon/update.go Outdated Show resolved Hide resolved
pkg/daemon/update.go Outdated Show resolved Hide resolved
pkg/daemon/update.go Outdated Show resolved Hide resolved
// ssh keys are in PasswdUser.HomeDir/.ssh
path = filepath.Join(oldUsers[idx].HomeDir, ".ssh")
glog.V(2).Infof("Writing SSHKeys at %q:", path)
// write the SSHKeys
Copy link
Member

Choose a reason for hiding this comment

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

👍

glog.V(2).Infof("Writing SSHKeys at %q:", path)
// write the SSHKeys
} else {
return fmt.Errorf("Failed to write SSHKeys")
Copy link
Member

Choose a reason for hiding this comment

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

Once the ssh key writing is added I recommend returning the error that is bubbled up from that work OR adding a log statement with details before this return

@kikisdeliveryservice
Copy link
Contributor Author

Thanks @ashcrow for your thoughts! I'll incorporate them into the PR. 😺

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 8, 2018
@smarterclayton
Copy link
Contributor

/test e2e-aws

@ericavonb
Copy link
Contributor

/cc @openshift/sig-security

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 10, 2018
@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/retest

@kikisdeliveryservice
Copy link
Contributor Author

Passed manual testing, only changes made since last review:

  • removed some of my logging that was added for testing
  • added additional comments for clarity
  • squashed commits

@cgwalters
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 10, 2019
Copy link
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

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

LGTM. I ask one more person do a review before we merge (for two sets of eyes).

msg := "Ignition passwd user section contains unsupported changes"
} else if len(oldIgn.Passwd.Users) > 0 && len(newIgn.Passwd.Users) >= 1 {
for _, user := range newIgn.Passwd.Users {
if user.Name != "core" {
Copy link
Member

Choose a reason for hiding this comment

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

Short explanation: the way Ignition works the newUsers array is actually the compilation of all the Users from all of the machineconfigs in oc get machineconfigs.

I spoke with @kikisdeliveryservice and this is a well known issue with the current ignition. She is going to write up some doc text around this as well.

msg := "Ignition passwd user section contains unsupported changes"
} else if len(oldIgn.Passwd.Users) > 0 && len(newIgn.Passwd.Users) >= 1 {
for _, user := range newIgn.Passwd.Users {
if user.Name != "core" {
Copy link
Member

Choose a reason for hiding this comment

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

/cc @dustymabe, @ajeddeloh, and @darkmuggle just for visibility

@@ -233,6 +244,29 @@ func (dn *Daemon) reconcilable(oldConfig, newConfig *mcfgv1.MachineConfig) *stri
return nil
}

// verifyUserFields returns nil if the user Name = "core", if 1 or more SSHKeys exist for
Copy link
Member

Choose a reason for hiding this comment

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

Thank you!

@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/retest

@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

Looks like @cgwalters reviewed at the same time.

/lgtm

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashcrow, cgwalters

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

Infra failure flake

could not wait for build: the build machine-config-controller failed with reason PullBuilderImageFailed: Failed pulling builder image

@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/test images

1 similar comment
@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/test images

@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/retest

@sjenning
Copy link
Contributor

sjenning commented Jan 10, 2019

We are hitting the same image build failures in #249

Something is up with the registry in api.ci

@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/retest

2 similar comments
@ashcrow
Copy link
Member

ashcrow commented Jan 10, 2019

/retest

@kikisdeliveryservice
Copy link
Contributor Author

/retest

@kikisdeliveryservice
Copy link
Contributor Author

/retest

3 similar comments
@kikisdeliveryservice
Copy link
Contributor Author

/retest

@kikisdeliveryservice
Copy link
Contributor Author

/retest

@kikisdeliveryservice
Copy link
Contributor Author

/retest

@kikisdeliveryservice
Copy link
Contributor Author

/test e2e-aws

@kikisdeliveryservice
Copy link
Contributor Author

My tests finally all passed and now they are rerunning. ☹️

@openshift-merge-robot openshift-merge-robot merged commit 0cd475c into openshift:master Jan 11, 2019
@ashcrow
Copy link
Member

ashcrow commented Jan 11, 2019

CI MERGED! 🎉

osherdp pushed a commit to osherdp/machine-config-operator that referenced this pull request Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.