Skip to content

Release mode processing for the route not being ready.#2948

Merged
knative-prow-robot merged 12 commits intoknative:masterfrom
vagababov:2430-release
Jan 23, 2019
Merged

Release mode processing for the route not being ready.#2948
knative-prow-robot merged 12 commits intoknative:masterfrom
vagababov:2430-release

Conversation

@vagababov
Copy link
Copy Markdown
Contributor

Fixes #2430

Proposed Changes

  • check for the route's traffic in the release mode to match the desired shape.
  • if it doesn't match -- mark service to be in Unknown state
  • Tested manually and with ITests.
  • Added unit tests for the new functionality.

When we update the service in the release mode, but the route is not yet
updated to the new version, we should mark the service to be in `Unknown` ready state.
See: knative#2430
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 19, 2019
@vagababov
Copy link
Copy Markdown
Contributor Author

/cc @mattmoor
/cc @dgerd

// This is important because the copy we loaded from the informer's
// cache may be stale and we don't want to overwrite a prior update
// to status with this stale state.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

did you mean to delete this line? If so, . on the previous line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No I did not. Probably one of those vscode vim bindings random actions.

if len(rs.Traffic) == 0 || rs.Traffic[0].RevisionName != revs[0] {
c.Logger.Debugf("%s: traffic not yet migrated to %s", s.Name, revs[0])
s.Status.MarkRouteNotYetReady()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel like there's an uncovered path through here when I go from:

revisions: ["rev1", "rev2"]
percent: 0

to:

revisions: ["rev1", "rev3"]
percent: 0

We only check that "current" matches, not that "candidate" matches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, that's why I left the comment. Since this does not affect the traffic — should it matter?
If you think it does, then it's just reorganization of code.

runLatestCheckTrafficMigrated(ss, &route.Status, &config.Status)
c.runLatestCheckTrafficMigrated(service, &route.Status, &config.Status)
case service.Spec.Release != nil:
c.releaseCheckTrafficMigrated(service, &route.Status, &config.Status)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couldn't we replace this whole switch (and both functions) with:

if rc := service.Status.GetCondition(v1alpha1.ServiceConditionRoutesReady); rc != nil && rc.Status == corev1.ConditionTrue {
   want := route.Spec.Traffic.DeepCopy()
   for idx := range want {
      if want[idx].ConfigurationName == config.Name {
         want[idx].RevisionName = config.LatestReadyConfigurationName
         want[idx].ConfigurationName = ""
      }
   }
   if got := route.Status.Traffic; !cmp.Equal(got, want) {
      s.Status.MarkRouteNotYetReady()
   }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't know. Have to think more about this. May be.

Copy link
Copy Markdown
Contributor Author

@vagababov vagababov Jan 22, 2019

Choose a reason for hiding this comment

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

As is this definitely makes old tests fail. New tests still pass.
I can try to tweak it a bit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW cmp.Equal can panic. If you go with this approach, consider: https://github.com/knative/pkg/blob/2a1c043ce3d778a4017e9c988b7a7dd0644312ad/kmp/diff.go#L53

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. Had to update other tests, since they were reflecting just part of the reality;
  2. implemented Matt's suggestion;
  3. implemented Jon's suggestion.

🍷

@vagababov
Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-go-coverage

@vagababov
Copy link
Copy Markdown
Contributor Author

PTAL>

Comment thread pkg/reconciler/v1alpha1/service/service.go Outdated
switch {
case service.Spec.RunLatest != nil:
runLatestCheckTrafficMigrated(ss, &route.Status, &config.Status)
if service.Spec.RunLatest != nil || service.Spec.Release != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think I would prefer service.Spec.Manual == nil as it is the only mode that we don't reconcile. Even though pinned is deprecated I don't think there is a strong reason to explicitly exclude it here, and checking that we are not manual enables any future modes to just work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well there's still pinned, it's deprecated, but supported.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, but it's a nop for Pinned. I think I have a mild preference for Manual != nil as well because if we were to add a new mode, this would either do the right thing or the author would have to adjust this logic for the Service to become Ready.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesn't matter at all, since we don't reconcile manual anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So we don't reconcile if we're in manual, so I removed the check altogether.

vagababov and others added 5 commits January 22, 2019 21:14
Since reconcile() is only invoked, when we're not in manual mode,
hence the type check is useless here.
Also move the DeepCopy() one word right, saving us a few microseconds.
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/service/service.go 92.0% 92.2% 0.2

@dgerd
Copy link
Copy Markdown

dgerd commented Jan 23, 2019

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2019
@mattmoor
Copy link
Copy Markdown
Member

/approve

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor, vagababov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 23, 2019
@knative-prow-robot knative-prow-robot merged commit af08456 into knative:master Jan 23, 2019
@vagababov vagababov deleted the 2430-release branch January 24, 2019 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants