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

Validating ssh key agent deployment #6443

Conversation

moadqassem
Copy link
Member

What this PR does / why we need it:
Adding validation for user ssh key agent enabling. The user ssh key agent can be enabled/disabled only during the creation of the user cluster, once the cluster is created, the agent status cannot be changed.

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 #6429

Does this PR introduce a user-facing change?:

Disabling/Enabling User SSH Key agent 

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
@kubermatic-bot kubermatic-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 22, 2021
Comment on lines 83 to 86
if err := h.rejectEnableUserSSHKeyAgentUpdate(ctx, cluster); err != nil {
h.log.Info("cluster admission failed", "error", err)
return webhook.Denied(fmt.Sprintf("cluster validation request %s rejected: %v", req.UID, err))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a dedicated function and not part of the existing validateCreateOrUpdate?

@@ -95,3 +107,26 @@ func (h *AdmissionHandler) validateCreateOrUpdate(c *kubermaticv1.Cluster) error
func (h *AdmissionHandler) SetupWebhookWithManager(mgr ctrl.Manager) {
mgr.GetWebhookServer().Register("/validate-kubermatic-k8s-io-cluster", &webhook.Admission{Handler: h})
}

func (h *AdmissionHandler) rejectEnableUserSSHKeyAgentUpdate(ctx context.Context, cluster *kubermaticv1.Cluster) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

This not just rejects Enablements, but also Disablements. The function could maybe be called rejectUserSSHKeyAgentChanges?

func (h *AdmissionHandler) rejectEnableUserSSHKeyAgentUpdate(ctx context.Context, cluster *kubermaticv1.Cluster) error {
var (
oldCluster = &kubermaticv1.Cluster{}
nName = types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace}
Copy link
Contributor

Choose a reason for hiding this comment

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

Clusters are non-namespaced, do not specifiy a namespace here in the key.

}{
{
name: "delete cluster succeess",
name: "Delete cluster succeess",
Copy link
Contributor

Choose a reason for hiding this comment

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

If you change the capitalization, you can also fix the typo in `succeess' ;-)

Copy link
Contributor

@xrstf xrstf left a comment

Choose a reason for hiding this comment

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

A few comments

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
@moadqassem
Copy link
Member Author

/test pre-kubermatic-etcd-launcher-e2e

Copy link
Contributor

@xrstf xrstf left a comment

Choose a reason for hiding this comment

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

/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 22, 2021
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 351c36b0aef0a0c15868a272a86e7d03117f0973

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: moadqassem, xrstf

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

@kubermatic-bot kubermatic-bot merged commit bec9856 into kubermatic:master Jan 22, 2021
@moadqassem moadqassem deleted the validating-ssh-key-agent-deployment branch March 22, 2022 16:00
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. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Reject enabling/disabling the user ssh key agent on a running cluster
3 participants