Skip to content

Commit 608e287

Browse files
authored
Merge branch 'main' into K8SPG-864
2 parents cbc67f5 + f9b2aa7 commit 608e287

32 files changed

Lines changed: 869 additions & 59 deletions

.github/copilot-instructions.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# GitHub Copilot Code Review Instructions
2+
3+
## Review Philosophy
4+
5+
- Only comment when you have HIGH CONFIDENCE (>80%) that an issue exists
6+
- Be concise
7+
- Focus on actionable feedback, not observations
8+
- If you're uncertain, stay silent—false positives reduce trust
9+
10+
## Project Context
11+
12+
Kubernetes Operator for PostgreSQL (Operator SDK, controller-runtime). Go + YAML. Key paths: `internal/`, `percona/`, `pkg/apis` and `e2e-tests/`.
13+
14+
## Priority Areas
15+
16+
### Security
17+
18+
- Hardcoded secrets, credentials, or API keys
19+
- SQL injection—use parameterized queries, never string concatenation
20+
- Missing or overly broad RBAC (`+kubebuilder:rbac` on reconcile functions)
21+
- Logging of secrets or sensitive data
22+
- Unvalidated user input before DB operations
23+
24+
### Correctness
25+
26+
- Logic errors that could cause panics or incorrect behavior
27+
- Race conditions, resource leaks (files, connections, memory)
28+
- Incorrect or missing error propagation
29+
- Error wrapping that doesn't add useful context
30+
- Redundant comments that restate what the code shows
31+
32+
### Imports and Dependencies
33+
34+
- Use standard import aliases: `corev1`, `appsv1`, `metav1`, `apierrors`, etc. (per `.golangci.yaml`)
35+
- Import order: standard, default, `github.com/percona` prefix
36+
37+
### Controller / Reconcile Logic
38+
39+
- Add `+kubebuilder:rbac` above reconcile functions that create/update K8s resources
40+
- Set controller/owner references for owned resources
41+
- Idempotent reconcile; handle `apierrors.IsConflict` with requeue
42+
43+
### Logging
44+
45+
- Prefer `logging.FromContext(ctx)` for loggers
46+
- Use structured fields: `log.Info("message", "key", value)`
47+
- Add logging for important operator actions (reconcile steps, errors, retries)
48+
49+
### Testing
50+
51+
- New features: expect unit tests and/or E2E (KUTTL) where appropriate
52+
- Unit tests should use `assert` and `require` from `github.com/stretchr/testify` wherever applicable
53+
- Utilize table driven tests when possible
54+
- Test names should describe the scenario
55+
56+
## Response Format
57+
58+
When you identify an issue:
59+
60+
1. **Problem** (1 sentence)
61+
2. **Why it matters** (1 sentence, only if not obvious)
62+
3. **Fix** (concrete suggestion or code snippet)
63+
64+
Example:
65+
```
66+
1. **Problem**: This map access can panic if the map is nil.
67+
2. **Why it matters**: A panic can crash the operator and disrupt reconciliation.
68+
3. **Fix**: Initialize the map before use, e.g. `m := make(map[string]string)` before assigning or reading.
69+
```
70+
71+
## When to Stay Silent
72+
73+
- You're uncertain whether something is an issue
74+
- The concern is stylistic and the code is acceptable
75+
- The fix would be a matter of preference, not correctness or security

Jenkinsfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ void createCluster(String CLUSTER_SUFFIX) {
88
export KUBECONFIG=/tmp/$CLUSTER_NAME-${CLUSTER_SUFFIX}
99
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
1010
gcloud config set project $GCP_PROJECT
11+
12+
printf 'linuxConfig:\n hugepageConfig:\n hugepage_size2m: 1024\n' > ${WORKSPACE}/hugepages-config-${CLUSTER_SUFFIX}.yaml
13+
1114
ret_num=0
1215
while [ \${ret_num} -lt 15 ]; do
1316
ret_val=0
@@ -28,11 +31,15 @@ void createCluster(String CLUSTER_SUFFIX) {
2831
--monitoring=NONE \
2932
--logging=NONE \
3033
--no-enable-managed-prometheus \
34+
--system-config-from-file=${WORKSPACE}/hugepages-config-${CLUSTER_SUFFIX}.yaml \
3135
--quiet && \
3236
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT".iam.gserviceaccount.com || ret_val=\$?
3337
if [ \${ret_val} -eq 0 ]; then break; fi
3438
ret_num=\$((ret_num + 1))
3539
done
40+
41+
rm -f ${WORKSPACE}/hugepages-config-${CLUSTER_SUFFIX}.yaml
42+
3643
if [ \${ret_num} -eq 15 ]; then
3744
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone ${region} --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone ${region} --quiet || true
3845
exit 1

build/crd/crunchy/generated/postgres-operator.crunchydata.com_postgresclusters.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9116,6 +9116,9 @@ spec:
91169116
description: Enable tracking latest restorable time
91179117
type: boolean
91189118
type: object
9119+
clusterServiceDNSSuffix:
9120+
description: K8SPG-694
9121+
type: string
91199122
config:
91209123
properties:
91219124
files:

build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9267,6 +9267,8 @@ spec:
92679267
are enabled
92689268
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
92699269
&& size(self.pgbackrest.repos) > 0)
9270+
clusterServiceDNSSuffix:
9271+
type: string
92709272
crVersion:
92719273
description: |-
92729274
Version of the operator. Update this to new version after operator

config/crd/bases/pgv2.percona.com_perconapgclusters.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9672,6 +9672,8 @@ spec:
96729672
are enabled
96739673
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
96749674
&& size(self.pgbackrest.repos) > 0)
9675+
clusterServiceDNSSuffix:
9676+
type: string
96759677
crVersion:
96769678
description: |-
96779679
Version of the operator. Update this to new version after operator

config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9106,6 +9106,9 @@ spec:
91069106
description: Enable tracking latest restorable time
91079107
type: boolean
91089108
type: object
9109+
clusterServiceDNSSuffix:
9110+
description: K8SPG-694
9111+
type: string
91099112
config:
91109113
properties:
91119114
files:

deploy/bundle.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9969,6 +9969,8 @@ spec:
99699969
are enabled
99709970
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
99719971
&& size(self.pgbackrest.repos) > 0)
9972+
clusterServiceDNSSuffix:
9973+
type: string
99729974
crVersion:
99739975
description: |-
99749976
Version of the operator. Update this to new version after operator
@@ -45432,6 +45434,9 @@ spec:
4543245434
description: Enable tracking latest restorable time
4543345435
type: boolean
4543445436
type: object
45437+
clusterServiceDNSSuffix:
45438+
description: K8SPG-694
45439+
type: string
4543545440
config:
4543645441
properties:
4543745442
files:

deploy/cr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ metadata:
1010
# - percona.com/delete-backups
1111
spec:
1212
crVersion: 2.9.0
13+
# clusterServiceDNSSuffix: cluster.local
1314
# initContainer:
1415
# image: docker.io/perconalab/percona-postgresql-operator:main
1516
# resources:

deploy/crd.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9969,6 +9969,8 @@ spec:
99699969
are enabled
99709970
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
99719971
&& size(self.pgbackrest.repos) > 0)
9972+
clusterServiceDNSSuffix:
9973+
type: string
99729974
crVersion:
99739975
description: |-
99749976
Version of the operator. Update this to new version after operator
@@ -45432,6 +45434,9 @@ spec:
4543245434
description: Enable tracking latest restorable time
4543345435
type: boolean
4543445436
type: object
45437+
clusterServiceDNSSuffix:
45438+
description: K8SPG-694
45439+
type: string
4543545440
config:
4543645441
properties:
4543745442
files:

deploy/cw-bundle.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9969,6 +9969,8 @@ spec:
99699969
are enabled
99709970
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
99719971
&& size(self.pgbackrest.repos) > 0)
9972+
clusterServiceDNSSuffix:
9973+
type: string
99729974
crVersion:
99739975
description: |-
99749976
Version of the operator. Update this to new version after operator
@@ -45432,6 +45434,9 @@ spec:
4543245434
description: Enable tracking latest restorable time
4543345435
type: boolean
4543445436
type: object
45437+
clusterServiceDNSSuffix:
45438+
description: K8SPG-694
45439+
type: string
4543545440
config:
4543645441
properties:
4543745442
files:

0 commit comments

Comments
 (0)