stolostron / klusterlet-addon-controller

Apache License 2.0
4 stars 22 forks source link

Enable policy addons to install themselves #96

Closed JustinKuli closed 2 years ago

JustinKuli commented 2 years ago

This enables the policy addons to be managed through their addon controller. As part of this migration, the "policy-addon" has been split into the config-policy-controller and the governance-policy-framework addons.

Refs:

Signed-off-by: Justin Kulikauskas jkulikau@redhat.com

JustinKuli commented 2 years ago

/hold

A git hook is failing on my end, but I don't quite know why:

❯ git commit
build/run-lint-check.sh
+ set -eo pipefail
+ GOLANGCI_LINT_VERSION=1.37.1
+ GOLANGCI_LINT_CACHE=/tmp/golangci-cache
++ go env GOOS
+ GOOS=darwin
++ go env GOPATH
+ GOPATH=/Users/jkulikau/go
+ export GOFLAGS=
+ GOFLAGS=
+ which golangci-lint
+ echo 'Running linting tool ...'
Running linting tool ...
++ GOLANGCI_LINT_CACHE=/tmp/golangci-cache
++ CGO_ENABLED=0
++ golangci-lint run -c build/golangci.yml
+ pkg/controller/klusterletaddon/globalproxy_controller_test.go:20:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/klusterletaddon/klusterlet_addon_components_test.go:19:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/klusterletaddon/klusterlet_addon_controller_test.go:27:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/klusterletaddon/klusterlet_addon_crds_test.go:17:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/klusterletaddon/klusterlet_addon_crs_test.go:30:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/utils/utils_test.go:30:17: SA1019: zap.Logger is deprecated: use 'New()' and the functional opts pattern instead: '(staticcheck)' 'logf.SetLogger(zap.Logger(true))' '^' pkg/utils/utils_test.go:24:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/clustermanagementaddon/cluster_management_addon_controller_test.go:16:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/csr/csr_controller_test.go:28:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/apis/agent/v1/image_utils_test.go:19:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/managedclusteraddon/managed_cluster_addon_controller_test.go:23:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^' pkg/controller/managedclusteraddon/managed_cluster_addon_registration_test.go:16:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. '(staticcheck)' '"sigs.k8s.io/controller-runtime/pkg/client/fake"' '^'
build/run-lint-check.sh: line 32: pkg/controller/klusterletaddon/globalproxy_controller_test.go:20:2:: No such file or directory
make: *** [lint] Error 1
JustinKuli commented 2 years ago

/cc @zhiweiyin318

While testing this, I didn't see the image overrides annotations that I was expecting. From what I found, the managedcluster did not have an image registry label, so the image overrides were not populated, see: https://github.com/stolostron/klusterlet-addon-controller/blob/main/pkg/controller/addon/klusterlet_addon_controller.go#L328

I was installing through https://github.com/dhaiducek/startrhacm, which uses https://github.com/stolostron/deploy, in case there is something weird there which is causing that.

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

zhiweiyin318 commented 2 years ago

thanks @JustinKuli . it looks good to me. feel free to unhold to merge it . the sonar failure is not introduced by this PR, I pushed a commit to fix the sonar failure in your PR. the git hook error may be caused y bdifferent versions of golangci-lint. anyway, ignore it. the image registry label is controlled by another CRD imageRegistry. I think there is some confusion here. the addon controller should fill the images to the values of addon charts, and the images have been filled in the operator helmRelease

$ oc get helmreleases.apps.open-cluster-management.io grc-a02e6 -o yaml
apiVersion: apps.open-cluster-management.io/v1
kind: HelmRelease
metadata:
  name: grc-a02e6
  namespace: open-cluster-management
  ownerReferences:
  - apiVersion: apps.open-cluster-management.io/v1
    kind: Subscription
    name: grc-sub
repo:
  chartName: grc
  digest: a9e1a7c4fccb8c6a8e7f80e54a6e02a7e26c4aa066a514bf84c9965d005d4550
  source:
    helmRepo:
      urls:
      - http://multiclusterhub-repo.open-cluster-management.svc.cluster.local:3000/charts/grc-2.5.0.tgz
    type: helmrepo
  version: 2.5.0
spec:
  global:
    imageOverrides:
   .....

the images are ACM release images, filled by installer. in some cases, the users want to use the custom images on the managed cluster, they will create an imageRegistry CR to override the release images. for search-addon I use env in search-operator chart to pass the image to search addon chart. you can refer to the PRs. https://github.com/stolostron/search-chart/pull/132 https://github.com/stolostron/search-operator/pull/99

zhiweiyin318 commented 2 years ago

/approve /lgtm

openshift-ci[bot] commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

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

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](https://github.com/stolostron/klusterlet-addon-controller/blob/main/OWNERS)~~ [zhiweiyin318] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
JustinKuli commented 2 years ago

/unhold