Skip to content

Commit dd1c319

Browse files
chore(ci): Add test to check if user changes are preserved (#2512)
Add a test to ensure that OLM is not reverting user changes like kubectl rollout restart. Assisted-by: Cursor/Claude
1 parent 8ccea5a commit dd1c319

2 files changed

Lines changed: 449 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@BoxcutterRuntime
2+
Feature: Preserve user-managed fields on deployed resources
3+
Fields that OLM does not declare ownership of (e.g. user-applied annotations
4+
and labels) belong to other managers and must be preserved across reconciliation
5+
cycles.
6+
7+
Background:
8+
Given OLM is available
9+
And ClusterCatalog "test" serves bundles
10+
And ServiceAccount "olm-sa" with needed permissions is available in ${TEST_NAMESPACE}
11+
And ClusterExtension is applied
12+
"""
13+
apiVersion: olm.operatorframework.io/v1
14+
kind: ClusterExtension
15+
metadata:
16+
name: ${NAME}
17+
spec:
18+
namespace: ${TEST_NAMESPACE}
19+
serviceAccount:
20+
name: olm-sa
21+
source:
22+
sourceType: Catalog
23+
catalog:
24+
packageName: test
25+
selector:
26+
matchLabels:
27+
"olm.operatorframework.io/metadata.name": test-catalog
28+
"""
29+
And ClusterExtension is rolled out
30+
And ClusterExtension is available
31+
And resource "deployment/test-operator" is available
32+
33+
Scenario: User-added annotations and labels coexist with bundle-defined labels after reconciliation
34+
# The bundle defines labels on the deployment via the CSV spec; verify they are present
35+
Given resource "deployment/test-operator" has labels
36+
| key | value |
37+
| app.kubernetes.io/name | test-operator |
38+
When annotations are added to "deployment/test-operator"
39+
| key | value |
40+
| example.com/custom-annotation | my-value |
41+
And labels are added to "deployment/test-operator"
42+
| key | value |
43+
| example.com/custom-label | my-value |
44+
And ClusterExtension reconciliation is triggered
45+
And ClusterExtension has been reconciled the latest generation
46+
Then resource "deployment/test-operator" has annotations
47+
| key | value |
48+
| example.com/custom-annotation | my-value |
49+
And resource "deployment/test-operator" has labels
50+
| key | value |
51+
| example.com/custom-label | my-value |
52+
| app.kubernetes.io/name | test-operator |
53+
54+
Scenario: Deployment rollout restart persists after OLM reconciliation
55+
When rollout restart is performed on "deployment/test-operator"
56+
Then deployment "test-operator" pod template has annotation "kubectl.kubernetes.io/restartedAt"
57+
And deployment "test-operator" rollout is complete
58+
And deployment "test-operator" has 2 replica sets
59+
When ClusterExtension reconciliation is triggered
60+
And ClusterExtension has been reconciled the latest generation
61+
Then deployment "test-operator" pod template has annotation "kubectl.kubernetes.io/restartedAt"
62+
And deployment "test-operator" rollout is complete

0 commit comments

Comments
 (0)