Skip to content

Commit

Permalink
Remove the tech preview compliance history API
Browse files Browse the repository at this point in the history
  • Loading branch information
mprahl committed Oct 31, 2024
1 parent 95cde2e commit 78ea229
Show file tree
Hide file tree
Showing 40 changed files with 12 additions and 7,836 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ jobs:
name: coverage_e2e
path: coverage_e2e.out

- name: E2E Tests for Compliance Events API
run: |
KUBECONFIG=${PWD}/kubeconfig_hub make e2e-test-coverage-compliance-events-api
- name: Upload Compliance Events API Test Coverage
if: ${{ github.event_name == 'pull_request' && matrix.kind == 'latest'}}
uses: actions/upload-artifact@v4
with:
name: coverage_e2e_compliance_events_api
path: coverage_e2e_compliance_events_api.out

- name: Verify Deployment Configuration
run: |
make webhook
Expand Down Expand Up @@ -220,11 +209,6 @@ jobs:
with:
name: coverage_e2e

- name: Download Compliance Events Coverage Result
uses: actions/download-artifact@v4
with:
name: coverage_e2e_compliance_events_api

- name: Download PolicyAutomation Coverage Result
uses: actions/download-artifact@v4
with:
Expand Down
6 changes: 0 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"version": "0.2.0",
"configurations": [
// If you are running the compliance API tests (case 20) with this, pass the `--compliance-api-port=8385` to
// Ginkgo.
{
"name": "Launch Controller",
"type": "go",
Expand All @@ -14,14 +12,10 @@
"--log-level=4",
"-v=4",
"--enable-webhooks=false",
"--compliance-history-api-port=8385",
"--compliance-history-api-cert=dev-tls.crt",
"--compliance-history-api-key=dev-tls.key"
],
"env": {
"WATCH_NAMESPACE": "",
"KUBECONFIG": "${workspaceFolder}/kubeconfig_hub",
"WATCH_NAMESPACE_COMPLIANCE_EVENTS_STORE": "open-cluster-management"
}
},
// Set FDescribe or FIt on the test to debug. Then set the desired breakpoint.
Expand Down
42 changes: 2 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ CONTROLLER_NAMESPACE ?= open-cluster-management
# Handle KinD configuration
CLUSTER_NAME ?= hub
KIND_NAMESPACE ?= $(CONTROLLER_NAMESPACE)
POSTGRES_HOST ?= localhost

# Test coverage threshold
export COVERAGE_MIN ?= 74
Expand Down Expand Up @@ -143,11 +142,10 @@ generate-operator-yaml: kustomize manifests
############################################################

.PHONY: kind-bootstrap-cluster
kind-bootstrap-cluster: POSTGRES_HOST=postgres
kind-bootstrap-cluster: kind-bootstrap-cluster-dev webhook kind-deploy-controller install-resources

.PHONY: kind-bootstrap-cluster-dev
kind-bootstrap-cluster-dev: kind-create-cluster install-crds kind-controller-kubeconfig postgres
kind-bootstrap-cluster-dev: kind-create-cluster install-crds kind-controller-kubeconfig

cert-manager:
@echo Installing cert-manager
Expand All @@ -156,29 +154,6 @@ cert-manager:
kubectl wait deployment -n cert-manager cert-manager --for condition=Available=True --timeout=180s
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/instance=cert-manager -n cert-manager --timeout=180s

postgres: cert-manager
@echo "Installing Postgres"
-kubectl create ns $(KIND_NAMESPACE)
sed 's/open-cluster-management/$(KIND_NAMESPACE)/g' build/kind/postgres.yaml | kubectl apply --timeout=180s -f-

@echo "Waiting until the pods are up"
@sleep 3
kubectl -n $(KIND_NAMESPACE) wait --for=condition=Ready pod -l app=postgres

@echo "Creating the governance-policy-database secret"
@kubectl -n $(KIND_NAMESPACE) get secret governance-policy-database || \
kubectl -n $(KIND_NAMESPACE) create secret generic governance-policy-database \
--from-literal="user=grc" \
--from-literal="password=grc" \
--from-literal="host=$(POSTGRES_HOST)" \
--from-literal="dbname=ocm-compliance-history" \
--from-literal="ca=$$(kubectl -n $(KIND_NAMESPACE) get secret postgres-cert -o json | jq -r '.data["ca.crt"]' | base64 -d)"

@echo "Copying the compliance API certificates locally"
kubectl -n $(KIND_NAMESPACE) get secret compliance-api-cert -o json | jq -r '.data["tls.crt"]' | base64 -d > dev-tls.crt
kubectl -n $(KIND_NAMESPACE) get secret compliance-api-cert -o json | jq -r '.data["ca.crt"]' | base64 -d >> dev-ca.crt
kubectl -n $(KIND_NAMESPACE) get secret compliance-api-cert -o json | jq -r '.data["tls.key"]' | base64 -d > dev-tls.key

webhook: cert-manager
-kubectl create ns $(KIND_NAMESPACE)
sed -E 's,open-cluster-management(.svc|/|$$),$(KIND_NAMESPACE)\1,g' deploy/webhook.yaml | kubectl apply -f -
Expand Down Expand Up @@ -207,10 +182,6 @@ kind-deploy-controller-dev: kind-deploy-controller
kubectl rollout restart deployment/$(IMG) -n $(KIND_NAMESPACE)
kubectl rollout status -n $(KIND_NAMESPACE) deployment $(IMG) --timeout=180s

# Specify KIND_VERSION to indicate the version tag of the KinD image
.PHONY: kind-create-cluster
kind-create-cluster: KIND_ARGS += --config build/kind/kind-config.yaml

.PHONY: kind-delete-cluster
kind-delete-cluster:
kind delete cluster --name $(KIND_NAME)
Expand Down Expand Up @@ -256,7 +227,7 @@ install-resources:
@echo setting a Hub cluster DNS name
kubectl apply -f test/resources/case5_policy_automation/cluster-dns.yaml

E2E_LABEL_FILTER = --label-filter="!webhook && !compliance-events-api && !policyautomation"
E2E_LABEL_FILTER = --label-filter="!webhook && !policyautomation"
.PHONY: e2e-test
e2e-test: e2e-dependencies
$(GINKGO) -v --fail-fast $(E2E_TEST_ARGS) $(E2E_LABEL_FILTER) test/e2e -- $(E2E_TEST_CODE_ARGS)
Expand All @@ -265,14 +236,6 @@ e2e-test: e2e-dependencies
e2e-test-webhook: E2E_LABEL_FILTER = --label-filter="webhook"
e2e-test-webhook: e2e-test

.PHONY: e2e-test-compliance-events-api
e2e-test-compliance-events-api: E2E_LABEL_FILTER = --label-filter="compliance-events-api"
e2e-test-compliance-events-api: e2e-test

.PHONY: e2e-test-coverage-compliance-events-api
e2e-test-coverage-compliance-events-api: E2E_TEST_ARGS = --json-report=report_e2e_compliance_events_api.json --covermode=atomic --coverpkg=open-cluster-management.io/governance-policy-propagator/controllers/complianceeventsapi --coverprofile=coverage_e2e_compliance_events_api.out --output-dir=.
e2e-test-coverage-compliance-events-api: e2e-test-compliance-events-api

.PHONY: e2e-test-policyautomation
e2e-test-policyautomation: E2E_LABEL_FILTER = --label-filter="policyautomation"
e2e-test-policyautomation: e2e-test
Expand All @@ -296,7 +259,6 @@ e2e-stop-instrumented:

.PHONY: e2e-test-coverage
e2e-test-coverage: E2E_TEST_ARGS = --json-report=report_e2e.json --output-dir=.
e2e-test-coverage: E2E_TEST_CODE_ARGS = --compliance-api-port=8385
e2e-test-coverage: e2e-run-instrumented e2e-test e2e-stop-instrumented

.PHONY: e2e-test-coverage-policyautomation
Expand Down
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,6 @@ in particular, the details in `./deploy/manager/manager.yaml`. When any of those
deployment yaml `./deploy/operator.yaml` must be regenerated through the `make generate-operator-yaml` target. The
`./deploy/operator.yaml` SHOULD NOT be manually updated.

## Running the Compliance Events API

Create the KinD cluster and install Postgres with the following commands:

```bash
make kind-bootstrap-cluster-dev
```

You can connect to the Postgres server with the following command:

```bash
psql "host=localhost dbname=ocm-compliance-history user=grc password=grc"
```

Run the Governance Policy Propagator with the following command:

```bash
WATCH_NAMESPACE="" WATCH_NAMESPACE_COMPLIANCE_EVENTS_STORE="open-cluster-management" go run main.go --leader-elect=false --enable-webhooks=false
```

## References

- The `governance-policy-propagator` is part of the `open-cluster-management` community. For more information, visit:
Expand Down
2 changes: 1 addition & 1 deletion build/common/config/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ issues:
# Disable the lint failure about the name "stuttering"
- linters:
- revive
source: type (PolicyStatusReconciler|ComplianceDBSecretReconciler) struct
source: type (PolicyStatusReconciler) struct

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand Down
10 changes: 0 additions & 10 deletions build/kind/kind-config.yaml

This file was deleted.

158 changes: 0 additions & 158 deletions build/kind/postgres.yaml

This file was deleted.

Loading

0 comments on commit 78ea229

Please sign in to comment.