-
Notifications
You must be signed in to change notification settings - Fork 95
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
Infoblox, heavy load fixed #312
Conversation
result, err = r.ensureIngress(gslb, ingress) | ||
if result != nil { | ||
return *result, err | ||
err = r.saveIngress(gslb, ingress) |
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.
Just in case the ensureIngress
naming was inherited from official operator-sdk quickstart tutorial. Obviously no strong opinion here :)
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.
Nice work! It should help to reduce load on edgeDNS providers in general, not only Infoblox.
lgtm, just few comments from me.
7f5ee78
to
276d63b
Compare
276d63b
to
c818962
Compare
controllers/ingress.go
Outdated
return nil | ||
} | ||
|
||
func ingressCompare(found *v1beta1.Ingress, i *v1beta1.Ingress) bool { |
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.
Consider renaming
func ingressCompare(found *v1beta1.Ingress, i *v1beta1.Ingress) bool { | |
func ingressEqual(ing1 *v1beta1.Ingress, ing2 *v1beta1.Ingress) bool { |
as we're testing for equality, not comparing entities.
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.
Just thinking about new package k8gb/metav1
next to the k8gb/utils
package and reuse ApiMachinery
https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#SetMetaDataAnnotation but in k8gb
Having metav1.AnnotationsEqual(obj1 *ObjectMeta, obj2 *ObjectMeta)
, metav1.MergeAnnotations(obj1 *ObjectMeta, obj2 *ObjectMeta)
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.
Then we can reuse for any kind. (Maybe move to AbsaOSS/gopkg)
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.
Like here https://github.com/AbsaOSS/k8gb/pull/314 ?
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.
@somaritane yes
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.
Might be good in general along with reusing helpers from https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1.
I don't have strong opinion here, perhaps we can extract it later when we find more use in other projects.
@ytsarev, @k0da, wdyt?
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.
Good idea, though I wouldn't block this specific PR with it. We should log the Issue for that though
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.
ok, will provide in later.
76df0b2
to
45399d3
Compare
45399d3
to
a683b0d
Compare
Rancher includes annotation into Ingress object. ```json "field.cattle.io/publicEndpoints": "[{\"addresses\":[\"22.240.40.188\"],\"port\":80,\"protocol\":\"HTTP\",\"serviceName\":\"test-gslb:frontend-podinfo\",\"ingressName\":\"test-gslb:test-gslb-failover\",\"hostname\":\"failover.k8gb-test-nonprod.bcp.absa.co.za\",\"path\":\"/\",\"allNodes\":true}]", ``` Original code modified ingress object back into desired state, but when reconciliation ended, rancher included new annotation again. As result was annotation included, removed, included , removed etc... Such behavior leds to executing reconciliation loop immediatelly instead of specified delay (RECONCILE_REQUEUE_SECONDS). - fix reconciliation issue - rename function ensureIngres -> saveIngress - ReconcileResultHandler - instead of `return ctrl.Result{},err` we call `r.RequeueError(err)`,`r.Requeue()` etc.. - Some functions returned `(*ctrl.Result, error)` but they shouldn't be responsible for reconciliation results. Now they return only `error` and only `gslb_controller` is responsible for Reconciliation (decide on the form of `ctrl.Reconciliation` object).
a683b0d
to
9c56098
Compare
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.
lgtm!
Rancher includes annotation into Ingress object.
Original code modified ingress object back into desired state, but when reconciliation ended, rancher included new annotation again.
As result was annotation included, removed, included, removed, etc...
Such behavior led to executing reconciliation loop immediately instead of specified delay (RECONCILE_REQUEUE_SECONDS).
fix reconciliation issue (see
ingress.go
changes)rename function
ensureIngres
->saveIngress
ReconcileResultHandler
return ctrl.Result{},err
we callreturn r.RequeueError(err)
,return r.Requeue()
etc..Some functions like
saveIngress
,SaveEndpoint
returned(*ctrl.Result, error)
as result, but they shouldn't be responsible for reconciliation status.Now they return only
error
and onlygslb_controller
handles Reconciliation.