Repository navigation
Steve controller - #597
Steve controller#597
Conversation
|
/assign @evankanderson |
|
/retest |
Apply Service label to route / configuration. add tests
grantr
left a comment
There was a problem hiding this comment.
This was easier to review than I expected; thanks @vaikas-google for making it easy to understand. I have a few minor comments.
|
|
||
| var ( | ||
| controllerKind = v1alpha1.SchemeGroupVersion.WithKind("Service") | ||
| routeProcessItemCount = prometheus.NewCounterVec(prometheus.CounterOpts{ |
There was a problem hiding this comment.
Probably should be called serviceProcessItemCount
|
|
||
| glog.Infof("Service controller Init") | ||
|
|
||
| // obtain references to a shared index informer for the Services and |
There was a problem hiding this comment.
This comment appears to be incomplete (Services and...)
| return err | ||
| } | ||
| } | ||
| config.SetGeneration(existing.GetGeneration()) |
There was a problem hiding this comment.
I'm not sure I understand why this line is necessary. Can you add a comment explaining it? In particular, is it still needed when the apiserver is setting Generation for CRDs?
| return err | ||
| } | ||
| } | ||
| route.SetGeneration(existing.GetGeneration()) |
There was a problem hiding this comment.
Same comment as above could be here too.
There was a problem hiding this comment.
It's not. For updates, I first had set the ResourceVersion (and just set the Generation as well). So, once I just switched to overwriting only the spec, I couldn't recall if the Generation was handled correctly forgot to go back and check.
loooong way to say, it's not necessary, yanked.
|
|
||
| revisionName := "" | ||
| if service.Spec.Pinned != nil { | ||
| revisionName = service.Spec.Pinned.RevisionName |
There was a problem hiding this comment.
Is service.Spec.Pinned.RevisionName allowed to be empty here (by the webhook)?
There was a problem hiding this comment.
Nope. Pinned.RevisionName must not be empty.
https://github.com/elafros/elafros/blob/master/pkg/webhook/service.go#L60
| tt := v1alpha1.TrafficTarget{ | ||
| Percent: 100, | ||
| } | ||
| if len(revisionName) != 0 { |
There was a problem hiding this comment.
It's a bit odd to me that MakeServiceConfiguration uses service.Spec.RunLatest to determine which configuration to use, while MakeServiceRoute uses the length of revisionName, relying on the implicit contract that an empty revision name means the service is in RunLatest mode. Is there a reason for that difference?
If MakeServiceRoute used the same method as MakeServiceConfiguration, maybe there wouldn't be a need for the revisionName parameter or the conditional at https://github.com/elafros/elafros/pull/597/files#diff-2f50e493d103b0bd9f2ac68800d40201R278.
WDYT @vaikas-google?
There was a problem hiding this comment.
Great suggestion! Done.
There was a problem hiding this comment.
Exposed a bug in the tests too btw :)
| ) | ||
|
|
||
| func testNothing(t *testing.T) { | ||
| return |
There was a problem hiding this comment.
Intended to be filled in later? 😉
There was a problem hiding this comment.
yep, added TODO as felt this was getting a bit large already.
| @@ -1,4 +1,4 @@ | |||
| load("@io_bazel_rules_go//go:def.bzl", "go_library") | |||
| load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | |||
There was a problem hiding this comment.
I'd recommend removing changes to this file since it's not related to the PR and might cause a merge conflict if someone else already fixed it in master.
There was a problem hiding this comment.
hm, odd. I assume this is from the update-codegen? At least I do not recall doing this.
There was a problem hiding this comment.
It's from hack/update-deps.sh
There was a problem hiding this comment.
Yeah, so when I take it out, I get this:
vaikas@vaikas-linux3:~/projects/go/src/github.com/elafros/elafros$ bazel test pkg/...
ERROR: /home/vaikas/projects/go/src/github.com/elafros/elafros/pkg/queue/BUILD.bazel:11:1: name 'go_test' is not defined (did you mean 'sh_test'?)
ERROR: package contains errors: pkg/queue
ERROR: error loading package 'pkg/queue': Package 'pkg/queue' contains errors
INFO: Elapsed time: 0.241s
FAILED: Build did NOT complete successfully (1 packages loaded)
ERROR: Couldn't start the build. Unable to run tests
There was a problem hiding this comment.
Ah sorry, my comment was unclear. I meant remove this change from the PR, leaving it unstaged in your local checkout. Just don't stage this particular file when committing.
It's fine to ignore this advice, since merge conflicts are unlikely anyway (the file will have the same generated content in all recent branches). At this point it's probably more work to try to remove this change than keep it.
There was a problem hiding this comment.
Turns out these were also fixed by @bobcatfish in #599
|
|
||
| ``` | ||
| NAME HOSTS ADDRESS PORTS AGE | ||
| route-example-ela-ingress demo.myhost.net 80 14s |
There was a problem hiding this comment.
I think route-example should be replaced with service-example here and elsewhere in this file.
|
|
||
| copy := existing.DeepCopy() | ||
| copy.Spec = config.Spec | ||
| _, err = configClient.Update(copy) |
There was a problem hiding this comment.
Does this update the configuration if it hasn't changed? I think maybe the webhook makes the update a noop if there are no patches. IIUC that behavior is required here, because we need to be able to update a service without creating a new revision.
There was a problem hiding this comment.
Yes, it doesn't diff yet, so will just update. webhook should cause the right thing to happen.
I added a few TODOs.
|
Thanks @grantr I believe I addressed all the comments (and it exposed a test bug 👍 ), PTAL. |
evankanderson
left a comment
There was a problem hiding this comment.
We really need a CLI so that the READMEs don't have so much crummy boilerplate (and automatic DNS setup for the same).
A bunch of medium-size comments, but no major red flags. Thanks for including the sample.
|
|
||
| // NewController initializes the controller and is called by the generated code | ||
| // Registers eventhandlers to enqueue events | ||
| //TODO(vaikas): somewhat generic (generic behavior) |
There was a problem hiding this comment.
I don't understand your TODO here -- what needs to be done (in case someone else wanted to pick it up and do it)
There was a problem hiding this comment.
These TODOs are copied from the other controllers. They identify functions that have no variance across the controller types and could be moved to the shared controller package. That was the original intent anyway - they might not be accurate anymore. In particular, some controllers now create multiple informers, so the NewController methods are no longer generic.
I'm fine with removing these. Anyone investigating how to generalize controller code will certainly do their own analysis.
There was a problem hiding this comment.
leftover cruft, removed.
|
|
||
| glog.Infof("Service controller Init") | ||
|
|
||
| // obtain references to a shared index informer for the Services and |
There was a problem hiding this comment.
You lost the end of your sentence here.
| // as syncing informer caches and starting workers. It will block until stopCh | ||
| // is closed, at which point it will shutdown the workqueue and wait for | ||
| // workers to finish processing their current work items. | ||
| //TODO(grantr): generic |
There was a problem hiding this comment.
leftover cruft from other skeleton controllers, removed.
| } | ||
|
|
||
| glog.Info("Starting workers") | ||
| // Launch two workers to process Service resources |
There was a problem hiding this comment.
This comment seems unnecessary and also wrong.
There was a problem hiding this comment.
It's true in practice because threadiness is always two due to https://github.com/elafros/elafros/blob/master/cmd/ela-controller/main.go#L44. The controller isn't supposed to know that though, and this comment probably shouldn't either.
There was a problem hiding this comment.
leftover cruft from other skeleton controllers, removed.
|
|
||
| // processNextWorkItem will read a single work item off the workqueue and | ||
| // attempt to process it, by calling the updateServiceEvent. | ||
| //TODO(vaikas): generic |
There was a problem hiding this comment.
again, leftover cruft.
| if apierrs.IsNotFound(err) { | ||
| _, err := configClient.Create(config) | ||
| return err | ||
| } |
There was a problem hiding this comment.
Do you want to bail/return on other errors?
| if apierrs.IsNotFound(err) { | ||
| _, err := routeClient.Create(route) | ||
| return err | ||
| } |
There was a problem hiding this comment.
Ditto on returning err here if Get fails on the existing with something other than not found.
| return err | ||
| } | ||
| } | ||
| route.SetGeneration(existing.GetGeneration()) |
There was a problem hiding this comment.
Ditto here as well on modifying the input route with some fields but not others.
| } | ||
| } | ||
|
|
||
| func createServiceWithRunLatest() *v1alpha1.Service { |
There was a problem hiding this comment.
It's slightly odd that this function is reused in service_route_test.go, though I don't have an immediate better suggestion.
There was a problem hiding this comment.
Yeah, I could've created createServiceConfigurationTestWithRunLatest :) or something like that, you're ok though with this?
There was a problem hiding this comment.
I am. I was wondering if a service_object_creators or the like for common test infra would make sense here, but I'm fine with this, too.
| "testing" | ||
| ) | ||
|
|
||
| func testNothing(t *testing.T) { |
There was a problem hiding this comment.
already did :) You must have looked at the older version?
|
Thanks @evankanderson for the review, I removed bunch of carry-over cruft todos and fixed the error cases. PTAL. |
|
It looks like I went through while you were addressing Grant's comments. I have a few more comments, but this generally LGTM: |
|
allrighty, made the changes and added a todo for type checking. PTAL. |
mattmoor
left a comment
There was a problem hiding this comment.
This seems like a reasonable skeleton to me, but I think I'd like to see us deeply specify the semantics we have in mind before we get too deep into implementing the controller logic and its tests.
| glog.Infof("Running reconcile Service for %s\n%+v\n", service.Name, service) | ||
|
|
||
| config := MakeServiceConfiguration(service) | ||
| if err = c.reconcileConfiguration(config); err != nil { |
There was a problem hiding this comment.
it's already defined above in 249?
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: grantr, mattmoor, vaikas-google The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Addresses Issue #412
Proposed Changes