Skip to content

Knative ConfigMap Propagation#2333

Merged
knative-prow-robot merged 32 commits into
knative:masterfrom
grac3gao-zz:propagation
Jan 28, 2020
Merged

Knative ConfigMap Propagation#2333
knative-prow-robot merged 32 commits into
knative:masterfrom
grac3gao-zz:propagation

Conversation

@grac3gao-zz
Copy link
Copy Markdown
Contributor

@grac3gao-zz grac3gao-zz commented Dec 18, 2019

Fixes #1758

Proposed Changes

  • This PR implements the design from @grantr in Knative ConfigMap Propagation
  • It includes two parts: 1) Creating a namespaced CRD ConfigMapPropagation and a corresponding controller to copy ConfigMaps from one namespace to another, 2) Updating Eventing Broker to adapt this CRD

Release Note


@grac3gao-zz grac3gao-zz requested a review from grantr December 18, 2019 19:17
@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 Dec 18, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Dec 18, 2019
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 18, 2019
@knative-prow-robot knative-prow-robot added the area/test-and-release Test infrastructure, tests or release label Dec 18, 2019
@lionelvillard
Copy link
Copy Markdown
Contributor

Is this something Knative Serving also needs?

# Conflicts:
#	cmd/broker/ingress/main.go
#	pkg/reconciler/namespace/namespace.go
#	pkg/reconciler/namespace/namespace_test.go
@grac3gao-zz grac3gao-zz changed the title [WIP]Knative ConfigMap Propagation Knative ConfigMap Propagation Dec 19, 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 Dec 19, 2019
@grac3gao-zz
Copy link
Copy Markdown
Contributor Author

ready for review @grantr

Copy link
Copy Markdown
Contributor

@yolocs yolocs left a comment

Choose a reason for hiding this comment

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

Good job, Grace! Next time, try to break up your PRs into smaller chunks. E.g. in this case, I would at least have two PRs - one for the new API and one for using the new API. It would be much more review-friendly :)

Comment thread pkg/apis/configs/v1alpha1/configmappropagation_defaults_test.go Outdated
Comment thread pkg/apis/configs/v1alpha1/configmappropagation_defaults.go Outdated
Comment thread pkg/apis/configs/v1alpha1/configmappropagation_lifecycle_test.go Outdated
Comment thread pkg/apis/configs/v1alpha1/configmappropagation_validation_test.go Outdated
Comment thread pkg/reconciler/configmappropagation/configmappropagation.go Outdated
Comment thread pkg/reconciler/configmappropagation/configmappropagation.go Outdated
Comment thread pkg/reconciler/configmappropagation/resources/configmap_test.go Outdated
Comment thread test/common/creation.go Outdated
@grac3gao-zz
Copy link
Copy Markdown
Contributor Author

Done. Ready for review again.

Copy link
Copy Markdown
Contributor

@antoineco antoineco left a comment

Choose a reason for hiding this comment

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

Some initial comments. This is a very large PR so I'll need to find more time to review more in depth.

Comment thread pkg/reconciler/configmappropagation/configmappropagation.go Outdated
Comment thread pkg/reconciler/configmappropagation/configmappropagation.go
Comment thread pkg/apis/configs/v1alpha1/configmappropagation_lifecycle.go Outdated
Comment thread pkg/apis/configs/v1alpha1/configmappropagation_lifecycle_test.go Outdated
Comment thread pkg/apis/configs/v1alpha1/configmappropagation_defaults.go Outdated
Comment thread pkg/tracing/setup.go Outdated
Comment thread pkg/reconciler/testing/configmap.go Outdated
Comment thread pkg/reconciler/testing/configmap.go Outdated
Comment thread cmd/broker/ingress/main.go Outdated
Comment thread config/200-addressable-resolvers-clusterrole.yaml Outdated
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.

Fully reviewed now. I have a couple minor comments and some followup issues. Otherwise I think this is good to merge.

// Tell tracker to reconcile this ConfigMapPropagation whenever an original ConfigMap changes.
// Note: Temporarily set Selector to match all objects.
// If Selector is set to match specific labels (the required labels from ConfigMapPropagation),
// the tracker can't track changes when an original ConfigMap no longer has required labels.
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 created an issue to track this: #2435

Namespace: cmp.Spec.OriginalNamespace,
Selector: metav1.SetAsLabelSelector(map[string]string{}),
}
if err := r.tracker.TrackReference(originalConfigMapObjRef, cmp); 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.

