Skip to content
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

add new field status for policy config crd #142

Merged
merged 10 commits into from
Feb 19, 2023
Merged

Conversation

waleedhammam
Copy link
Contributor

@waleedhammam waleedhammam commented Feb 12, 2023

Related: #141

What changed?

  • add new field status for policy config crd

Why was this change made?

  • As a feature request for add new field status for policy config crd to determine if the policies in the config all exist in the cluster or not, that way we can easily display warnings to the user

How was this change implemented?

  • By updating the CRD to have a status field to indicate the health of the policy config policies with a list of strings for the policies ids that doesn't exist on the cluster.
  • Updating the controller to watch/reconcile this list if any change is done on policy or policy config

How did you validate the change?

  • Manual test
  • unit test

Release notes

Documentation Changes

Examples with status OK and Warning

➜  waleed k get policyconfig my-config -o yaml
apiVersion: pac.weave.works/v2beta2
kind: PolicyConfig
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"pac.weave.works/v2beta2","kind":"PolicyConfig","metadata":{"annotations":{},"name":"my-config"},"spec":{"config":{"weave.policies.containers-minimum-replica-count":{"parameters":{"replica_count":3}}},"match":{"namespaces":["dev","prod"]}}}
  creationTimestamp: "2023-02-13T09:51:11Z"
  generation: 2
  name: my-config
  resourceVersion: "1401"
  uid: 9b3e05bf-d9c2-4baa-9461-885a6d35c3a0
spec:
  config:
    weave.policies.containers-minimum-replica-count:
      parameters:
        replica_count: 3
  match:
    namespaces:
    - dev
    - prod
status:
  status: OK


➜  waleed k get policyconfig my-app-config -o yaml
apiVersion: pac.weave.works/v2beta2
kind: PolicyConfig
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"pac.weave.works/v2beta2","kind":"PolicyConfig","metadata":{"annotations":{},"name":"my-app-config"},"spec":{"config":{"weave.policies.policy-1":{"parameters":{"replica_count":3}},"weave.policies.policy-2":{"parameters":{"run_as_root":true}}},"match":{"resources":[{"kind":"Deployment","name":"my-deployment","namespace":"default"}]}}}
  creationTimestamp: "2023-02-13T09:51:19Z"
  generation: 11
  name: my-app-config
  resourceVersion: "11591"
  uid: a72d57ec-e778-465d-bf26-4fea78282290
spec:
  config:
    weave.policies.policy-1:
      parameters:
        replica_count: 3
    weave.policies.policy-2:
      parameters:
        run_as_root: true
  match:
    resources:
    - kind: Deployment
      name: my-deployment
      namespace: default
status:
  missingPolicies:
  - weave.policies.policy-2
  - weave.policies.policy-1
  status: Warning

@codecov
Copy link

codecov bot commented Feb 12, 2023

Codecov Report

Merging #142 (f137d7e) into dev (12e8e0c) will decrease coverage by 1.35%.
The diff coverage is 50.84%.

❗ Current head f137d7e differs from pull request most recent head a2b964c. Consider uploading reports for the commit a2b964c to get more accurate results

@@            Coverage Diff             @@
##              dev     #142      +/-   ##
==========================================
- Coverage   80.86%   79.52%   -1.35%     
==========================================
  Files          14       14              
  Lines         831      884      +53     
==========================================
+ Hits          672      703      +31     
- Misses        120      137      +17     
- Partials       39       44       +5     
Flag Coverage Δ
unit 79.52% <50.84%> (-1.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
controllers/policy_controller.go 71.87% <ø> (+2.17%) ⬆️
controllers/policyconfig_controller.go 62.72% <50.84%> (-6.37%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@waleedhammam waleedhammam force-pushed the dev-policyconfig-status branch 2 times, most recently from 41b925f to 3500edb Compare February 13, 2023 12:30
@waleedhammam waleedhammam marked this pull request as ready for review February 13, 2023 12:32
@waleedhammam waleedhammam force-pushed the dev-policyconfig-status branch 3 times, most recently from f1ef03c to 02d8127 Compare February 13, 2023 13:50
controllers/policyconfig_controller.go Outdated Show resolved Hide resolved
controllers/policyconfig_controller.go Show resolved Hide resolved
controllers/policyconfig_controller.go Outdated Show resolved Hide resolved
controllers/policyconfig_controller.go Outdated Show resolved Hide resolved
controllers/policyconfig_controller.go Outdated Show resolved Hide resolved
api/v2beta2/policyconfig_types.go Show resolved Hide resolved
controllers/policyconfig_controller.go Show resolved Hide resolved
ahsayde
ahsayde previously approved these changes Feb 16, 2023
controllers/policyconfig_controller.go Outdated Show resolved Hide resolved
controllers/policyconfig_controller.go Outdated Show resolved Hide resolved
serboctor
serboctor previously approved these changes Feb 16, 2023
Copy link
Contributor

@serboctor serboctor left a comment

Choose a reason for hiding this comment

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

LGTM

ahsayde
ahsayde previously approved these changes Feb 19, 2023
ahsayde
ahsayde previously approved these changes Feb 19, 2023
@waleedhammam waleedhammam merged commit 273ef8f into dev Feb 19, 2023
@waleedhammam waleedhammam deleted the dev-policyconfig-status branch February 19, 2023 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants