Commit 3758eb7
feat: enable optional ServiceMonitor creation for Backstage CR (#1374)
* feat: enable optional ServiceMonitor creation for Backstage CR
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* adding the new spec.monitoring field to the CRD
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* Updated the CRD (config/crd/bases/rhdh.redhat.com_backstages.yaml) via make manifests. Implemented applyServiceMonitor logic in monitor.go. Added RBAC for ServiceMonitor and regenerated manager-role.
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* correct port and path endpoints
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* test monitoringv1
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* test: add minimal ServiceMonitor CRD for envtest integration tests
Envtest does not include the Prometheus Operator CRDs by default,
so tests that reconcile ServiceMonitor resources failed with
for kind ServiceMonitor in version monitoring.coreos.com/v1.
This commit adds a minimal CRD under
to make envtest aware of the resource type during integration tests.
This avoids pulling the full Prometheus Operator CRDs while keeping
tests lightweight and self-contained.
Fixes: integration test failures in BackstageReconciler when monitoring.enabled=true.
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Apply ServiceMonitor before Backstage model initialization, this way even if InitObjects() fails (like our deployment.yaml missing case), the ServiceMonitor still gets created.
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* The CRD is confirmed installed, so always allow ServiceMonitor creation
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* debugs
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* Switching from server-side apply (client.Apply) to a safer (controllerutil.CreateOrUpdate) do fix the error 'invalid object type: /, kind='' because client.Apply triggers a server-sideapply (ssa), which only works reliably for build-in K8s resouces or CRDs that fully support SSA. ServiceMonitor is a CRD from the Prometheus OPerator its openapi schema does not fully support ssa so the k8s api server cant determine its type it returns an empty kind hence error invalid object type
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Update: feat(operator): add optional ServiceMonitor support for Backstage CR
- Introduce in Backstage CRD
- Create/update ServiceMonitor only if Prometheus Operator CRD exists
- Gracefully skip with warning on vanilla Kubernetes clusters
- Delete ServiceMonitor when monitoring is disabled
- Idempotent creation with owner references for cleanup
Includes:
- CRD schema update for monitoring.enabled
- RBAC permissions for monitoring.coreos.com/servicemonitors
- ServiceMonitor creation logic in controller
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Updated main.go to register apiextensions.k8s.io/v1 types in the manager scheme so CRD lookups can be decoded properly
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Add RBAC to allow checking ServiceMonitor CRD (apiextensions.k8s.io) and persist it
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* update cache
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* fix scheme registration
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* add tests
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* update
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* fixup
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* fixup
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* fix test missing label
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* fix: remove duplicate API compatibility test
- Remove duplicate test from config-refresh_test.go
- Keep the dedicated test in cr-compatibility_test.go (from main)
- Clean up unused imports (bsv1alpha3, metav1)
- Fixes test duplication causing CI failures
* update
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* fix: restore ServiceMonitor scheme registration in integration tests
- Add back monitoringv1 import and AddToScheme() registration
- Add back external CRD directory to load ServiceMonitor CRDs
- Fix cr-compatibility test to use deployment spec validation instead of pod readiness
- This allows controller to properly clean up ServiceMonitors even when monitoring is disabled
Fixes the 'no kind is registered for the type v1.ServiceMonitor' error that was causing
12 integration test failures when the controller tried to delete ServiceMonitors.
* add: server side apply logic to Service Monitor to use the same resource management patterns
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* refactor: use direct ServiceMonitor creation instead of CRD pre-check. Replace explicit CRD existence check with direct creation and error handling.Reduces API calls and follows more idiomatic Kubernetes controller patterns.
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* resolving dependencies and tests
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* return true
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* update test
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* clean up error parcing logic
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* removing redundent code
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* fix test by removing TypeMeta assertions
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* remove redundent log
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* remove kubebuilder RBAC annotation from backstage_controller.go and regenerate bundle manifests
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* Regenerate bundle/installer manifests
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
* add typemeta and singleline patchoptions
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
* generate consistent naming to align with other objects
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
---------
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>1 parent ccbfc04 commit 3758eb7
19 files changed
Lines changed: 547 additions & 7 deletions
File tree
- api/v1alpha4
- bundle
- backstage.io/manifests
- rhdh/manifests
- cmd
- config
- crd
- bases
- external
- rbac
- dist
- backstage.io
- rhdh
- integration_tests
- internal/controller
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
| |||
329 | 341 | | |
330 | 342 | | |
331 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
142 | 154 | | |
143 | 155 | | |
144 | 156 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1512 | 1512 | | |
1513 | 1513 | | |
1514 | 1514 | | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
1515 | 1525 | | |
1516 | 1526 | | |
1517 | 1527 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
182 | 194 | | |
183 | 195 | | |
184 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1512 | 1512 | | |
1513 | 1513 | | |
1514 | 1514 | | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
1515 | 1525 | | |
1516 | 1526 | | |
1517 | 1527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1512 | 1512 | | |
1513 | 1513 | | |
1514 | 1514 | | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
1515 | 1525 | | |
1516 | 1526 | | |
1517 | 1527 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
49 | 61 | | |
50 | 62 | | |
51 | 63 | | |
| |||
0 commit comments