Skip to content

Policyset dependencies #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

JustinKuli
Copy link
Member

Some refactoring to (I think) get things in better shape for the changes, and then this is the main commit message:

Since whether dependencies are satisfied will be calculated on the managed cluster, and since PolicySets are not propagated to managed clusters, in order to work "as expected" by a user, any PolicySet dependencies should be replaced with the Policies that are in that set.

To keep those lists up to date, the root policies need to reconcile whenever the dependent PolicySets are updated, accomplished here with the new dynamic watch library. So now Policies watch items referenced in their templates, as well as relevant PolicySets.

Note: when a PolicySet does not exist, the dependency is not changed - it is expected that the status message from the managed cluster (indicating that the set does not exist) will be sufficient for users to understand the issue.

Refs:

Previously, only the spec and annotations of policies were synchronized
between root and replicated policies. Labels were not synchronized, and
the root and replicated policies could drift apart.

This was an inconsistent behavior because when the replicated policy is
first created, any labels on the root policy *are* copied over.

Signed-off-by: Justin Kulikauskas <[email protected]>
These functions were not as "common" as them being in the "common" pkg
would suggest. Now they're closer to where they are used, and future
related changes will be able to stay in one place.

Signed-off-by: Justin Kulikauskas <[email protected]>
Since whether dependencies are satisfied will be calculated on the
managed cluster, and since PolicySets are not propagated to managed
clusters, in order to work "as expected" by a user, any PolicySet
dependencies should be replaced with the Policies that are in that set.

To keep those lists up to date, the root policies need to reconcile
whenever the dependent PolicySets are updated, accomplished here with
the new dynamic watch library. So now Policies watch items referenced
in their templates, as well as relevant PolicySets.

Note: when a PolicySet does not exist, the dependency is not changed -
it is expected that the status message from the managed cluster
(indicating that the set does not exist) will be sufficient for users
to understand the issue.

Refs:
 - stolostron/backlog#26181

Signed-off-by: Justin Kulikauskas <[email protected]>
@JustinKuli
Copy link
Member Author

Pushing image to KinD cluster
kind load docker-image localhost:5000/governance-policy-propagator:latest --name test-hub
Image: "localhost:5000/governance-policy-propagator:latest" with ID "sha256:0687892eab0a3f0e9c50076a7cfa82b0fc755a742eb93a1f28f94985f0550552" not yet present on node "test-hub-control-plane", loading...
ERROR: failed to load image: command "docker exec --privileged -i test-hub-control-plane ctr --namespace=k8s.io images import --digests --snapshotter=overlayfs -" failed with error: exit status 1

Command Output: ctr: failed to resolve layers: failure checking for compressed blobs: failed to detect media type of layer: failed to read content store to detect layer media type: content digest sha256:8cedbb6c20a1b8c838c2c7e8bc3c9ef01a35ddcae4c7673bc7cda880922facae: not found
make: *** [Makefile:230: kind-deploy-controller-dev] Error 1

Fun 😆

return replicated, nil
}

func (r *PolicyReconciler) canonicalizeDependencies(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a comment describing what this function does would be useful, since the formatted dependency array is not really used in this repo so it might be a bit confusing why we are changing it

@openshift-ci
Copy link

openshift-ci bot commented Oct 26, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JustinKuli, willkutler

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:
  • OWNERS [JustinKuli,willkutler]

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

@willkutler
Copy link
Contributor

This looks good to me! Just added a nit about adding some comments to clarify what these dependency formatting functions do.

@openshift-merge-robot openshift-merge-robot merged commit 902e86e into open-cluster-management-io:main Oct 26, 2022
ChunxiAlexLuo added a commit to ChunxiAlexLuo/governance-policy-propagator that referenced this pull request Oct 28, 2022
ChunxiAlexLuo added a commit to ChunxiAlexLuo/governance-policy-propagator that referenced this pull request Oct 28, 2022
ChunxiAlexLuo added a commit to ChunxiAlexLuo/governance-policy-propagator that referenced this pull request Oct 28, 2022
@JustinKuli JustinKuli deleted the policyset-dependencies branch February 2, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants