Skip to content

Commit 549f71b

Browse files
Jan-MFxKu
andauthored
Support EBS gp2 to gp3 migration on sync for below 1tb volumes (zalando#1242)
* initial commit for gp3 migration. * Default volume migration done. * Added Gomock and one test case with mock. * Dep update. * more changes for code gen. * push fake package. * Rename var. * Changes to Makefile and return value. * Macke mocks phony due to overlap in foldername. * Learning as one goes. Initialize map. * Wrong toggle. * Expect modify call. * Fix mapping of ids in test. * Fix volume id. * volume ids. * Fixing test setup. Late night... * create all pvs. * Fix test case config. * store volumes and compare. * More logs. * Logging of migration action. * Ensure to log errors. * Log warning if modify failed, e.g. due to ebs volume state. * Add more output. * Skip local e2e tests. * Reflect k8s volume id in test data. Extract aws volume id from k8s value. * Finalizing ebs migration. * More logs. describe fails. * Fix non existing fields in gp2 discovery. * Remove nothing to do flag for migration. * Final commit for migration. * add new options to all places Co-authored-by: Felix Kunde <[email protected]>
1 parent b9ef88f commit 549f71b

27 files changed

+565
-165
lines changed

.github/workflows/run_e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
go-version: "^1.15.5"
1818
- name: Make dependencies
19-
run: make deps
19+
run: make deps mocks
2020
- name: Compile
2121
run: make linux
2222
- name: Run unit tests

.github/workflows/run_tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
go-version: "^1.15.5"
1818
- name: Make dependencies
19-
run: make deps
19+
run: make deps mocks
2020
- name: Compile
2121
run: make linux
2222
- name: Run unit tests

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,5 @@ e2e/manifests
9898
# Translations
9999
*.mo
100100
*.pot
101+
102+
mocks

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean local test linux macos docker push scm-source.json e2e
1+
.PHONY: clean local test linux macos mocks docker push scm-source.json e2e
22

33
BINARY ?= postgres-operator
44
BUILD_FLAGS ?= -v
@@ -81,9 +81,12 @@ push:
8181
scm-source.json: .git
8282
echo '{\n "url": "git:$(GITURL)",\n "revision": "$(GITHEAD)",\n "author": "$(USER)",\n "status": "$(GITSTATUS)"\n}' > scm-source.json
8383

84+
mocks:
85+
GO111MODULE=on go generate ./...
86+
8487
tools:
85-
GO111MODULE=on go get -u honnef.co/go/tools/cmd/staticcheck
8688
GO111MODULE=on go get k8s.io/[email protected]
89+
GO111MODULE=on go get github.com/golang/mock/[email protected]
8790
GO111MODULE=on go mod tidy
8891

8992
fmt:

charts/postgres-operator/crds/operatorconfigurations.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ spec:
292292
type: string
293293
aws_region:
294294
type: string
295+
enable_ebs_gp3_migration:
296+
type: boolean
297+
enable_ebs_gp3_migration_max_size:
298+
type: integer
295299
gcp_credentials:
296300
type: string
297301
kube_iam_role:

charts/postgres-operator/values-crd.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ configAwsOrGcp:
219219
# AWS region used to store ESB volumes
220220
aws_region: eu-central-1
221221

222+
# enable automatic migration on AWS from gp2 to gp3 volumes
223+
enable_ebs_gp3_migration: false
224+
# defines maximum volume size in GB until which auto migration happens
225+
# enable_ebs_gp3_migration_max_size: 1000
226+
222227
# GCP credentials that will be used by the operator / pods
223228
# gcp_credentials: ""
224229

charts/postgres-operator/values.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ configAwsOrGcp:
211211
# AWS region used to store ESB volumes
212212
aws_region: eu-central-1
213213

214+
# enable automatic migration on AWS from gp2 to gp3 volumes
215+
enable_ebs_gp3_migration: "false"
216+
# defines maximum volume size in GB until which auto migration happens
217+
# enable_ebs_gp3_migration_max_size: 1000
218+
219+
# GCP credentials for setting the GOOGLE_APPLICATION_CREDNETIALS environment variable
220+
# gcp_credentials: ""
221+
214222
# AWS IAM role to supply in the iam.amazonaws.com/role annotation of Postgres pods
215223
# kube_iam_role: ""
216224

@@ -223,9 +231,6 @@ configAwsOrGcp:
223231
# GCS bucket to use for shipping WAL segments with WAL-E
224232
# wal_gs_bucket: ""
225233

226-
# GCP credentials for setting the GOOGLE_APPLICATION_CREDNETIALS environment variable
227-
# gcp_credentials: ""
228-
229234
# configure K8s cron job managed by the operator
230235
configLogicalBackup:
231236
# image for pods of the logical backup job (example runs pg_dumpall)

delivery.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pipeline:
3232
IMAGE=registry-write.opensource.zalan.do/acid/postgres-operator-test
3333
fi
3434
export IMAGE
35-
make deps docker
35+
make deps mocks docker
3636
- desc: 'Run unit tests'
3737
cmd: |
3838
export PATH=$PATH:$HOME/go/bin

docs/reference/operator_parameters.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,22 @@ yet officially supported.
518518
AWS region used to store EBS volumes. The default is `eu-central-1`.
519519

520520
* **additional_secret_mount**
521-
Additional Secret (aws or gcp credentials) to mount in the pod. The default is empty.
521+
Additional Secret (aws or gcp credentials) to mount in the pod.
522+
The default is empty.
522523

523524
* **additional_secret_mount_path**
524-
Path to mount the above Secret in the filesystem of the container(s). The default is empty.
525+
Path to mount the above Secret in the filesystem of the container(s).
526+
The default is empty.
527+
528+
* **enable_ebs_gp3_migration**
529+
enable automatic migration on AWS from gp2 to gp3 volumes, that are smaller
530+
than the configured max size (see below). This ignores that EBS gp3 is by
531+
default only 125 MB/sec vs 250 MB/sec for gp2 >= 333GB.
532+
The default is `false`.
533+
534+
* **enable_ebs_gp3_migration_max_size**
535+
defines the maximum volume size in GB until which auto migration happens.
536+
Default is 1000 (1TB) which matches 3000 IOPS.
525537

526538
## Logical backup
527539

go.mod

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
module github.com/zalando/postgres-operator
22

3-
go 1.14
3+
go 1.15
44

55
require (
6-
github.com/aws/aws-sdk-go v1.35.15
7-
github.com/lib/pq v1.8.0
6+
github.com/aws/aws-sdk-go v1.36.3
7+
github.com/golang/mock v1.4.4
8+
github.com/lib/pq v1.9.0
89
github.com/motomux/pretty v0.0.0-20161209205251-b2aad2c9a95d
910
github.com/r3labs/diff v1.1.0
1011
github.com/sirupsen/logrus v1.7.0
11-
github.com/stretchr/testify v1.5.1
12-
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
13-
golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb // indirect
14-
gopkg.in/yaml.v2 v2.2.8
15-
k8s.io/api v0.19.3
12+
github.com/stretchr/testify v1.6.1
13+
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c
14+
golang.org/x/mod v0.4.0 // indirect
15+
golang.org/x/tools v0.0.0-20201207204333-a835c872fcea // indirect
16+
gopkg.in/yaml.v2 v2.4.0
17+
k8s.io/api v0.19.4
1618
k8s.io/apiextensions-apiserver v0.19.3
17-
k8s.io/apimachinery v0.19.3
19+
k8s.io/apimachinery v0.19.4
1820
k8s.io/client-go v0.19.3
19-
k8s.io/code-generator v0.19.3
21+
k8s.io/code-generator v0.19.4
2022
)

0 commit comments

Comments
 (0)