Skip to content

Commit 2898177

Browse files
authored
Merge branch 'main' into K8SPG-938_fix_conditions_update
2 parents ba5919f + f9b2aa7 commit 2898177

20 files changed

Lines changed: 201 additions & 59 deletions

File tree

.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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6965,6 +6965,9 @@ spec:
69656965
description: Enable tracking latest restorable time
69666966
type: boolean
69676967
type: object
6968+
clusterServiceDNSSuffix:
6969+
description: K8SPG-694
6970+
type: string
69686971
config:
69696972
properties:
69706973
files:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7116,6 +7116,8 @@ spec:
71167116
are enabled
71177117
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
71187118
&& size(self.pgbackrest.repos) > 0)
7119+
clusterServiceDNSSuffix:
7120+
type: string
71197121
crVersion:
71207122
description: |-
71217123
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
@@ -7521,6 +7521,8 @@ spec:
75217521
are enabled
75227522
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
75237523
&& size(self.pgbackrest.repos) > 0)
7524+
clusterServiceDNSSuffix:
7525+
type: string
75247526
crVersion:
75257527
description: |-
75267528
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
@@ -6955,6 +6955,9 @@ spec:
69556955
description: Enable tracking latest restorable time
69566956
type: boolean
69576957
type: object
6958+
clusterServiceDNSSuffix:
6959+
description: K8SPG-694
6960+
type: string
69586961
config:
69596962
properties:
69606963
files:

deploy/bundle.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7818,6 +7818,8 @@ spec:
78187818
are enabled
78197819
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
78207820
&& size(self.pgbackrest.repos) > 0)
7821+
clusterServiceDNSSuffix:
7822+
type: string
78217823
crVersion:
78227824
description: |-
78237825
Version of the operator. Update this to new version after operator
@@ -36871,6 +36873,9 @@ spec:
3687136873
description: Enable tracking latest restorable time
3687236874
type: boolean
3687336875
type: object
36876+
clusterServiceDNSSuffix:
36877+
description: K8SPG-694
36878+
type: string
3687436879
config:
3687536880
properties:
3687636881
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
@@ -7818,6 +7818,8 @@ spec:
78187818
are enabled
78197819
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
78207820
&& size(self.pgbackrest.repos) > 0)
7821+
clusterServiceDNSSuffix:
7822+
type: string
78217823
crVersion:
78227824
description: |-
78237825
Version of the operator. Update this to new version after operator
@@ -36871,6 +36873,9 @@ spec:
3687136873
description: Enable tracking latest restorable time
3687236874
type: boolean
3687336875
type: object
36876+
clusterServiceDNSSuffix:
36877+
description: K8SPG-694
36878+
type: string
3687436879
config:
3687536880
properties:
3687636881
files:

deploy/cw-bundle.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7818,6 +7818,8 @@ spec:
78187818
are enabled
78197819
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
78207820
&& size(self.pgbackrest.repos) > 0)
7821+
clusterServiceDNSSuffix:
7822+
type: string
78217823
crVersion:
78227824
description: |-
78237825
Version of the operator. Update this to new version after operator
@@ -36871,6 +36873,9 @@ spec:
3687136873
description: Enable tracking latest restorable time
3687236874
type: boolean
3687336875
type: object
36876+
clusterServiceDNSSuffix:
36877+
description: K8SPG-694
36878+
type: string
3687436879
config:
3687536880
properties:
3687636881
files:

internal/controller/postgrescluster/instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ func (r *Reconciler) reconcileInstanceCertificates(
14981498
var leafCert *pki.LeafCertificate
14991499

15001500
if err == nil {
1501-
leafCert, err = r.instanceCertificate(ctx, instance, existing, instanceCerts, root)
1501+
leafCert, err = r.instanceCertificate(ctx, instance, existing, instanceCerts, root, cluster.Spec.ClusterServiceDNSSuffix)
15021502
}
15031503
if err == nil {
15041504
err = patroni.InstanceCertificates(ctx,

0 commit comments

Comments
 (0)