-
Notifications
You must be signed in to change notification settings - Fork 155
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
Validating ssh key agent deployment #6443
Conversation
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
pkg/validation/cluster/handler.go
Outdated
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)) | ||
} |
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.
Why is this a dedicated function and not part of the existing validateCreateOrUpdate
?
pkg/validation/cluster/handler.go
Outdated
@@ -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 { |
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.
This not just rejects Enablements, but also Disablements. The function could maybe be called rejectUserSSHKeyAgentChanges
?
pkg/validation/cluster/handler.go
Outdated
func (h *AdmissionHandler) rejectEnableUserSSHKeyAgentUpdate(ctx context.Context, cluster *kubermaticv1.Cluster) error { | ||
var ( | ||
oldCluster = &kubermaticv1.Cluster{} | ||
nName = types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace} |
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.
Clusters are non-namespaced, do not specifiy a namespace here in the key.
}{ | ||
{ | ||
name: "delete cluster succeess", | ||
name: "Delete cluster succeess", |
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.
If you change the capitalization, you can also fix the typo in `succeess' ;-)
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.
A few comments
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
/test pre-kubermatic-etcd-launcher-e2e |
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.
/approve
LGTM label has been added. Git tree hash: 351c36b0aef0a0c15868a272a86e7d03117f0973
|
[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 |
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?: