Skip to content

Commit caff9a3

Browse files
authored
Merge branch 'main' into K8SPG-778
2 parents 8c01118 + 54b12cc commit caff9a3

File tree

103 files changed

+3582
-2178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3582
-2178
lines changed

.e2eignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ CONTRIBUTING.md
77
LICENSE.md
88
README.md
99
.gitignore
10-
release_versions
10+
release_versions
11+
.e2eignore
12+
.snyk

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* @hors @egegunes @pooknull @nmarukovich @gkech
2-
/e2e-tests/ @ptankov @jvpasinatto @eleo007
3-
Jenkinsfile @ptankov @jvpasinatto @eleo007
2+
/e2e-tests/ @jvpasinatto @eleo007 @valmiranogueira
3+
Jenkinsfile @jvpasinatto @eleo007 @valmiranogueira

.github/workflows/reviewdog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
go-version: '^1.23'
1111
- uses: actions/checkout@v4
1212
- name: golangci-lint
13-
uses: golangci/golangci-lint-action@v7
13+
uses: golangci/golangci-lint-action@v8
1414
with:
1515
version: latest
1616
only-new-issues: true

.github/workflows/scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
make build-docker-image
3232
3333
- name: Run Trivy vulnerability scanner image (linux/arm64)
34-
uses: aquasecurity/trivy-action@0.30.0
34+
uses: aquasecurity/trivy-action@0.31.0
3535
with:
3636
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64'
3737
format: 'table'
@@ -50,7 +50,7 @@ jobs:
5050
make build-docker-image
5151
5252
- name: Run Trivy vulnerability scanner image (linux/amd64)
53-
uses: aquasecurity/trivy-action@0.30.0
53+
uses: aquasecurity/trivy-action@0.31.0
5454
with:
5555
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64'
5656
format: 'table'

.snyk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#SNYK - percona/percona-postgresql-operator
2+
3+
exclude:
4+
global:
5+
- e2e-tests/**
6+
- testing/**
7+
8+
version: v1.25.0
9+
ignore: {}
10+
patch: {}

CONTRIBUTING.md

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Contributing to Percona Operator for PostgreSQL
22

3+
We welcome contributions to the Percona Operator for PostgreSQL project and we're glad that you would like to become a Percona community member and participate in keeping open source open. For you to help us improve the Operator, please follow the guidelines below.
4+
35
## Prerequisites
46

5-
Before submitting code contributions, you should first complete the following prerequisites.
7+
Before submitting code contributions, complete the following prerequisites first.
68

79
### 1. Sign the CLA
810

@@ -16,40 +18,102 @@ Please make sure to read and observe the [Contribution Policy](code-of-conduct.m
1618

1719
### 1. Making a bug report
1820

19-
Improvement and bugfix tasks for Percona's projects are tracked in [Jira](https://jira.percona.com/projects/K8SPG/issues).
21+
We track improvement and bugfix tasks for Percona Operator project in [Jira](https://jira.percona.com/projects/K8SPG/issues).
2022

2123
Although not mandatory, it is a good practice to examine already open Jira issues first. For bigger contributions, we suggest creating a Jira issue and discussing it with the engineering team and community before proposing any code changes.
2224

2325
Another good place to discuss Percona's projects with developers and other community members is the [community forum](https://forums.percona.com).
2426

2527
### 2. Contributing to the source tree
2628

27-
Contributions to the source tree should follow the workflow described below:
29+
Follow the workflow described below:
30+
31+
1. [Fork the repository on GitHub](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo), clone your fork locally, and then [sync your local fork to upstream](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork). Make sure to always sync your fork with upstream before starting to work on any changes.
2832

29-
1. First, you need to [fork the repository on GitHub](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo), clone your fork locally, and then [sync your local fork to upstream](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork). After that, before starting to work on changes, make sure to always sync your fork with upstream.
30-
2. Create a branch for changes you are planning to make. If there is a Jira ticket related to your contribution, it is recommended to name your branch in the following way: `<Jira issue number>-<short description>`, where the issue number is something like `K8SPG-42`.
33+
2. Create a branch for changes you are planning to make. If there is a Jira ticket related to your contribution, name your branch in the following way: `<Jira issue number>-<short description>`, where the issue number is something like `K8SPG-42`.
3134

3235
Create the branch in your local repo as follows:
3336

3437
```
3538
$ git checkout -b K8SPG-42-fix-feature-X
3639
```
3740

38-
When your changes are ready, make a commit, mentioning the Jira issue in the commit message, if any:
41+
3. When your changes are ready, make a commit, mentioning the Jira issue in the commit message, if any:
3942

4043
```
4144
$ git add .
4245
$ git commit -m "K8SPG-42 fixed by ......"
4346
$ git push -u origin K8SPG-42-fix-feature-X
4447
```
4548

46-
3. Create a pull request to the main repository on GitHub.
47-
4. When the reviewer makes some comments, address any feedback that comes and update the pull request.
48-
5. When your contribution is accepted, your pull request will be approved and merged to the main branch.
49+
4. Create a pull request to the main repository on GitHub.
50+
5. [Build a custom Operator image based on your changes](#build-a-custom-operator-image) to verify that they work
51+
6. [Update deployment manifests](#update-deployment-manifests) to reflect your changes
52+
7. [Run e2e tests](#run-e2e-tests) to verify your changes are stable and robust.
53+
8. Someone from our team reviews your pull request. When the reviewer makes some comments, address any feedback that comes and update the pull request.
54+
9. When your contribution is accepted, your pull request will be approved and merged to the main branch.
55+
56+
#### Build a custom Operator image based on your changes
57+
58+
To build a new Operator image based on your local changes, do the following:
59+
60+
1. Set the `IMAGE` environment variable to the your image repository and tag. For example:
61+
62+
```
63+
$ export IMAGE=<your-repository>/percona-postgresql-operator:<feature-XYZ>
64+
```
65+
66+
Replace <your-repository> and <feature-XYZ> with your own values.
67+
68+
2. Build the Docker image and push it to the specified repository:
69+
70+
```
71+
$ make build-docker-image
72+
```
73+
74+
#### Update deployment manifests
75+
76+
Update the files under the `deploy/` directory to reflect any new fields in the resource API, a new image, etc. The `deploy/` directory contains the CRDs, bundles, and other manifests.
77+
78+
Run the following command to update deployment manifests:
79+
80+
```
81+
$ make generate VERSION=<feature-XYZ>
82+
```
83+
84+
`<feature-XYZ>` here is the tag of your built image.
85+
86+
Next, test your custom changes by deploying the Operator on your Kubernetes cluster.
87+
88+
First, deploy the Operator:
89+
90+
```
91+
$ kubectl apply --server-side -f deploy/bundle.yaml
92+
```
93+
94+
Then, deploy a Percona PostgreSQL cluster CRD:
95+
96+
```
97+
$ kubectl apply -f deploy/cr.yaml
98+
```
99+
100+
#### Run end-to-end tests
101+
102+
The Operator repository includes a collection of end-to-end (e2e) tests under the `e2e-tests/` directory. You can run these tests on your own Kubernetes cluster to ensure that your changes are robust and stable.
103+
104+
105+
To run a specific test by name, use the following command. In the example below, we run the `init-deploy` test:
106+
107+
```
108+
$ kubectl kuttl test --config e2e-tests/kuttl.yaml --test "^init-deploy\$" --skip-delete
109+
```
110+
111+
Replace `init-deploy` with the name of the test you want to run.
49112

50113
### 3. Contributing to documentation
51114

52115
The workflow for documentation is similar, but we store source code for the Percona Operator for PostgreSQL documentation in a [separate repository](https://github.com/percona/k8spg-docs).
116+
53117
See the [Documentation Contribution Guide](https://github.com/percona/k8spg-docs/blob/main/CONTRIBUTING.md) for more information.
54118

55119
### 4. Container images

Jenkinsfile

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
region="us-central1-a"
2-
testUrlPrefix="https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pg-operator"
3-
tests=[]
1+
region = 'us-central1-a'
2+
testUrlPrefix = "https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pg-operator"
3+
tests = []
44

55
void createCluster(String CLUSTER_SUFFIX) {
66
withCredentials([string(credentialsId: 'GCP_PROJECT_ID', variable: 'GCP_PROJECT'), file(credentialsId: 'gcloud-key-file', variable: 'CLIENT_SECRET_FILE')]) {
77
sh """
8-
NODES_NUM=3
98
export KUBECONFIG=/tmp/$CLUSTER_NAME-${CLUSTER_SUFFIX}
9+
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
10+
gcloud config set project $GCP_PROJECT
1011
ret_num=0
1112
while [ \${ret_num} -lt 15 ]; do
1213
ret_val=0
13-
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
14-
gcloud config set project $GCP_PROJECT
15-
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
16-
gcloud container clusters create --zone $region $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.30 --machine-type=n1-standard-4 --preemptible --disk-size 30 --num-nodes=\$NODES_NUM --network=jenkins-vpc --subnetwork=jenkins-${CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 --enable-ip-alias && \
14+
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
15+
gcloud container clusters create $CLUSTER_NAME-${CLUSTER_SUFFIX} \
16+
--preemptible \
17+
--zone=${region} \
18+
--machine-type='n1-standard-4' \
19+
--cluster-version='1.30' \
20+
--num-nodes=3 \
21+
--labels='delete-cluster-after-hours=6' \
22+
--disk-size=30 \
23+
--network=jenkins-vpc \
24+
--subnetwork=jenkins-${CLUSTER_SUFFIX} \
25+
--cluster-ipv4-cidr=/21 \
26+
--enable-ip-alias \
27+
--no-enable-autoupgrade \
28+
--monitoring=NONE \
29+
--logging=NONE \
30+
--no-enable-managed-prometheus \
31+
--quiet && \
1732
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT".iam.gserviceaccount.com || ret_val=\$?
1833
if [ \${ret_val} -eq 0 ]; then break; fi
1934
ret_num=\$((ret_num + 1))
2035
done
2136
if [ \${ret_num} -eq 15 ]; then
22-
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
37+
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
2338
exit 1
2439
fi
2540
"""
@@ -41,7 +56,7 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
4156
kubectl delete pods --all -n \$namespace --force --grace-period=0 || true
4257
done
4358
kubectl get svc --all-namespaces || true
44-
gcloud container clusters delete --zone $region $CLUSTER_NAME-${CLUSTER_SUFFIX}
59+
gcloud container clusters delete --zone ${region} $CLUSTER_NAME-${CLUSTER_SUFFIX}
4560
"""
4661
}
4762
}
@@ -65,7 +80,7 @@ void deleteOldClusters(String FILTER) {
6580
break
6681
fi
6782
done
68-
gcloud container clusters delete --async --zone $region --quiet \$GKE_CLUSTER || true
83+
gcloud container clusters delete --async --zone ${region} --quiet \$GKE_CLUSTER || true
6984
done
7085
fi
7186
"""
@@ -120,7 +135,7 @@ void markPassedTests() {
120135

121136
for (int i=0; i<tests.size(); i++) {
122137
def testName = tests[i]["name"]
123-
def file="${env.GIT_BRANCH}-${env.GIT_SHORT_COMMIT}-$testName"
138+
def file = "${env.GIT_BRANCH}-${env.GIT_SHORT_COMMIT}-$testName"
124139
def retFileExists = sh(script: "aws s3api head-object --bucket percona-jenkins-artifactory --key ${JOB_NAME}/${env.GIT_SHORT_COMMIT}/${file} >/dev/null 2>&1", returnStatus: true)
125140

126141
if (retFileExists == 0) {
@@ -149,26 +164,48 @@ void printKubernetesStatus(String LOCATION, String CLUSTER_SUFFIX) {
149164
"""
150165
}
151166

152-
TestsReport = '| Test name | Status |\r\n| ------------- | ------------- |'
167+
String formatTime(def time) {
168+
if (!time || time == "N/A") return "N/A"
169+
170+
try {
171+
def totalSeconds = time as Double
172+
def hours = (totalSeconds / 3600) as Integer
173+
def minutes = ((totalSeconds % 3600) / 60) as Integer
174+
def seconds = (totalSeconds % 60) as Integer
175+
176+
return String.format("%02d:%02d:%02d", hours, minutes, seconds)
177+
178+
} catch (Exception e) {
179+
println("Error converting time: ${e.message}")
180+
return time.toString()
181+
}
182+
}
183+
184+
TestsReport = '| Test Name | Result | Time |\r\n| ----------- | -------- | ------ |'
153185
TestsReportXML = '<testsuite name=\\"PG\\">\n'
154186

155187
void makeReport() {
156-
def wholeTestAmount=tests.size()
188+
def wholeTestAmount = tests.size()
157189
def startedTestAmount = 0
190+
def totalTestTime = 0
158191

159192
for (int i=0; i<tests.size(); i++) {
160193
def testName = tests[i]["name"]
161194
def testResult = tests[i]["result"]
162195
def testTime = tests[i]["time"]
163196
def testUrl = "${testUrlPrefix}/${env.GIT_BRANCH}/${env.GIT_SHORT_COMMIT}/${testName}.log"
164197

198+
if (testTime instanceof Number) {
199+
totalTestTime += testTime
200+
}
201+
165202
if (tests[i]["result"] != "skipped") {
166203
startedTestAmount++
167204
}
168-
TestsReport = TestsReport + "\r\n| "+ testName +" | ["+ testResult +"]("+ testUrl +") |"
205+
TestsReport = TestsReport + "\r\n| " + testName + " | [" + testResult + "](" + testUrl + ") | " + formatTime(testTime) + " |"
169206
TestsReportXML = TestsReportXML + '<testcase name=\\"' + testName + '\\" time=\\"' + testTime + '\\"><'+ testResult +'/></testcase>\n'
170207
}
171-
TestsReport = TestsReport + "\r\n| We run $startedTestAmount out of $wholeTestAmount|"
208+
TestsReport = TestsReport + "\r\n| We run $startedTestAmount out of $wholeTestAmount | | " + formatTime(totalTestTime) + " |"
172209
TestsReportXML = TestsReportXML + '</testsuite>\n'
173210

174211
sh """
@@ -244,10 +281,10 @@ void runTest(Integer TEST_ID) {
244281

245282
void prepareNode() {
246283
sh """
247-
sudo curl -s -L -o /usr/local/bin/kubectl https://dl.k8s.io/release/\$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
284+
sudo curl -sLo /usr/local/bin/kubectl https://dl.k8s.io/release/\$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
248285
kubectl version --client --output=yaml
249286
250-
curl -fsSL https://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gz | sudo tar -C /usr/local/bin --strip-components 1 -xzf - linux-amd64/helm
287+
curl -fsSL https://get.helm.sh/helm-v3.18.3-linux-amd64.tar.gz | sudo tar -C /usr/local/bin --strip-components 1 -xzf - linux-amd64/helm
251288
252289
sudo curl -fsSL https://github.com/mikefarah/yq/releases/download/v4.44.1/yq_linux_amd64 -o /usr/local/bin/yq && sudo chmod +x /usr/local/bin/yq
253290
sudo curl -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux64 -o /usr/local/bin/jq && sudo chmod +x /usr/local/bin/jq
@@ -258,8 +295,8 @@ void prepareNode() {
258295
259296
kubectl krew install assert
260297
261-
# v0.17.0 kuttl version
262-
kubectl krew install --manifest-url https://raw.githubusercontent.com/kubernetes-sigs/krew-index/336ef83542fd2f783bfa2c075b24599e834dcc77/plugins/kuttl.yaml
298+
# v0.22.0 kuttl version
299+
kubectl krew install --manifest-url https://raw.githubusercontent.com/kubernetes-sigs/krew-index/02d5befb2bc9554fdcd8386b8bfbed2732d6802e/plugins/kuttl.yaml
263300
echo \$(kubectl kuttl --version) is installed
264301
265302
sudo tee /etc/yum.repos.d/google-cloud-sdk.repo << EOF
@@ -459,7 +496,7 @@ pipeline {
459496
-v $WORKSPACE/src/github.com/percona/percona-postgresql-operator:/go/src/github.com/percona/percona-postgresql-operator \
460497
-w /go/src/github.com/percona/percona-postgresql-operator \
461498
-e GO111MODULE=on \
462-
golang:1.23 sh -c '
499+
golang:1.24 sh -c '
463500
go install github.com/google/go-licenses@latest;
464501
/go/bin/go-licenses csv github.com/percona/percona-postgresql-operator/cmd/postgres-operator \
465502
| cut -d , -f 3 \

0 commit comments

Comments
 (0)