Since we know the GVK of this object, I'd prefer to use informer event handlers (set up in the constructor in controller.go) instead of the tracker here. I think that's a bit more clear about what watch events will cause the reconciler to run. I created a followup issue to track this: #2436

// Tell tracker to reconcile this ConfigMapPropagation whenever the a copy ConfigMap changes.
// Note: Temporarily set Selector to match all objects.
// If Selector is set to match specific labels (the required labels from creation),
// the tracker can't track changes when a copy ConfigMap no longer has required labels.
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 believe we can replace this with an informer event handler that watches for ConfigMaps owned by CMPs OR with the copy label. The "OR label" clause capture copies that previously had their labels removed for user modifications, then re-added to revert those modifications. I mentioned this in #2435 also.

Comment thread pkg/reconciler/configmappropagation/configmappropagation.go Outdated
Comment thread pkg/reconciler/configmappropagation/configmappropagation.go Outdated
// OwnerReference will be removed when the knative.dev/config-propagation:copy label is not set in copy configmap
// so that this copy configmap will not be deleted if cmp is deleted.
expected = current.DeepCopy()
expected.OwnerReferences = 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.

Here we should only delete the CMP's owner reference. Theoretically other owner references might exist by the time we reconcile. There might be helper methods for this (or if not, you could write one).

I think this is such a rare case that handling it is optional, so I created a followup issue: #2437

Eventf(corev1.EventTypeNormal, configMapPropagationReadinessChanged, "ConfigMapPropagation %q became ready", configMapPropagationName),
},
}, {
Name: "Copy ConfigMap no longer has required labels",
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.

Related to the comment above and #2437: if we write code to only delete the CMP owner reference, we should add a test case for abandoning a ConfigMap with multiple owner references.

# Conflicts:
#	cmd/controller/main.go
#	config/200-addressable-resolvers-clusterrole.yaml
#	config/200-controller-clusterrole.yaml
#	config/config-logging.yaml
#	config/config-observability.yaml
#	config/config-tracing.yaml
#	hack/update-codegen.sh
#	pkg/reconciler/inmemorychannel/dispatcher/controller.go
# Conflicts:
#	cmd/broker/filter/main.go
#	cmd/broker/ingress/main.go
#	hack/update-codegen.sh
#	pkg/client/informers/externalversions/generic.go
@grac3gao-zz
Copy link
Copy Markdown
Contributor Author

Thank you for reviewing it and opening subsequent issues! @grantr. I changed api group to be configs.internal.knative.dev. Together with modification according to reviews, ready for review.

Comment thread config/300-configmappropagation.yaml Outdated
@@ -0,0 +1 @@
core/resources/configmappropagation.yaml No newline at end of file
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.

Add trailing newline:

Suggested change
core/resources/configmappropagation.yaml
core/resources/configmappropagation.yaml

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.

Does symbolic link also need trailing newline?

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.

No, don't edit this file. @mattmoor your bot should probably ignore symlinks

@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/apis/configs/v1alpha1/configmappropagation_defaults.go Do not exist 100.0%
pkg/apis/configs/v1alpha1/configmappropagation_lifecycle.go Do not exist 100.0%
pkg/apis/configs/v1alpha1/configmappropagation_types.go Do not exist 100.0%
pkg/apis/configs/v1alpha1/configmappropagation_validation.go Do not exist 95.8%
pkg/apis/configs/v1alpha1/register.go Do not exist 100.0%
pkg/reconciler/configmappropagation/configmappropagation.go Do not exist 89.2%
pkg/reconciler/configmappropagation/controller.go Do not exist 100.0%
pkg/reconciler/configmappropagation/resources/configmap.go Do not exist 100.0%
pkg/reconciler/configmappropagation/resources/labels.go Do not exist 100.0%
pkg/reconciler/namespace/controller.go 94.1% 94.7% 0.6
pkg/reconciler/namespace/namespace.go 79.1% 79.4% 0.3

@grantr
Copy link
Copy Markdown
Contributor

grantr commented Jan 28, 2020

/kind feature
/area observability
/area api

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@grantr: The label(s) kind/feature cannot be applied, because the repository doesn't have them

Details

In response to this:

/kind feature
/area observability
/area api

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.

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.

Thanks @grac3gao! Let's merge this so it can get more testing in the wild.

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grac3gao, grantr

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2020
@grantr
Copy link
Copy Markdown
Contributor

grantr commented Jan 28, 2020

/remove-area test-and-release

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. area/api area/observability 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.

Send observability related configmaps to destination namespaces