Remove builder interface, linearize pod creation and watching#464
Remove builder interface, linearize pod creation and watching#464knative-prow-robot merged 14 commits intoknative:masterfrom
Conversation
knative-prow-robot
left a comment
There was a problem hiding this comment.
@imjasonh: 0 warnings.
Details
In response to this:
Proposed Changes
- Remove the
builder.Interfacewhich effectively only had a single implementation for on-cluster builds- Linearize pod creation, so it can be read and understood more clearly from top-to-bottom
- Remove
Operation, callbacks, mutexes, etc.With this change, we'll listen for all pod events on the cluster, and when we see one for a pod owned by a Build, we'll update that build with the Pod's status.
Release Note
NONE
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
|
/test pull-knative-build-integration-tests |
| Namespace: build.Namespace, | ||
| // Ensure our Pod gets a unique name. | ||
| GenerateName: fmt.Sprintf("%s-", build.Name), | ||
| Name: fmt.Sprintf("pod-for-%s", build.Name), |
There was a problem hiding this comment.
How about $(build_name)-pod?
For example if k8s deployment is used, the pod names have deployment name as prefix. It is easier to associate the parent resource with prefix rather than suffix.
There was a problem hiding this comment.
I do not have strong opinion on what follows after build_name. Probably a better question to ask is if build can only have a pod why do we need different name.
There was a problem hiding this comment.
Good call, done.
FWIW, the reason I dropped GenerateName is because the fake k8s implementation doesn't generate names, and so pods were always created as "". 😠
|
The failing test is the YAML test for It looks like the timeout isn't kicking in and the build continues executing ~forever. Oddly this doesn't seem to happen when I run e2e-tests.sh locally. I'll investigate more and unhold this. /hold |
|
CLAs look good, thanks! |
|
/test pull-knative-build-integration-tests |
| controllers := []controller.Interface{ | ||
| build.NewController(logger, kubeClient, buildClient, buildInformer, buildTemplateInformer, clusterBuildTemplateInformer, bldr), | ||
| controllers := []*controller.Impl{ | ||
| build.NewController(logger, kubeClient, kubeInformerFactory, buildClient, buildInformer, buildTemplateInformer, clusterBuildTemplateInformer), |
There was a problem hiding this comment.
The pattern we're using constructs the Pod informer here and passes it in, so that it can be included in the synchronization below.
| kubeinformers.Core().V1().Pods().Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
| AddFunc: r.addPodEvent, | ||
| UpdateFunc: r.updatePodEvent, | ||
| DeleteFunc: r.deletePodEvent, |
There was a problem hiding this comment.
For this to be properly level-based, these should use impl.EnqueueControllerOf (possibly wrapped with controller.PassNew). For a Pod informer, you also certainly want to use a Filter on the OwnerReference Kind being Build.
In level-based reconciliation, all of the logic is oriented in terms of reconciling Build keys (Reconcile()), and these triggers are very thin, they just figure out what Build to queue and enqueue it.
There was a problem hiding this comment.
Thanks for that tip. I tried switching to this and had some trouble in tests getting a signal that the enqueued update happened. Do you happen to have a link to how you handle this in Serving?
Also, good idea filtering for build-owned pods. How do I express that filter to podsLister? NewSharedInformerFactoryWithOptions with a TweakListOptions to specify a FieldSelector?
7b5dbd7 to
28759d3
Compare
| "k8s.io/client-go/tools/clientcmd" | ||
|
|
||
| // Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters). | ||
| "k8s.io/client-go/tools/clientcmd" // Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters). |
There was a problem hiding this comment.
This comment is not at the right place 😅
|
/hold I have quite a few unpushed changes, I'm thinking this might be better as more smaller PRs. Unfortunately life stuff is taking up a lot of time lately, I probably can't promise much progress until after the Thanksgiving holiday. |
|
/hold cancel This change is ready now, passing unit and integration tests. Unfortunately it's pretty big, sorry about that, my intention had been to split it up but it looked like it was all pretty tightly intertwined. The good news is I think this is a lot easier to read and understand (and test!) after this change. It should now be pretty straightforward to forklift this into the |
| if err != nil { | ||
| return err | ||
| } | ||
| newb.Status = u.Status |
There was a problem hiding this comment.
We could consider checking if there is any change in status object before updating it.
This could be changed in further PR too.
| } | ||
| } | ||
| return nil, errors.New("watch ended before build completion") | ||
| return latest, errWatchTimeout |
There was a problem hiding this comment.
I like this classification of errors.
|
oh @imjasonh needs a rebase 🙏 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ImJasonH, shashwathi, vdemeester 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 |
|
The following is the coverage report on pkg/.
|
…e#464) * Remove builder interface, linearize pod creation and watching * Remove pkg/buildtest/wait.go * Create pods like <build-name>-pod * Remove pkg/controller * Improve TestLowTimeout, still needs work * Move BuildStatusFromPod to resources pkg * Skip statuses for multiple sources; add tests for BuildStatusFromPod * Lower timeout, log more * pass build to isTimeout * Generate unique names for each pod, otherwise conflict; move tests to pod_test.go * Sync pod lister before starting controller * update deps * Reconcile in response to pod events * Remove commented import
…e#464) * Remove builder interface, linearize pod creation and watching * Remove pkg/buildtest/wait.go * Create pods like <build-name>-pod * Remove pkg/controller * Improve TestLowTimeout, still needs work * Move BuildStatusFromPod to resources pkg * Skip statuses for multiple sources; add tests for BuildStatusFromPod * Lower timeout, log more * pass build to isTimeout * Generate unique names for each pod, otherwise conflict; move tests to pod_test.go * Sync pod lister before starting controller * update deps * Reconcile in response to pod events * Remove commented import
…e#464) * Remove builder interface, linearize pod creation and watching * Remove pkg/buildtest/wait.go * Create pods like <build-name>-pod * Remove pkg/controller * Improve TestLowTimeout, still needs work * Move BuildStatusFromPod to resources pkg * Skip statuses for multiple sources; add tests for BuildStatusFromPod * Lower timeout, log more * pass build to isTimeout * Generate unique names for each pod, otherwise conflict; move tests to pod_test.go * Sync pod lister before starting controller * update deps * Reconcile in response to pod events * Remove commented import
…e#464) * Remove builder interface, linearize pod creation and watching * Remove pkg/buildtest/wait.go * Create pods like <build-name>-pod * Remove pkg/controller * Improve TestLowTimeout, still needs work * Move BuildStatusFromPod to resources pkg * Skip statuses for multiple sources; add tests for BuildStatusFromPod * Lower timeout, log more * pass build to isTimeout * Generate unique names for each pod, otherwise conflict; move tests to pod_test.go * Sync pod lister before starting controller * update deps * Reconcile in response to pod events * Remove commented import
Proposed Changes
builder.Interfacewhich effectively only had a single implementation for on-cluster buildsOperation, callbacks, mutexes, etc.With this change, we'll listen for all pod events on the cluster, and when we see one for a pod owned by a Build, we'll update that build with the Pod's status.
Release Note