Skip to content

Commit 38fc9f3

Browse files
authored
Merge branch 'main' into K8SPG-873
2 parents 93555f8 + f9b2aa7 commit 38fc9f3

21 files changed

Lines changed: 211 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
@@ -7381,6 +7381,9 @@ spec:
73817381
description: Enable tracking latest restorable time
73827382
type: boolean
73837383
type: object
7384+
clusterServiceDNSSuffix:
7385+
description: K8SPG-694
7386+
type: string
73847387
config:
73857388
properties:
73867389
files:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7532,6 +7532,8 @@ spec:
75327532
are enabled
75337533
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
75347534
&& size(self.pgbackrest.repos) > 0)
7535+
clusterServiceDNSSuffix:
7536+
type: string
75357537
crVersion:
75367538
description: |-
75377539
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
@@ -8143,6 +8143,8 @@ spec:
81438143
are enabled
81448144
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
81458145
&& size(self.pgbackrest.repos) > 0)
8146+
clusterServiceDNSSuffix:
8147+
type: string
81468148
crVersion:
81478149
description: |-
81488150
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
@@ -7371,6 +7371,9 @@ spec:
73717371
description: Enable tracking latest restorable time
73727372
type: boolean
73737373
type: object
7374+
clusterServiceDNSSuffix:
7375+
description: K8SPG-694
7376+
type: string
73747377
config:
73757378
properties:
73767379
files:

deploy/bundle.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8440,6 +8440,8 @@ spec:
84408440
are enabled
84418441
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
84428442
&& size(self.pgbackrest.repos) > 0)
8443+
clusterServiceDNSSuffix:
8444+
type: string
84438445
crVersion:
84448446
description: |-
84458447
Version of the operator. Update this to new version after operator
@@ -38322,6 +38324,9 @@ spec:
3832238324
description: Enable tracking latest restorable time
3832338325
type: boolean
3832438326
type: object
38327+
clusterServiceDNSSuffix:
38328+
description: K8SPG-694
38329+
type: string
3832538330
config:
3832638331
properties:
3832738332
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
@@ -8440,6 +8440,8 @@ spec:
84408440
are enabled
84418441
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
84428442
&& size(self.pgbackrest.repos) > 0)
8443+
clusterServiceDNSSuffix:
8444+
type: string
84438445
crVersion:
84448446
description: |-
84458447
Version of the operator. Update this to new version after operator
@@ -38322,6 +38324,9 @@ spec:
3832238324
description: Enable tracking latest restorable time
3832338325
type: boolean
3832438326
type: object
38327+
clusterServiceDNSSuffix:
38328+
description: K8SPG-694
38329+
type: string
3832538330
config:
3832638331
properties:
3832738332
files:

deploy/cw-bundle.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8440,6 +8440,8 @@ spec:
84408440
are enabled
84418441
rule: (has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos)
84428442
&& size(self.pgbackrest.repos) > 0)
8443+
clusterServiceDNSSuffix:
8444+
type: string
84438445
crVersion:
84448446
description: |-
84458447
Version of the operator. Update this to new version after operator
@@ -38322,6 +38324,9 @@ spec:
3832238324
description: Enable tracking latest restorable time
3832338325
type: boolean
3832438326
type: object
38327+
clusterServiceDNSSuffix:
38328+
description: K8SPG-694
38329+
type: string
3832538330
config:
3832638331
properties:
3832738332
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)