Skip to content

Reconcile using pkg/controller#1057

Merged
knative-prow-robot merged 27 commits into
knative:masterfrom
n3wscott:reconcile_pkg
Apr 18, 2019
Merged

Reconcile using pkg/controller#1057
knative-prow-robot merged 27 commits into
knative:masterfrom
n3wscott:reconcile_pkg

Conversation

@n3wscott
Copy link
Copy Markdown
Contributor

@n3wscott n3wscott commented Apr 15, 2019

Relates to #734

Proposed Changes

  • Move to pkg/controller style for eventing core.

Release Note

- channel.spec.subscribable.subscribers[n]**.ref** changes to **.uid** for patchMergeKey,
- SubscriberSpec Struct .Ref becomes .DeprecatedRef

@knative-prow-robot knative-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 Apr 15, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Apr 15, 2019
@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 15, 2019
@n3wscott
Copy link
Copy Markdown
Contributor Author

/cc @mattmoor

@n3wscott
Copy link
Copy Markdown
Contributor Author

/cc @vaikas-google

@n3wscott n3wscott changed the title [WIP] Reconcile using pkg/controller Reconcile using pkg/controller Apr 17, 2019
@knative-prow-robot knative-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 Apr 17, 2019
Copy link
Copy Markdown
Contributor

@vaikas vaikas left a comment

Choose a reason for hiding this comment

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

I feel like we should document the change from ref to uid in the release notes section for sure? I assume there's a way to find the subscription given the URI alone? I'll go look at those next, just jotting it down though.

Comment thread Gopkg.toml Outdated
Comment thread cmd/controller/main.go
eventingInformerFactory := informers.NewSharedInformerFactory(opt.EventingClientSet, opt.ResyncPeriod)

subscriptionInformer := eventingInformerFactory.Eventing().V1alpha1().Subscriptions()
//deploymentInformer := kubeInformerFactory.Apps().V1().Deployments()
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.

remove?

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.

I want to keep them until I am finished with the the other rec loops.

Comment thread cmd/controller/main.go
logger.Fatalw("Error building kubeconfig", zap.Error(err))
}

const numControllers = 1
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.

why not define this with the other constants around L72?

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.

I am copying patterns from serving, I think because this code knows how many reconcilers it is adding right here.

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.

Why can't we determine the qps values based on the size of the controller array?

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.

I was going to suggest that as well, but these seem to be necessary before the controller array is defined. Then I was going to suggest that we should document below in the controller array creation, but then I noticed that the code will panic if you add a controller and forget to modify controller const here. So I'm fine with this.

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.

This is a copy from serving. We can improve on it later. I would suggest not changing it until we do more integrations.

Comment thread cmd/controller/main.go Outdated
}

// Watch the logging config map and dynamically update logging levels.
opt.ConfigMapWatcher.Watch(logging.ConfigMapName(), logging.UpdateLevelFromConfigMap(logger, atomicLevel, component))
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.

this uses logging.ConfigMapName() but L177 uses logconfig.ConfigMapName() is that intentional? If so, perhaps add comments about that. Just seems goofy.

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.

The two impls are split between the CR way and pkg way. The other path will be deleted when it is removed

Comment thread cmd/controller/main.go Outdated
Comment thread pkg/reconciler/v1alpha1/testing/channel.go Outdated
Comment thread pkg/reconciler/v1alpha1/testing/aliases.go Outdated
Comment thread pkg/reconciler/v1alpha1/testing/unstructured.go Outdated
Comment thread pkg/reconciler/v1alpha1/testing/clock.go Outdated
type ChannelSubscriberSpec struct {
// +optional
Ref *corev1.ObjectReference `json:"ref,omitempty"`
UID types.UID `json:"uid,omitempty"`
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.

So, these are Subscription UIDs? Just trying to think what ramifications this change has.

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.

This is ONLY for patchMerge to work correctly.

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.

Is there an upgrade plan that allows existing channels to continue to work? What about partners who are already relying on the ref field?

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.

Just trying to think what ramifications this change has.

Doesn't this eliminate the ability for Channel provisioners to retrieve a list of their Subscription objects? Is there a way to retrieve an object by UID only in the Kubernetes api?

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 upgrade plan needed, it just works.

Channel provisioners to retrieve a list of their Subscription objects

this is not done as far as I know and not part of the subscribable spec.

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.

Yeah, this was what I was curious about also, does anybody else need to retrieve the subscription object. @n3wscott told me no, the ref here was only used for merging purposes.

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.

I added back Ref as DeprecatedRef

@n3wscott
Copy link
Copy Markdown
Contributor Author

/hold
last thing to do is to let the controllers run together.

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 17, 2019
@n3wscott
Copy link
Copy Markdown
Contributor Author

/test pull-knative-eventing-integration-tests

Comment thread cmd/controller/main.go
logger.Fatalw("Error building kubeconfig", zap.Error(err))
}

const numControllers = 1
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.

I was going to suggest that as well, but these seem to be necessary before the controller array is defined. Then I was going to suggest that we should document below in the controller array creation, but then I noticed that the code will panic if you add a controller and forget to modify controller const here. So I'm fine with this.

