Skip to content

Move revision condition manipulation to _types.go#1118

Merged
google-prow-robot merged 5 commits intoknative:masterfrom
mattmoor:revision-conditions
Jun 11, 2018
Merged

Move revision condition manipulation to _types.go#1118
google-prow-robot merged 5 commits intoknative:masterfrom
mattmoor:revision-conditions

Conversation

@mattmoor
Copy link
Copy Markdown
Member

@mattmoor mattmoor commented Jun 8, 2018

This is the Revision equivalent of #1113

This contains two other unrelated changes:

  1. Condense the object construction in revision_test.go
  2. Reorder the helloworld yaml to create the configuration first.

The reason for the second "unrelated" change is that I was seeing the route controller marking the Route as "AllTrafficAssigned = False" because the configuration wasn't created yet.

@google-prow-robot google-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 8, 2018
@mattmoor mattmoor changed the title Move revision condition manipulation to _types.go [WIP] Move revision condition manipulation to _types.go Jun 8, 2018
@google-prow-robot google-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 8, 2018
@mattmoor
Copy link
Copy Markdown
Member Author

mattmoor commented Jun 8, 2018

Oh, this also makes setCondition private on these types, which means population of Ready should be fully managed auto-magically. I am changing this to [WIP] because I'd like to add unit test coverage for all of the condition manipulation logic.

@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/apis/serving/v1alpha1/revision_types.go 82.8% 38.1% -44.7
pkg/apis/serving/v1alpha1/revision_types_test.go 82.8% 38.1% -44.7
pkg/apis/serving/v1alpha1/route_types.go 30.4% 35.0% 4.6
pkg/apis/serving/v1alpha1/route_types_test.go 30.4% 35.0% 4.6
pkg/controller/route/route.go 78.9% 78.8% -0.1
pkg/controller/revision/revision.go 74.8% 73.7% -1.2
pkg/controller/revision/revision_test.go 74.8% 73.7% -1.2

*TestCoverage feature is being tested, do not rely on any info here yet

@google-prow-robot google-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 9, 2018
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/apis/serving/v1alpha1/revision_types.go 82.8% 90.5% 7.7
pkg/apis/serving/v1alpha1/revision_types_test.go 82.8% 90.5% 7.7
pkg/apis/serving/v1alpha1/route_types.go 30.4% 85.0% 54.6
pkg/apis/serving/v1alpha1/route_types_test.go 30.4% 85.0% 54.6
pkg/controller/route/route.go 78.9% 78.8% -0.1
pkg/controller/revision/revision.go 74.8% 73.7% -1.2
pkg/controller/revision/revision_test.go 74.8% 73.7% -1.2

*TestCoverage feature is being tested, do not rely on any info here yet

@mattmoor mattmoor changed the title [WIP] Move revision condition manipulation to _types.go Move revision condition manipulation to _types.go Jun 9, 2018
@google-prow-robot google-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 9, 2018
@mattmoor
Copy link
Copy Markdown
Member Author

mattmoor commented Jun 9, 2018

/assign @jonjohnsonjr
/assign @evankanderson

@mattmoor
Copy link
Copy Markdown
Member Author

/assign @tcnghia

Jon's travelling.

Comment thread pkg/controller/revision/revision.go Outdated
}
// Don't modify the informer's copy.
rev = rev.DeepCopy()
rev.Status.InitializeConditions()
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.

does this set all existing conditions on the Status to Unknown? are there cases where we would want to retain existing conditions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This only populates missing Conditions.

Comment thread pkg/controller/revision/revision.go Outdated
// TODO(mattmoor): Use a method on the Build type.
func isBuildDone(rev *v1alpha1.Revision) (done, failed bool) {
if rev.Spec.BuildName == "" {
return true, false
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.

personally I'd find it more readable to do

done,failed = true, false
return

but the function is small enough so you don't need to do that if you don't want to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll tweak this a bit further

Comment thread pkg/controller/revision/revision.go Outdated
if getIsServiceReady(endpoint) {
logger.Infof("Endpoint %q is ready", eName)
if err := c.markRevisionReady(ctx, rev); err != nil {
rev.Status.MarkResourcesAvailable()
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.

looks like these two always go together? I wonder if they can be the same condition?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I was struggling with this myself. I opened #1137 for this discussion.

mattmoor added 5 commits June 11, 2018 19:27
This is the Revision equivalent of #1113

This contains two other unrelated changes:
1. Condense the object construction in `revision_test.go`
1. Reorder the `helloworld` yaml to create the configuration first.

The reason for the second "unrelated" change is that I was seeing the route controller marking the Route as "AllTrafficAssigned = False" because the configuration wasn't created yet.
Eliding conditions can come later, it's a premature optimization,
and I'm not sure we're handling conditions well enough to do it
reliably yet.
@mattmoor mattmoor force-pushed the revision-conditions branch from af209cd to c27e365 Compare June 11, 2018 19:29
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/apis/serving/v1alpha1/revision_types.go 82.8% 90.5% 7.7
pkg/apis/serving/v1alpha1/revision_types_test.go 82.8% 90.5% 7.7
pkg/apis/serving/v1alpha1/route_types.go 30.4% 85.0% 54.6
pkg/apis/serving/v1alpha1/route_types_test.go 30.4% 85.0% 54.6
pkg/controller/route/route.go 78.9% 78.8% -0.1
pkg/controller/revision/revision.go 74.8% 73.6% -1.3
pkg/controller/revision/revision_test.go 74.8% 73.6% -1.3

*TestCoverage feature is being tested, do not rely on any info here yet

@tcnghia
Copy link
Copy Markdown
Contributor

tcnghia commented Jun 11, 2018

thanks a lot for doing this refactoring.

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 11, 2018
@google-prow-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@google-prow-robot google-prow-robot merged commit 3ec60bc into knative:master Jun 11, 2018
@mattmoor mattmoor deleted the revision-conditions branch June 11, 2018 20:02
google-prow-robot pushed a commit that referenced this pull request Jun 11, 2018
This is the Service equivalent of #1113, #1118, #1132

However, Service's condition are largely not implemented, so mostly deferred to: #1134
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants