-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Improve parsing of annotations and use of Ingress wrapper #3474
Conversation
e2517c0
to
08ace5a
Compare
08ace5a
to
17f99ab
Compare
// IngressAnnotationsLister makes a Store that lists annotations in Ingress rules. | ||
type IngressAnnotationsLister struct { | ||
// IngressWithAnnotationsLister makes a Store that lists Ingress rules with annotations already parsed | ||
type IngressWithAnnotationsLister struct { | ||
cache.Store | ||
} | ||
|
||
// ByKey returns the Ingress annotations matching key in the local Ingress annotations Store. |
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.
can you adjust this comment as well
Why are you making all those |
17f99ab
to
36d19f2
Compare
Consistency in the parsing method and also simplify the validations to set the defaults
The change in #3437 is not enough because at the end we are still joining the ingress and annotations when we build the model. The change here ensures we only extract the annotations when there's an event and we always use a single store, without any logic to get the ingresses |
37d992f
to
8cefb74
Compare
|
664a1d9
to
f8ae100
Compare
var ingresses []*ingress.Ingress | ||
for _, item := range s.listers.Ingress.List() { | ||
ing := item.(*extensions.Ingress) | ||
if !class.IsValid(ing) { |
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.
How's this case handled now? I don't see this function being used in new changes.
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.
hmm looks like this is being handled in ingress event handlers and this was redundant
@@ -597,9 +594,26 @@ func (s *k8sStore) extractAnnotations(ing *extensions.Ingress) { | |||
key := k8s.MetaNamespaceKey(ing) |
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.
The comment seems to be outdated - it does not describe what the function does.
Also should we call this function syncIngress
now?
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.
done
@@ -39,24 +39,24 @@ func TestParse(t *testing.T) { | |||
|
|||
testCases := []struct { | |||
annotations map[string]string | |||
expected Config |
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 are you switching this to pointer?
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.
fixed
} | ||
|
||
pb, err := parser.GetStringAnnotation("proxy-buffering", ing) | ||
if err != nil || pb == "" { |
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 did you change all these to not check for == ""
?
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.
I just added a new commit that avoids empty annotations
i, exists, err := il.GetByKey(key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if !exists { | ||
return nil, NotExistsError(key) | ||
} | ||
return i.(*annotations.Ingress), nil |
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.
Is annotations.Ingress
being used anywhere after this PR?
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.
Only in the Ingress struct (ParsedAnnotations *annotations.Ingress
)
@@ -132,13 +129,13 @@ type Informer struct { | |||
|
|||
// Lister contains object listers (stores). | |||
type Lister struct { | |||
Ingress IngressLister |
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 do we still need this?
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.
We cannot get rid of this because the informer still needs this type.
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.
Does this mean we will be storing extensions.Ingress objects in both here and IngressWithAnnotation
? That sounds like unnecessary duplication.
I'm not too familiar with how k8s go client works, but it does not make sense to not be able to configure informer without storing the objects. We should not need IngressLister, since all the ingress objects are already going to be stored in IngressWithAnnotation
.
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.
Does this mean we will be storing extensions.Ingress objects in both here and IngressWithAnnotation? That sounds like unnecessary duplication.
I know but there is no way to have a custom type (IngressWithAnnotation) in the informer.
I'm not too familiar with how k8s go client works, but it does not make sense to not be able to configure informer without storing the objects
You need to use a store to be able to handle deltas.
7b205a8
to
733f9a7
Compare
733f9a7
to
497246f
Compare
/lgtm https://github.com/kubernetes/ingress-nginx/pull/3474/files#r239025364 can be addressed later if it's an actual concern. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf, ElvinEfendi 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 |
How's this PR fixing #3489? |
What this PR does / why we need it:
Continues the work started in #3437 and introduce a new local store that contains the original Ingress and the parsed annotations.
Which issue this PR fixes:
fixes #2494
fixes #3473
fixes #3468
fixes #3489