Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@stevesloka
Copy link
Member

@stevesloka stevesloka commented Oct 5, 2020

Change how the comparison of the status of the object of HTTPProxy objects by
ignoring the LastTransitionTime which is always updates on each DAG rebuild
regardless if the status of object changed or not.

Not ignoring this causes each status to be updated each time since the objects
are always different for each DAG rebuild.

Fixes #2979

Signed-off-by: Steve Sloka [email protected]

@stevesloka stevesloka added this to the 1.9.0 milestone Oct 5, 2020
@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #2986 into main will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2986   +/-   ##
=======================================
  Coverage   75.03%   75.04%           
=======================================
  Files          90       90           
  Lines        5869     5871    +2     
=======================================
+ Hits         4404     4406    +2     
  Misses       1371     1371           
  Partials       94       94           
Impacted Files Coverage Δ
internal/k8s/helpers.go 91.66% <100.00%> (+1.66%) ⬆️

@jpeach
Copy link
Contributor

jpeach commented Oct 5, 2020

FYI this tags the wrong issue

…equal check

Change how the comparison of the status of the object of HTTPProxy objects by
ignoring the LastTransitionTime which is always updates on each DAG rebuild
regardless if the status of object changed or not.

Not ignoring this causes each status to be updated each time since the objects
are always different for each DAG rebuild.

Fixes projectcontour#2979

Signed-off-by: Steve Sloka <[email protected]>
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM. I don't know if there was a particular reason for using the equality package to do the equality compare previously, but we use cmp.Equal in the Contour handler for doing equality of API objects, and the tests pass, so I don't see an issue with changing it.

@skriss skriss requested a review from jpeach October 5, 2020 20:57
Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

This reverts the switch to Kubernetes semantic equality from #2853

I think that a better fix might be to add the v1.DetailedCondition type to the equality funcs that we use for this comparison. That retains the special handling that api-machinery has for existing Kubernetes types.

var equalities = conversion.Equalities{equality.Semantic}

equalities.AddFunc(func(a, b contourv1.DetailedCondition) bool{
        ...
})

@jpeach
Copy link
Contributor

jpeach commented Oct 5, 2020

This reverts the switch to Kubernetes semantic equality from #2853

I think that a better fix might be to add the v1.DetailedCondition type to the equality funcs that we use for this comparison. That retains the special handling that api-machinery has for existing Kubernetes types.

var equalities = conversion.Equalities{equality.Semantic}

equalities.AddFunc(func(a, b contourv1.DetailedCondition) bool{
        ...
})

That said, I don't see any practical issues with landing this and following up.

@stevesloka
Copy link
Member Author

But will adding the type still skip that field? That's the goal here, and why we went with cmp which is used in other places.

@jpeach
Copy link
Contributor

jpeach commented Oct 5, 2020

But will adding the type still skip that field? That's the goal here, and why we went with cmp which is used in other places.

Looking at the way the interfaces work, you would add your own comparator that skips or flattens the relevant fields (e.g. the time comparison is flattened to UTC). cmp doesn't do the same thing as semantic equality AFAICT; trade-offs in both directions.

@mattmoor
Copy link
Contributor

mattmoor commented Oct 5, 2020

FWIW in Knative we define a VolatileTime type, which we exclude from semantic equality, which we use exclusively (I think) for LastTransitionTime.

@mattmoor
Copy link
Contributor

mattmoor commented Oct 5, 2020

@skriss
Copy link
Member

skriss commented Oct 6, 2020

We also have https://github.com/projectcontour/contour/blob/main/internal/contour/handler.go#L179-L183 which would need a custom comparer if we want to migrate that to equality.Semantic.DeepEqual.

@stevesloka do you want to merge this as-is for now (@jpeach was OK with that too) and do a follow-up to fully switch compare libraries?

@stevesloka
Copy link
Member Author

@skriss let's just land this as-is. I think we should chat about how to best approach the solution. I like Knavtive's approach that @mattmoor linked, it removes the extra need to understand that this field is different for other comparisons, but should chat about this a bit before making that change.

@stevesloka stevesloka merged commit c87f589 into projectcontour:main Oct 6, 2020
@stevesloka stevesloka deleted the fixDelayedUpdate branch October 6, 2020 17:43
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.

Status updates are delayed with 100 proxies

4 participants