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

Ensure ingress host matches route host #8151

Merged
merged 1 commit into from Mar 23, 2016

Conversation

marun
Copy link
Contributor

@marun marun commented Mar 19, 2016

The router status plugin compares ingress timestamps with cached
values to detect conflict with other router instances, and was falsely
detecting conflict when values with nanosecond accuracy were compared
to the same values that had been serialized to and from etcd in
RFC3339 format (accurate to the second). The result of a conflict was
that an update to the host of a route would not be reflected in the
route's ingress record.

This change enures that ingress timestamps are truncated to the second
to ensure safe comparison between in-memory and serialized timestamps.

@marun
Copy link
Contributor Author

marun commented Mar 19, 2016

cc: @smarterclayton @openshift/networking

@marun
Copy link
Contributor Author

marun commented Mar 19, 2016

[test]

p := &fakePlugin{}
c := testclient.NewSimpleFake(&routeapi.Route{})
admitter := NewStatusAdmitter(p, c, "test")
err := admitter.HandleRoute(watch.Added, &routeapi.Route{

route := routeapi.Route{
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't really testing the same thing, please preserve the old test as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@marun
Copy link
Contributor Author

marun commented Mar 19, 2016

Latest patch fixes the test failures (at least locally). I didn't understand how nowFn was being used in the tests.

if action.GetVerb() != "update" || action.GetResource() != "routes" || action.GetSubresource() != "status" {
t.Fatalf("unexpected action: %#v", action)
}
obj1 := c.Actions()[0].(ktestclient.UpdateAction).GetObject().(*routeapi.Route)
Copy link
Contributor

Choose a reason for hiding this comment

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

s#c.Actions()[0]#action#

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you please explain?

Copy link
Contributor

Choose a reason for hiding this comment

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

You have defined action in L450, you can use that instead of accessing via the method again.

@marun
Copy link
Contributor Author

marun commented Mar 19, 2016

I've removed the new test since the other tests are already validating the requirement for RFC3339 timestamps.

@marun
Copy link
Contributor Author

marun commented Mar 21, 2016

cc: @ramr

// Return a time truncated to the second to ensure that in-memory and
// serialized timestamps can be safely compared.
func getRFC3339Timestamp() unversioned.Time {
return unversioned.Time{Time: unversioned.Now().Truncate(time.Second)}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an api call available called Rfc3339Copy which returns time at the second level precision - that should work here, no?
Basically: return unversioned.Now().Rfc3339Copy()
Ref: https://github.com/kubernetes/kubernetes/blob/master/pkg/api/unversioned/time.go#L76

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

The router status plugin compares ingress timestamps with cached
values to detect conflict with other router instances, and was falsely
detecting conflict when values with nanosecond accuracy were compared
to the same values that had been serialized to and from etcd in
RFC3339 format (accurate to the second).  The result of a conflict was
that an update to the host of a route would not be reflected in the
route's ingress record.

This change ensures that ingress timestamps are truncated to the second
to ensure safe comparison between in-memory and serialized timestamps.
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 923a155

@smarterclayton
Copy link
Contributor

LGTM [merge], thanks for catching this

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/2442/) (Image: devenv-rhel7_3805)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 923a155

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/2442/)

@openshift-bot openshift-bot merged commit 7de0f2a into openshift:master Mar 23, 2016
@marun marun deleted the bz/1317835 branch April 19, 2016 15:57
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.

None yet

5 participants