Skip to content

This hoists the K8s Service reconciliation and makes it level-based.#1328

Merged
google-prow-robot merged 1 commit intoknative:masterfrom
mattmoor:service-time
Jun 25, 2018
Merged

This hoists the K8s Service reconciliation and makes it level-based.#1328
google-prow-robot merged 1 commit intoknative:masterfrom
mattmoor:service-time

Conversation

@mattmoor
Copy link
Copy Markdown
Member

This is the next phase of our level-based migration of the Revision controller. It includes the K8s Service for the user Deployment. This is patterned in much the same way as the Deployment refactor in #1322. The most notable difference in this change is that we establish readiness from the Endpoints resource instead of the Service resource directly.

In addition, I spent a bit of time cleaning up some of the revision_test.go code to more automatically update the informers as resources are reconciled. In particular, after controller.Reconcile we need to make sure all of the updates to the underlying objects are reflected in our informers, or a subsequent reconcile may act on stale state. To facilitate this, I added a helper that updates the informers with the Revision/Deployment/Service to be used after a controller.Reconcile.

@google-prow-robot google-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 22, 2018
@mattmoor mattmoor force-pushed the service-time branch 2 times, most recently from 2403d28 to 5fda32c Compare June 23, 2018 04:29
@mattmoor
Copy link
Copy Markdown
Member Author

$ go test -tags=e2e -count=10 ./test/conformance/...
ok  	github.com/knative/serving/test/conformance	299.609s
?   	github.com/knative/serving/test/conformance/test_images/pizzaplanetv1	[no test files]
?   	github.com/knative/serving/test/conformance/test_images/pizzaplanetv2	[no test files]

🎉

@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 23, 2018
This is the next phase of our level-based migration of the Revision controller.  It includes the K8s Service for the user Deployment. This is patterned in much the same way as the Deployment refactor in #1322.  The most notable difference in this change is that we establish readiness from the Endpoints resource instead of the Service resource directly.

In addition, I spent a bit of time cleaning up some of the `revision_test.go` code to more automatically update the informers as resources are reconciled.  In particular, after `controller.Reconcile` we need to make sure all of the updates to the underlying objects are reflected in our informers, or a subsequent reconcile may act on stale state.  To facilitate this, I added a helper that updates the informers with the Revision/Deployment/Service to be used after a `controller.Reconcile`.
@google-prow-robot google-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 25, 2018
@mattmoor mattmoor changed the title [WIP] This hoists the K8s Service reconciliation and makes it level-based. This hoists the K8s Service reconciliation and makes it level-based. Jun 25, 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 25, 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/controller/revision/revision.go 78.1% 78.8% 0.8

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

Comment thread cmd/controller/main.go
configuration.NewController(opt, configurationInformer, revisionInformer, cfg),
revision.NewController(opt, vpaClient, revisionInformer, buildInformer, configMapInformer,
deploymentInformer, endpointsInformer, vpaInformer, cfg, &revControllerConfig),
deploymentInformer, coreServiceInformer, endpointsInformer, vpaInformer,
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.

The more Informers I see being added, the more I like passing in the map of them so each and every NewController method doesn't need to change when one of them needs something ;)

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.

benefit of this style

  • type safety
  • plus it makes dependencies explicit

return c.KubeClientSet.CoreV1().Services(ns).Create(service)
}

func (c *Controller) checkAndUpdateService(ctx context.Context, rev *v1alpha1.Revision, service *corev1.Service) (*corev1.Service, bool, error) {
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.

nit, but it might be good to document what the bool here is. I think it means if it an update was attempted or not?

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.

Use an enum - self documenting

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jun 25, 2018

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor, vaikas-google

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 60cfc29 into knative:master Jun 25, 2018
Comment thread cmd/controller/main.go
configuration.NewController(opt, configurationInformer, revisionInformer, cfg),
revision.NewController(opt, vpaClient, revisionInformer, buildInformer, configMapInformer,
deploymentInformer, endpointsInformer, vpaInformer, cfg, &revControllerConfig),
deploymentInformer, coreServiceInformer, endpointsInformer, vpaInformer,
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.

benefit of this style

  • type safety
  • plus it makes dependencies explicit

@@ -218,12 +224,8 @@ func NewController(
})

endpointsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
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'm guessing the owner of the endpoints is the service - hence no filtering on the revision as an owner?

Does the Filter support label keys?

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.

The filter is just a function, so we could potentially generalize this to something like our Controller kind filter that takes a label key. WDYT?

// should not allow, or if our expectations of how the service should look
// changes (e.g. we update our controller with new sidecars).
var updated bool
service, updated, err = c.checkAndUpdateService(ctx, rev, service)
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'm guessing there are is no defaulting involved with the service hence why it's safe to perform checkAndUpdateService?

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 haven't seen the dueling controllers that I saw with Deployment, but if this becomes a problem we can relax it as well (until we find a better way of achieving this that works for both).

return c.KubeClientSet.CoreV1().Services(ns).Create(service)
}

func (c *Controller) checkAndUpdateService(ctx context.Context, rev *v1alpha1.Revision, service *corev1.Service) (*corev1.Service, bool, error) {
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.

Use an enum - self documenting

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants