goharbor / harbor-operator

Kubernetes operator for Harbor service components
Apache License 2.0
343 stars 106 forks source link

Add GenerationChangedPredicate event filter to project controller #1067

Closed ChristianLoewel closed 10 months ago

ChristianLoewel commented 11 months ago

This pull request removes the LastApplyTime status field in the HarborProject CRD.

I have noticed that updating the status field asynchronously after returning the Reconcile function seems to trigger an immediate 're-reconciliation'. As LastApplyTime gets updated every time, this results in an endless loop instead of reconciling HarborProjects only every 5 minutes as intended.

chlins commented 10 months ago

It's the way kubernetes works, the controller will receive the event when a CR changed but maybe we can retain this field as it's helpful when debug issues, how about update the strategy like add the predicate filter or do the time window check(e.g if now()-lastAppliedTime < 5min) before reconcile?

ChristianLoewel commented 10 months ago

It's the way kubernetes works, the controller will receive the event when a CR changed but maybe we can retain this field as it's helpful when debug issues, how about update the strategy like add the predicate filter or do the time window check(e.g if now()-lastAppliedTime < 5min) before reconcile?

Yeah, I totally agree with that. Will take a look at the options you mentioned.

ChristianLoewel commented 10 months ago

@chlins I've used the GenerationChangedPredicate event filter to only reconcile when the generation field changed, so all status changes will be excluded.