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

validator: use ingress validator with dataclient #2757

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

MustafaSaber
Copy link
Member

Relates to #1618

IngressValidator was introduced in #2493 while we still validate inside skipper with some functions that will only drop the annotation but Ingress will still pass and work for example https://github.com/zalando/skipper/blob/master/dataclients/kubernetes/ingress.go#L257C1-L269C2 which will drop the annotation only if parsing fail.

This PR should fix this and at least drop the Ingress resource if validation for skipper annotations fail.

@MustafaSaber MustafaSaber self-assigned this Nov 28, 2023
ingressValidator := &definitions.IngressV1Validator{}
if err := ingressValidator.Validate(i); err != nil {
logger.Errorf("Ingress validation failed: %v", err)
return nil, nil // Drop the resource without failing LoadAll
Copy link
Member Author

Choose a reason for hiding this comment

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

If we returned and error here LoadAll will fail which doesn't make sense, so either move on with this or think of another solution.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can reduce message to logger.Errorf("Validation failed: %v", err) because this logger has ingress context.

Also I am not sure why we create ingressValidator for each ingressV1Route call, I think we should make it a field of ing *ingress.

@MustafaSaber
Copy link
Member Author

@MustafaSaber MustafaSaber changed the title Use ingress validator with dataclient validator: use ingress validator with dataclient Nov 29, 2023
@MustafaSaber MustafaSaber marked this pull request as ready for review November 29, 2023 13:33
@MustafaSaber MustafaSaber added the major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs label Dec 5, 2023
@AlexanderYastrebov
Copy link
Member

Please rebase

Signed-off-by: Mustafa Abdelrahman <mustafa.abdelrahman@zalando.de>
@MustafaSaber MustafaSaber force-pushed the use-ingress-validator-in-skipper branch from e644392 to 7121f32 Compare January 24, 2024 13:17
@MustafaSaber
Copy link
Member Author

This is safe to merge according to our reports.

@AlexanderYastrebov
Copy link
Member

👍

1 similar comment
@MustafaSaber
Copy link
Member Author

👍

@MustafaSaber MustafaSaber merged commit d3f0322 into master Jan 24, 2024
14 checks passed
@MustafaSaber MustafaSaber deleted the use-ingress-validator-in-skipper branch January 24, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants