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

🌱 [WIP] Runtimesdk/validate handlers on discovery #28

Conversation

killianmuldoon
Copy link

Signed-off-by: killianmuldoon [email protected]

Add first round of validation rules on discovery of extensions in the extension controller.

@@ -197,14 +200,59 @@ func (r Reconciler) discoverExtension(ctx context.Context, extension *runtimev1.
// if any of these checks fails the response is invalid and an error is returned. Extensions with previously valid
// RuntimeExtension registrations are not removed from the registry or the object's status.
func validateRuntimeExtensionDiscovery(ext *runtimev1.Extension) error {
names := make(map[string]bool)
var errs []error
// TODO: Implement the same validation rules in the runtime SDK server side Discovery handler.
for _, runtimeExtension := range ext.Status.RuntimeExtensions {

Choose a reason for hiding this comment

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

How about also adding a validation rule to make sure that the hook is valid?

}

// Timeout should be a positive integer and should be under 600 seconds (10 minutes)
if *runtimeExtension.TimeoutSeconds < 0 && *runtimeExtension.TimeoutSeconds > 600 {

Choose a reason for hiding this comment

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

10 minutes for maximum timeout seems too long. The admission webhooks in k8s allow a maximum timeout of 30s.
How about using the same for our maximum as well?

// FIXME: How should we handle timeout is nil or zero?
// If TimeoutSeconds is not defined set to zero.
if runtimeExtension.TimeoutSeconds == nil {
runtimeExtension.TimeoutSeconds = pointer.Int32(0)

Choose a reason for hiding this comment

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

A 0s timeout means if the user does not set a timeout the network call will always timeout. The admission webhooks in k8s default to a timeout of 10s. We should also probably use the same timeout as default.

@killianmuldoon
Copy link
Author

Closing in favor of #kubernetes-sigs#6578

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.

4 participants