Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Only watched managed resources #715

Merged
merged 7 commits into from Apr 13, 2019
Merged

Only watched managed resources #715

merged 7 commits into from Apr 13, 2019

Conversation

marun
Copy link
Contributor

@marun marun commented Apr 2, 2019

This PR labels managed resources with federation.k8s.io/managed: true and the federated informer will only watch resources so labeled. Existing resources will be updated to include the label, and this is implicitly tested by the crud test for namespaces (since the namespace in the host cluster exists and will be adopted).

The label will be removed from namespaces in the host cluster in the event of a propagation change resulting in the host cluster not existing in the selected set. The label is not yet removed from a namespace in the host cluster when a FederatedNamespace is deleted. The label is also not yet removed from an orphaned resource. Both of these changes will be made in a subsequent PR that rewrites the deletion helper.

Fixes #549

TODO:

  • - Add test that federated resource without placement for a member cluster does not delete an unlabeled resource in that cluster.

5th in a series targeting #612

@k8s-ci-robot k8s-ci-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 2, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 2, 2019
@k8s-ci-robot k8s-ci-robot requested review from font and pmorie April 2, 2019 06:12
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 2, 2019
@marun marun requested review from shashidharatd, irfanurrehman and xunpan and removed request for pmorie and font April 2, 2019 06:13
@marun
Copy link
Contributor Author

marun commented Apr 3, 2019

@shashidharatd @irfanurrehman I realized while working on this that it will fix #549 without further work. We had discussed making adoption optional, but I don't think that will be necessary. Resources have always only been deleted if they appear in the informer cache, and as of this PR only labeled resources will appear in that cache.

I'll add a test to this PR that validates that a non-labeled resource in a given member cluster will not be deleted if a federated resource is created without placement for that cluster.

@marun
Copy link
Contributor Author

marun commented Apr 4, 2019

Rebased

1 similar comment
@marun
Copy link
Contributor Author

marun commented Apr 4, 2019

Rebased

@marun
Copy link
Contributor Author

marun commented Apr 5, 2019

Added a new e2e test validating the behavior required by #549.

@marun marun mentioned this pull request Apr 9, 2019
@k8s-ci-robot k8s-ci-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 Apr 9, 2019
@marun
Copy link
Contributor Author

marun commented Apr 9, 2019

Rebased on #736

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 10, 2019
@marun
Copy link
Contributor Author

marun commented Apr 10, 2019

Rebased

@marun marun changed the title WIP Only watched managed resources Only watched managed resources Apr 10, 2019
@k8s-ci-robot k8s-ci-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 10, 2019
@xunpan
Copy link
Contributor

xunpan commented Apr 10, 2019

LGTM

test/e2e/crud.go Outdated Show resolved Hide resolved
test/e2e/crud.go Outdated Show resolved Hide resolved
test/e2e/crud.go Outdated Show resolved Hide resolved
test/e2e/crud.go Outdated Show resolved Hide resolved
test/e2e/crud.go Outdated Show resolved Hide resolved
@irfanurrehman
Copy link
Contributor

@marun few nits and queries in test code, otherwise lgtm.

@irfanurrehman
Copy link
Contributor

@marun Just realised that this needs a rebase. Please rebase and I will merge.

Label all resources created or updated by federation and ensure that
the federated informer only watches for resources so labeled.
If the containing namespace of a propagated version is deleted, the
request to create it will be denied with 403 and no further attempts
to create should be attempted.

This commit also stops logging version write errors as events, since
version accounting is an internal detail of the sync controller.
@marun
Copy link
Contributor Author

marun commented Apr 12, 2019

Rebased

@irfanurrehman
Copy link
Contributor

/lgtm
@marun Thanks for doing this.

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 13, 2019
@k8s-ci-robot k8s-ci-robot merged commit ae9a656 into kubernetes-retired:master Apr 13, 2019
@marun marun deleted the only-watch-managed branch April 24, 2019 23:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resource in joined cluster will be deleted if federatedresource is created with the same name
4 participants