type ChannelSubscriberSpec struct {
// +optional
Ref *corev1.ObjectReference `json:"ref,omitempty"`
UID types.UID `json:"uid,omitempty"`
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.

Yeah, this was what I was curious about also, does anybody else need to retrieve the subscription object. @n3wscott told me no, the ref here was only used for merging purposes.

Comment thread pkg/reconciler/v1alpha1/testing/aliases.go Outdated
Comment thread cmd/controller/main.go
Comment thread pkg/reconciler/reconciler.go Outdated
Comment thread pkg/reconciler/v1alpha1/subscription/subscription.go Outdated
Comment thread pkg/reconciler/v1alpha1/subscription/subscription.go
Comment thread pkg/reconciler/v1alpha1/subscription/subscription.go
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
contrib/kafka/pkg/dispatcher/dispatcher.go 71.8% 73.6% 1.8
contrib/natss/pkg/dispatcher/dispatcher/dispatcher.go 57.1% 56.3% -0.8

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Apr 18, 2019

/approve
/lgtm
/hold

Thanks so much for doing this, really stoked about this.

Just putting the /hold since @grantr had some outstanding comments so don't want to merge without him getting a chance to veto :)

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Apr 18, 2019
Authority: fmt.Sprintf("%s.%s.channels.%s", channelName, testNS, utils.GetClusterDomainName()),
},
Route: []istiov1alpha3.DestinationWeight{{
Route: []istiov1alpha3.HTTPRouteDestination{{
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.

Why did this change? Is this an integration from one of the istio PRs?

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.

This is a pkg change.

Authority: fmt.Sprintf("%s.%s.channels.%s", channelName, testNS, utils.GetClusterDomainName()),
},
Route: []istiov1alpha3.DestinationWeight{{
Route: []istiov1alpha3.HTTPRouteDestination{{
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.

Same as above - why did this change?

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.

pkg changed it.

}
s.logger.Sugar().Infof("NATSS message received from subject: %v; sequence: %v; timestamp: %v, headers: '%s'", msg.Subject, msg.Sequence, msg.Timestamp, message.Headers)
if err := s.dispatcher.DispatchMessage(&message, subscription.SubscriberURI, subscription.ReplyURI, provisioners.DispatchDefaults{Namespace: subscription.Namespace}); err != nil {
if err := s.dispatcher.DispatchMessage(&message, subscription.SubscriberURI, subscription.ReplyURI, provisioners.DispatchDefaults{Namespace: channel.Namespace}); err != nil {
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.

Was this a bug? I guess they're always the same namespace in practice, so hard to see.

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.

yes it was a bug

Authority: channelHostName(channel.Name, channel.Namespace),
},
Route: []istiov1alpha3.DestinationWeight{{
Route: []istiov1alpha3.HTTPRouteDestination{{
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.

Same as above

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.

pkg updated the names to the real names

Authority: fmt.Sprintf("%s.%s.channels.%s", channelName, testNS, utils.GetClusterDomainName()),
},
Route: []istiov1alpha3.DestinationWeight{{
Route: []istiov1alpha3.HTTPRouteDestination{{
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.

Same as above

if equality.Semantic.DeepEqual(sub.Spec.Channel, s.Spec.Channel) {
subs = append(subs, s)
}
sl, err := r.subscriptionLister.Subscriptions(sub.Namespace).List(labels.Everything()) // TODO: we can use labels to help here
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.

For future reference, the continue token handling can be removed based on #1044 (comment).

Name: "key not found",
// Make sure Reconcile handles good keys that don't exist.
Key: "foo/not-found",
//}, { // TODO: there is a bug in the controller, it will query for ""
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.

Is this a new test you wrote @n3wscott? Good catch!

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, it is an existing test that was blind to what the reconciler was really doing.

import (
"encoding/json"
"fmt"
testing2 "github.com/knative/eventing/pkg/reconciler/testing"
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.

Can we call this import something more descriptive than testing2? I suggest rectesting

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.

as a followup?

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.

}, {
Name: "subscription, but subscriber does not exist",
Objects: []runtime.Object{
testing2.NewSubscription(subscriptionName, testNS,
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.

Can you explain why you replaced the previous builder syntax with the functional options syntax?

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.

serving uses mutation functions and go tends to not use builders. The functions are more flexible.

@@ -14,30 +14,26 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
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.

lol this is a weird diff

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.

/idk

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.

I think it is git being funny, it is a new file

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.

yeah it's accidentally a rename because git can only detect renames by looking at file similarity.

Copy link
Copy Markdown
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Big change! Thanks for working through all this @n3wscott.

/lgtm

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, n3wscott, 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:
  • OWNERS [grantr,n3wscott,vaikas-google]

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

@grantr
Copy link
Copy Markdown
Contributor

grantr commented Apr 18, 2019

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 18, 2019
@knative-prow-robot knative-prow-robot merged commit 83b079f into knative:master Apr 18, 2019
@n3wscott
Copy link
Copy Markdown
Contributor Author

🎉

matzew added a commit to matzew/eventing that referenced this pull request Mar 26, 2021
Co-authored-by: Stavros Kontopoulos <skontopo@redhat.com>
matzew pushed a commit to matzew/eventing that referenced this pull request Feb 14, 2025
…5 updates (knative#1057)

* [release-v1.17][gomod]: Bump the patch group across 1 directory with 5 updates

Bumps the patch group with 2 updates in the / directory: [k8s.io/api](https://github.com/kubernetes/api) and [k8s.io/apiextensions-apiserver](https://github.com/kubernetes/apiextensions-apiserver).


Updates `k8s.io/api` from 0.31.4 to 0.31.5
- [Commits](kubernetes/api@v0.31.4...v0.31.5)

Updates `k8s.io/apiextensions-apiserver` from 0.31.4 to 0.31.5
- [Release notes](https://github.com/kubernetes/apiextensions-apiserver/releases)
- [Commits](kubernetes/apiextensions-apiserver@v0.31.4...v0.31.5)

Updates `k8s.io/apimachinery` from 0.31.4 to 0.31.5
- [Commits](kubernetes/apimachinery@v0.31.4...v0.31.5)

Updates `k8s.io/apiserver` from 0.31.4 to 0.31.5
- [Commits](kubernetes/apiserver@v0.31.4...v0.31.5)

Updates `k8s.io/client-go` from 0.31.4 to 0.31.5
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](kubernetes/client-go@v0.31.4...v0.31.5)

---
updated-dependencies:
- dependency-name: k8s.io/api
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: k8s.io/apiextensions-apiserver
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: k8s.io/apimachinery
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: k8s.io/apiserver
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: k8s.io/client-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Run generate release

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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. cla: yes Indicates the PR's author has signed the CLA. 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.

8 participants