Skip to content

Commit 9e1ca93

Browse files
committed
Merge remote-tracking branch 'origin/master' into additionalPodLabels
2 parents fa58df8 + 51aa80a commit 9e1ca93

Some content is hidden

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

56 files changed

+2852
-509
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Added
2+
body: compatibility tests running automatically on each new tag
3+
time: 2024-12-04T15:35:50.352507104+01:00
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Added
2+
body: customize Database and Storage container securityContext
3+
time: 2024-12-09T18:25:00.648464+01:00
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Fixed
2+
body: regenerate CRDs in upload-artifacts workflow (as opposed to manually)
3+
time: 2024-11-29T21:38:09.848071991+01:00
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: compatibility-tests
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
test-compatibility:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Maximize build space
14+
uses: AdityaGarg8/[email protected]
15+
with:
16+
remove-android: 'true'
17+
remove-haskell: 'true'
18+
remove-codeql: 'true'
19+
remove-dotnet: 'true'
20+
remove-swapfile: 'true'
21+
22+
- name: checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # we need to know about previous tags
26+
27+
- name: print the latest version without "v"
28+
id: latest-no-v
29+
uses: miniscruff/changie-action@v2
30+
with:
31+
version: latest
32+
args: latest --remove-prefix
33+
34+
- name: determine-versions
35+
run: |
36+
NEW_VERSION=${{ steps.latest-no-v.outputs.output }}
37+
38+
# Extract the major and minor parts of the version
39+
MAJOR=$(echo $NEW_VERSION | cut -d. -f1)
40+
MINOR=$(echo $NEW_VERSION | cut -d. -f2)
41+
PREV_MINOR=$((MINOR - 1))
42+
43+
# Find the previous version tag in the format "<MAJOR>.<MINOR-1>.<LATEST_PATCH>"
44+
PREVIOUS_VERSION=$(git tag -l "${MAJOR}.${PREV_MINOR}.*" | sort --version-sort | tail -1)
45+
46+
# If no previous version is found, fallback to a default or handle the error somehow
47+
if [ -z "$PREVIOUS_VERSION" ]; then
48+
echo "No previous version found, ensure your repository has proper tags."
49+
exit 1
50+
fi
51+
52+
# remove after creating 0.6.0 tag.
53+
# Basically, we are incompatible with 0.4, and while there is no 0.6 (and prev minor being 0.5),
54+
# we will run compat tests from previous patch version
55+
if [ "$PREVIOUS_VERSION" = "0.4.42" ]; then
56+
PREVIOUS_VERSION="0.5.30"
57+
fi
58+
59+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
60+
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_ENV
61+
62+
- name: Setup Go
63+
uses: actions/setup-go@v3
64+
with:
65+
go-version: '1.22'
66+
67+
- name: Install dependencies
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y build-essential
71+
72+
curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl
73+
chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin
74+
75+
HELM_VERSION="v3.10.3"
76+
curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -zxvf - --strip-components=1 linux-amd64/helm
77+
chmod +x ./helm && sudo mv ./helm /usr/local/bin
78+
79+
go install sigs.k8s.io/[email protected]
80+
81+
curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash
82+
83+
echo "$(pwd)" >> $GITHUB_PATH
84+
echo "$HOME/ydb/bin" >> $GITHUB_PATH
85+
echo "$HOME/go/bin" >> $GITHUB_PATH
86+
87+
- name: Check dependencies
88+
run: |
89+
gcc --version
90+
go version
91+
kind version
92+
kubectl version --client=true
93+
helm version
94+
ydb version
95+
96+
- name: Setup k8s cluster
97+
run: |
98+
kind create cluster \
99+
--image=kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e \
100+
--config=./tests/cfg/kind-cluster-config.yaml
101+
102+
kubectl wait --timeout=5m --for=condition=ready node -l worker=true
103+
104+
- name: Run compatibility tests
105+
env:
106+
NEW_VERSION: ${{ env.NEW_VERSION }}
107+
PREVIOUS_VERSION: ${{ env.PREVIOUS_VERSION }}
108+
run: |
109+
go install gotest.tools/[email protected]
110+
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./tests/compatibility/... -ginkgo.vv -coverprofile cover.out
111+
112+
- name: convert-to-human-readable
113+
run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true
114+
115+
- name: artifact-upload-step
116+
uses: actions/upload-artifact@v4
117+
id: artifact-upload-step
118+
if: always()
119+
with:
120+
name: compat-tests-log
121+
path: log.txt
122+
if-no-files-found: error
123+
124+
- name: echo-tests-log-url
125+
run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}'
126+
127+
- name: Teardown k8s cluster
128+
run: |
129+
kind delete cluster

.github/workflows/create-release-pr.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: create-release-pr
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
bump_type:
7+
description: 'Which version to bump when creating a release PR: minor or patch?'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
514

615
jobs:
716
create-release-pr:
@@ -14,7 +23,7 @@ jobs:
1423
uses: miniscruff/changie-action@v2
1524
with:
1625
version: latest
17-
args: batch patch
26+
args: batch ${{ github.event.inputs.bump_type }}
1827

1928
- name: merge-changes
2029
uses: miniscruff/changie-action@v2
@@ -48,4 +57,8 @@ jobs:
4857
title: Release ${{ steps.latest.outputs.output }}
4958
branch: release/${{ steps.latest.outputs.output }}
5059
commit-message: Release ${{ steps.latest.outputs.output }}
60+
body: |
61+
Here is what a new entry in changelog would look like:
62+
63+
[`.changes/${{ steps.latest.outputs.output }}.md`](https://github.com/${{ github.repository }}/blob/release/${{ steps.latest.outputs.output }}/.changes/${{ steps.latest.outputs.output }}.md)
5164
token: ${{ github.token }}

.github/workflows/run-tests.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
sudo apt-get update
8383
sudo apt-get install -y build-essential
8484
85-
go install sigs.k8s.io/kind@v0.17.0
85+
go install sigs.k8s.io/kind@v0.25.0
8686
8787
curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl
8888
chmod +x ./kubectl
@@ -108,14 +108,10 @@ jobs:
108108
run: |
109109
kind delete cluster
110110
kind create cluster \
111-
--image=kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5 \
112-
--config=./e2e/kind-cluster-config.yaml
111+
--image=kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e \
112+
--config=./tests/cfg/kind-cluster-config.yaml
113113
114114
kubectl wait --timeout=5m --for=condition=ready node -l worker=true
115-
116-
kubectl label --overwrite node kind-worker topology.kubernetes.io/zone=fakeZone1
117-
kubectl label --overwrite node kind-worker2 topology.kubernetes.io/zone=fakeZone2
118-
kubectl label --overwrite node kind-worker3 topology.kubernetes.io/zone=fakeZone3
119115
- name: build-operator-image
120116
uses: docker/build-push-action@v3
121117
with:
@@ -138,7 +134,7 @@ jobs:
138134
kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 --nodes kind-worker,kind-worker2,kind-worker3
139135
- name: pull-and-load-ydb-image
140136
run: |
141-
YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./e2e/tests/**/*.go | grep -o -E '"cr\.yandex.*"')
137+
YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./tests/**/*.go | grep -o -E '"cr\.yandex.*"')
142138
YDB_IMAGE=${YDB_IMAGE:1:-1} # strip ""
143139
docker pull $YDB_IMAGE
144140
kind load docker-image $YDB_IMAGE --nodes kind-worker,kind-worker2,kind-worker3
@@ -148,7 +144,7 @@ jobs:
148144
- name: run-e2e-tests
149145
id: run-e2e-tests
150146
run: |
151-
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./e2e/... -ginkgo.vv
147+
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./tests/e2e/... -ginkgo.vv
152148
- name: convert-json-log-to-human-readable
153149
run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true
154150
- name: artifact-upload-step
@@ -164,4 +160,3 @@ jobs:
164160
- name: teardown-k8s-cluster
165161
run: |
166162
kind delete cluster
167-

.github/workflows/upload-artifacts.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
docker push cr.yandex/crpsjg1coh47p81vh2lc/ydb-kubernetes-operator:"$VERSION"
7575
- name: package-and-push-helm-chart
7676
run: |
77+
make manifests
78+
7779
helm package ./deploy/ydb-operator
7880
7981
# Push into internal oci-based registry

.golangci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,22 @@ output:
3737
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
3838
format: colored-line-number
3939

40-
# print lines of code with issue, default is true
4140
print-issued-lines: true
4241

43-
# print linter name in the end of issue text, default is true
4442
print-linter-name: true
4543

4644

4745
# all available settings of specific linters
4846
linters-settings:
47+
stylecheck:
48+
dot-import-whitelist:
49+
# used in tests only
50+
- "github.com/onsi/ginkgo/v2"
51+
# used in tests only
52+
- "github.com/onsi/gomega"
53+
# it's nice having string constants in a separate package, but without boilerplate
54+
- "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
55+
4956
errcheck:
5057
# report about not checking of errors in types assetions: `a := b.(MyStruct)`;
5158
# default is false: such cases aren't reported by default.
@@ -77,6 +84,7 @@ linters-settings:
7784
excludes:
7885
- G101
7986
- G115
87+
- G601 # no longer actual since 1.22
8088
fieldalignment:
8189
# print struct with more effective memory layout or not, false by default
8290
suggest-new: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[![run-tests](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/run-tests.yml)
21
[![upload-artifacts](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/upload-artifacts.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/upload-artifacts.yml)
2+
[![compatibility-tests](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/compatibility-tests.yaml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/compatibility-tests.yaml)
33

44
# YDB Kubernetes Operator
55

api/v1alpha1/database_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ type DatabaseNodeSpec struct {
172172
// (Optional) Additional custom resource annotations that are added to all resources
173173
// +optional
174174
AdditionalAnnotations map[string]string `json:"additionalAnnotations,omitempty"`
175+
176+
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
175177
}
176178

177179
type DatabaseResources struct {

0 commit comments

Comments
 (0)