From ca74211cdcf306537a6a49ebf5c9d66ad2b72408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20G=C3=BCne=C5=9F?= Date: Mon, 29 May 2023 12:35:36 +0300 Subject: [PATCH 1/6] K8SPSMDB-807: Allow customizing replset name with custom config --- pkg/apis/psmdb/v1/psmdb_types.go | 22 ++++++++++++++++++++-- pkg/controller/perconaservermongodb/mgo.go | 12 +++++++++--- pkg/psmdb/client.go | 8 +++++++- pkg/psmdb/container.go | 8 ++++++-- pkg/psmdb/mongos.go | 8 +++++++- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/pkg/apis/psmdb/v1/psmdb_types.go b/pkg/apis/psmdb/v1/psmdb_types.go index ad262df31e..ac5a720034 100644 --- a/pkg/apis/psmdb/v1/psmdb_types.go +++ b/pkg/apis/psmdb/v1/psmdb_types.go @@ -6,13 +6,12 @@ import ( "strconv" "strings" - "gopkg.in/yaml.v2" - "github.com/go-logr/logr" v "github.com/hashicorp/go-version" "github.com/percona/percona-backup-mongodb/pbm" "github.com/percona/percona-backup-mongodb/pbm/compress" "github.com/pkg/errors" + "gopkg.in/yaml.v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -539,6 +538,25 @@ func (r *ReplsetSpec) PodFQDNWithPort(cr *PerconaServerMongoDB, podName string) return fmt.Sprintf("%s:%d", r.PodFQDN(cr, podName), MongodPort(cr)) } +func (r ReplsetSpec) CustomReplsetName() (string, error) { + var cfg struct { + Replication struct { + ReplSetName string `yaml:"replSetName,omitempty"` + } `yaml:"replication,omitempty"` + } + + err := yaml.Unmarshal([]byte(r.Configuration), &cfg) + if err != nil { + return cfg.Replication.ReplSetName, errors.Wrap(err, "unmarshal configuration") + } + + if len(cfg.Replication.ReplSetName) == 0 { + return cfg.Replication.ReplSetName, errors.New("replSetName is not configured") + } + + return cfg.Replication.ReplSetName, nil +} + type LivenessProbeExtended struct { corev1.Probe `json:",inline"` StartupDelaySeconds int `json:"startupDelaySeconds,omitempty"` diff --git a/pkg/controller/perconaservermongodb/mgo.go b/pkg/controller/perconaservermongodb/mgo.go index 6e17238c88..e1dcad3bba 100644 --- a/pkg/controller/perconaservermongodb/mgo.go +++ b/pkg/controller/perconaservermongodb/mgo.go @@ -523,7 +523,13 @@ func (r *ReconcilePerconaServerMongoDB) handleReplsetInit(ctx context.Context, c continue } - log.Info("initiating replset", "replset", replset.Name, "pod", pod.Name) + replsetName := replset.Name + name, err := replset.CustomReplsetName() + if err == nil { + replsetName = name + } + + log.Info("initiating replset", "replset", replsetName, "pod", pod.Name) host, err := psmdb.MongoHost(ctx, r.client, cr, replset.Name, replset.Expose.Enabled, pod) if err != nil { @@ -560,7 +566,7 @@ func (r *ReconcilePerconaServerMongoDB) handleReplsetInit(ctx context.Context, c } ) EOF - `, mongoCmd, replset.Name, host), + `, mongoCmd, replsetName, host), } errb.Reset() @@ -585,7 +591,7 @@ func (r *ReconcilePerconaServerMongoDB) handleReplsetInit(ctx context.Context, c return fmt.Errorf("exec add admin user: %v / %s / %s", err, outb.String(), errb.String()) } - log.Info("replset initialized", "replset", replset.Name, "pod", pod.Name) + log.Info("replset initialized", "replset", replsetName, "pod", pod.Name) return nil } diff --git a/pkg/psmdb/client.go b/pkg/psmdb/client.go index d1dcc42213..8a8aaa67d1 100644 --- a/pkg/psmdb/client.go +++ b/pkg/psmdb/client.go @@ -28,8 +28,14 @@ func MongoClient(ctx context.Context, k8sclient client.Client, cr *api.PerconaSe return nil, errors.Wrap(err, "get replset addr") } + rsName := rs.Name + name, err := rs.CustomReplsetName() + if err == nil { + rsName = name + } + conf := &mongo.Config{ - ReplSetName: rs.Name, + ReplSetName: rsName, Hosts: rsAddrs, Username: c.Username, Password: c.Password, diff --git a/pkg/psmdb/container.go b/pkg/psmdb/container.go index 7a85cdd04c..53da63f19c 100644 --- a/pkg/psmdb/container.go +++ b/pkg/psmdb/container.go @@ -154,8 +154,7 @@ func container(ctx context.Context, cr *api.PerconaServerMongoDB, replset *api.R } // containerArgs returns the args to pass to the mSpec container -func containerArgs(ctx context.Context, cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec, resources corev1.ResourceRequirements, - useConfigFile bool) []string { +func containerArgs(ctx context.Context, cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec, resources corev1.ResourceRequirements, useConfigFile bool) []string { // TODO(andrew): in the safe mode `sslAllowInvalidCertificates` should be set only with the external services args := []string{ "--bind_ip_all", @@ -168,6 +167,11 @@ func containerArgs(ctx context.Context, cr *api.PerconaServerMongoDB, replset *a "--sslAllowInvalidCertificates", } + name, err := replset.CustomReplsetName() + if err == nil { + args[4] = "--replSet=" + name + } + if cr.Spec.UnsafeConf { args = append(args, "--clusterAuthMode=keyFile", diff --git a/pkg/psmdb/mongos.go b/pkg/psmdb/mongos.go index c54c760e41..cdc8615309 100644 --- a/pkg/psmdb/mongos.go +++ b/pkg/psmdb/mongos.go @@ -244,9 +244,15 @@ func mongosContainerArgs(cr *api.PerconaServerMongoDB, resources corev1.Resource msSpec := cr.Spec.Sharding.Mongos cfgRs := cr.Spec.Sharding.ConfigsvrReplSet + cfgRsName := cfgRs.Name + name, err := cfgRs.CustomReplsetName() + if err == nil { + cfgRsName = name + } + // sort config instances to prevent unnecessary updates sort.Strings(cfgInstances) - configDB := fmt.Sprintf("%s/%s", cfgRs.Name, strings.Join(cfgInstances, ",")) + configDB := fmt.Sprintf("%s/%s", cfgRsName, strings.Join(cfgInstances, ",")) args := []string{ "mongos", "--bind_ip_all", From 4553100acb6113ab7b2ce786ab989ce948d12c8e Mon Sep 17 00:00:00 2001 From: Viacheslav Sarzhan Date: Fri, 23 Jun 2023 15:21:02 +0300 Subject: [PATCH 2/6] K8SPSMDB-807: fix backups for custom replSetName (#1238) * fix * fix sharding --------- Co-authored-by: Andrii Dema --- pkg/controller/perconaservermongodb/mgo.go | 19 +++++++++++++++---- .../perconaservermongodb/psmdb_controller.go | 7 +++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pkg/controller/perconaservermongodb/mgo.go b/pkg/controller/perconaservermongodb/mgo.go index e1dcad3bba..5073c769ec 100644 --- a/pkg/controller/perconaservermongodb/mgo.go +++ b/pkg/controller/perconaservermongodb/mgo.go @@ -187,20 +187,26 @@ func (r *ReconcilePerconaServerMongoDB) reconcileCluster(ctx context.Context, cr return api.AppStateError, errors.Wrap(err, "set default RW concern") } - in, err := inShard(ctx, mongosSession, replset.Name) + rsName := replset.Name + name, err := replset.CustomReplsetName() + if err == nil { + rsName = name + } + + in, err := inShard(ctx, mongosSession, rsName) if err != nil { return api.AppStateError, errors.Wrap(err, "get shard") } if !in { - log.Info("adding rs to shard", "rs", replset.Name) + log.Info("adding rs to shard", "rs", rsName) err := r.handleRsAddToShard(ctx, cr, replset, pods.Items[0], mongosPods[0]) if err != nil { return api.AppStateError, errors.Wrap(err, "add shard") } - log.Info("added to shard", "rs", replset.Name) + log.Info("added to shard", "rs", rsName) } rs := cr.Status.Replsets[replset.Name] @@ -503,7 +509,12 @@ func (r *ReconcilePerconaServerMongoDB) handleRsAddToShard(ctx context.Context, } }() - err = mongo.AddShard(ctx, cli, replset.Name, host) + rsName := replset.Name + name, err := replset.CustomReplsetName() + if err == nil { + rsName = name + } + err = mongo.AddShard(ctx, cli, rsName, host) if err != nil { return errors.Wrap(err, "failed to add shard") } diff --git a/pkg/controller/perconaservermongodb/psmdb_controller.go b/pkg/controller/perconaservermongodb/psmdb_controller.go index e016ddf7ff..c934255392 100644 --- a/pkg/controller/perconaservermongodb/psmdb_controller.go +++ b/pkg/controller/perconaservermongodb/psmdb_controller.go @@ -1511,8 +1511,11 @@ func (r *ReconcilePerconaServerMongoDB) reconcileStatefulSet( } if cr.Spec.Backup.Enabled { - agentC := backup.AgentContainer(cr, replset.Name) - sfsSpec.Template.Spec.Containers = append(sfsSpec.Template.Spec.Containers, agentC) + rsName := replset.Name + if name, err := replset.CustomReplsetName(); err == nil { + rsName = name + } + sfsSpec.Template.Spec.Containers = append(sfsSpec.Template.Spec.Containers, backup.AgentContainer(cr, rsName)) } pmmC := psmdb.AddPMMContainer(ctx, cr, secret, cr.Spec.PMM.MongodParams) From 3931224241ddf29f293b76d5a2e7857dc78e0ba1 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Sat, 22 Jul 2023 08:23:04 +0200 Subject: [PATCH 3/6] K8SPSMDB-807: Add custom-replset-name test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --------- Co-authored-by: Ege Güneş Co-authored-by: Viacheslav Sarzhan --- Jenkinsfile | 19 ++ .../custom-replset-name/compare/find-2nd.json | 4 + .../custom-replset-name/compare/find.json | 3 + .../conf/backup-aws-s3.yml | 7 + .../conf/backup-gcp-cs.yml | 7 + .../custom-replset-name/conf/backup-minio.yml | 7 + .../custom-replset-name/conf/restore.yml | 7 + .../custom-replset-name/conf/some-name.yml | 230 ++++++++++++++++++ e2e-tests/custom-replset-name/run | 75 ++++++ e2e-tests/functions | 8 +- e2e-tests/init-deploy/compare/backup-44.json | 1 - .../init-deploy/compare/clusterAdmin-44.json | 25 -- e2e-tests/run-distro.csv | 1 + e2e-tests/run-minikube.csv | 1 + e2e-tests/run-pr.csv | 1 + e2e-tests/run-release.csv | 1 + pkg/psmdb/container.go | 9 +- pkg/psmdb/mongos.go | 3 + 18 files changed, 376 insertions(+), 33 deletions(-) create mode 100644 e2e-tests/custom-replset-name/compare/find-2nd.json create mode 100644 e2e-tests/custom-replset-name/compare/find.json create mode 100644 e2e-tests/custom-replset-name/conf/backup-aws-s3.yml create mode 100644 e2e-tests/custom-replset-name/conf/backup-gcp-cs.yml create mode 100644 e2e-tests/custom-replset-name/conf/backup-minio.yml create mode 100644 e2e-tests/custom-replset-name/conf/restore.yml create mode 100644 e2e-tests/custom-replset-name/conf/some-name.yml create mode 100755 e2e-tests/custom-replset-name/run diff --git a/Jenkinsfile b/Jenkinsfile index 036ab6093a..b82088a39e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -428,7 +428,26 @@ pipeline { } stage('cluster4') { steps { +<<<<<<< HEAD clusterRunner('cluster4') +======= + CreateCluster('cluster2') + runTest('custom-replset-name', 'cluster2') + runTest('one-pod', 'cluster2') + runTest('ignore-labels-annotations', 'cluster2') + runTest('monitoring-2-0', 'cluster2') + runTest('arbiter', 'cluster2') + runTest('service-per-pod', 'cluster2') + runTest('liveness', 'cluster2') + runTest('smart-update', 'cluster2') + runTest('version-service', 'cluster2') + runTest('users', 'cluster2') + runTest('data-sharded', 'cluster2') + runTest('non-voting', 'cluster2') + runTest('demand-backup-eks-credentials', 'cluster2') + runTest('data-at-rest-encryption', 'cluster2') + ShutdownCluster('cluster2') +>>>>>>> e52ca30e (CUSTOM-149: Fix liveness probe if custom replset name for 1.14.0 (#1258)) } } stage('cluster5') { diff --git a/e2e-tests/custom-replset-name/compare/find-2nd.json b/e2e-tests/custom-replset-name/compare/find-2nd.json new file mode 100644 index 0000000000..d0a0868e32 --- /dev/null +++ b/e2e-tests/custom-replset-name/compare/find-2nd.json @@ -0,0 +1,4 @@ +switched to db myApp +{ "_id" : , "x" : 100500 } +{ "_id" : , "x" : 100501 } +bye diff --git a/e2e-tests/custom-replset-name/compare/find.json b/e2e-tests/custom-replset-name/compare/find.json new file mode 100644 index 0000000000..74495091bf --- /dev/null +++ b/e2e-tests/custom-replset-name/compare/find.json @@ -0,0 +1,3 @@ +switched to db myApp +{ "_id" : , "x" : 100500 } +bye diff --git a/e2e-tests/custom-replset-name/conf/backup-aws-s3.yml b/e2e-tests/custom-replset-name/conf/backup-aws-s3.yml new file mode 100644 index 0000000000..d7601c50e0 --- /dev/null +++ b/e2e-tests/custom-replset-name/conf/backup-aws-s3.yml @@ -0,0 +1,7 @@ +apiVersion: psmdb.percona.com/v1 +kind: PerconaServerMongoDBBackup +metadata: + name: backup-aws-s3 +spec: + psmdbCluster: some-name + storageName: aws-s3 diff --git a/e2e-tests/custom-replset-name/conf/backup-gcp-cs.yml b/e2e-tests/custom-replset-name/conf/backup-gcp-cs.yml new file mode 100644 index 0000000000..f176bdd05b --- /dev/null +++ b/e2e-tests/custom-replset-name/conf/backup-gcp-cs.yml @@ -0,0 +1,7 @@ +apiVersion: psmdb.percona.com/v1 +kind: PerconaServerMongoDBBackup +metadata: + name: backup-gcp-cs +spec: + psmdbCluster: some-name + storageName: gcp-cs diff --git a/e2e-tests/custom-replset-name/conf/backup-minio.yml b/e2e-tests/custom-replset-name/conf/backup-minio.yml new file mode 100644 index 0000000000..adfc0ba899 --- /dev/null +++ b/e2e-tests/custom-replset-name/conf/backup-minio.yml @@ -0,0 +1,7 @@ +apiVersion: psmdb.percona.com/v1 +kind: PerconaServerMongoDBBackup +metadata: + name: backup-minio +spec: + psmdbCluster: some-name + storageName: minio diff --git a/e2e-tests/custom-replset-name/conf/restore.yml b/e2e-tests/custom-replset-name/conf/restore.yml new file mode 100644 index 0000000000..32ab3c4b9a --- /dev/null +++ b/e2e-tests/custom-replset-name/conf/restore.yml @@ -0,0 +1,7 @@ +apiVersion: psmdb.percona.com/v1 +kind: PerconaServerMongoDBRestore +metadata: + name: +spec: + clusterName: some-name + backupName: diff --git a/e2e-tests/custom-replset-name/conf/some-name.yml b/e2e-tests/custom-replset-name/conf/some-name.yml new file mode 100644 index 0000000000..2d698ae981 --- /dev/null +++ b/e2e-tests/custom-replset-name/conf/some-name.yml @@ -0,0 +1,230 @@ +apiVersion: psmdb.percona.com/v1 +kind: PerconaServerMongoDB +metadata: + name: some-name +spec: + crVersion: 1.14.0 + allowUnsafeConfigurations: true + backup: + enabled: true + image: percona/percona-backup-mongodb:2.0.4 + pitr: + enabled: false + serviceAccountName: percona-server-mongodb-operator + storages: + aws-s3: + type: s3 + s3: + credentialsSecret: aws-s3-secret + region: us-east-1 + bucket: operator-testing + prefix: psmdb + minio: + type: s3 + s3: + credentialsSecret: minio-secret + region: us-east-1 + bucket: operator-testing + endpointUrl: http://minio-service:9000/ + gcp-cs: + type: s3 + s3: + credentialsSecret: gcp-cs-secret + region: us-east-1 + bucket: operator-testing + prefix: psmdb + endpointUrl: https://storage.googleapis.com + image: percona/percona-server-mongodb:4.4.10-11 + imagePullPolicy: Always + mongod: + net: + hostPort: 0 + port: 27017 + operationProfiling: + mode: slowOp + rateLimit: 100 + slowOpThresholdMs: 100 + security: + enableEncryption: false + encryptionCipherMode: AES256-CBC + encryptionKeySecret: tee-pro-mongodb-encryption-key + redactClientLogData: false + setParameter: + ttlMonitorSleepSecs: 60 + wiredTigerConcurrentReadTransactions: 128 + wiredTigerConcurrentWriteTransactions: 128 + storage: + engine: wiredTiger + inMemory: + engineConfig: + inMemorySizeRatio: 0.9 + wiredTiger: + collectionConfig: + blockCompressor: snappy + engineConfig: + cacheSizeRatio: 0.5 + directoryForIndexes: false + journalCompressor: snappy + indexConfig: + prefixCompression: true + pmm: + enabled: false + replsets: + - affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + arbiter: + affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + enabled: false + size: 1 + configuration: | + storage: + directoryPerDB: true + wiredTiger: + engineConfig: + directoryForIndexes: true + expose: + enabled: true + exposeType: ClusterIP + serviceAnnotations: + networking.gke.io/load-balancer-type: Internal + name: shard1 + podDisruptionBudget: + maxUnavailable: 1 + size: 3 + volumeSpec: + persistentVolumeClaim: + resources: + requests: + storage: 2Gi + storageClassName: standard-rwo + - affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + arbiter: + affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + enabled: false + size: 1 + configuration: | + storage: + directoryPerDB: true + wiredTiger: + engineConfig: + directoryForIndexes: true + expose: + enabled: true + exposeType: ClusterIP + serviceAnnotations: + networking.gke.io/load-balancer-type: Internal + name: shard3 + podDisruptionBudget: + maxUnavailable: 1 + size: 3 + volumeSpec: + persistentVolumeClaim: + resources: + requests: + storage: 2Gi + storageClassName: standard-rwo + - affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + arbiter: + affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + enabled: false + size: 1 + configuration: | + storage: + directoryPerDB: true + wiredTiger: + engineConfig: + directoryForIndexes: true + expose: + enabled: true + exposeType: ClusterIP + serviceAnnotations: + networking.gke.io/load-balancer-type: Internal + name: shard5 + podDisruptionBudget: + maxUnavailable: 1 + size: 3 + volumeSpec: + persistentVolumeClaim: + resources: + requests: + storage: 2Gi + storageClassName: standard-rwo + - affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + arbiter: + affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + enabled: false + size: 1 + configuration: | + storage: + directoryPerDB: true + wiredTiger: + engineConfig: + directoryForIndexes: true + expose: + enabled: true + exposeType: ClusterIP + serviceAnnotations: + networking.gke.io/load-balancer-type: Internal + name: shard7 + podDisruptionBudget: + maxUnavailable: 1 + size: 3 + volumeSpec: + persistentVolumeClaim: + resources: + requests: + storage: 2Gi + storageClassName: standard-rwo + secrets: + users: some-users + sharding: + configsvrReplSet: + affinity: + antiAffinityTopologyKey: topology.kubernetes.io/zone + configuration: | + replication: + replSetName: csReplSet + storage: + directoryPerDB: true + wiredTiger: + engineConfig: + directoryForIndexes: true + expose: + enabled: true + exposeType: ClusterIP + serviceAnnotations: + networking.gke.io/load-balancer-type: Internal + podDisruptionBudget: + maxUnavailable: 1 + size: 3 + volumeSpec: + persistentVolumeClaim: + resources: + requests: + storage: 5Gi + storageClassName: standard-rwo + enabled: true + mongos: + affinity: + antiAffinityTopologyKey: kubernetes.io/hostname + expose: + exposeType: LoadBalancer + serviceAnnotations: + networking.gke.io/load-balancer-type: Internal + podDisruptionBudget: + maxUnavailable: 1 + size: 3 + unmanaged: false + updateStrategy: SmartUpdate + upgradeOptions: + apply: Disabled + schedule: 0 2 * * * + setFCV: false + versionServiceEndpoint: https://check.percona.com diff --git a/e2e-tests/custom-replset-name/run b/e2e-tests/custom-replset-name/run new file mode 100755 index 0000000000..7d10accef3 --- /dev/null +++ b/e2e-tests/custom-replset-name/run @@ -0,0 +1,75 @@ +#!/bin/bash + +set -o errexit +set -o xtrace + +test_dir=$(realpath $(dirname $0)) +. ${test_dir}/../functions + +create_namespace $namespace +deploy_operator +apply_s3_storage_secrets +deploy_minio + +kubectl_bin apply -f $conf_dir/secrets.yml -f $conf_dir/client.yml -f $conf_dir/minio-secret.yml +cluster="some-name" + +desc 'create first PSMDB cluster' +apply_cluster $test_dir/conf/${cluster}.yml +wait_cluster_consistency $cluster + +desc 'write data, read from all' +run_mongos \ + 'db.createUser({user:"myApp",pwd:"myPass",roles:[{db:"myApp",role:"readWrite"}]})' \ + "userAdmin:userAdmin123456@$cluster-mongos.$namespace" +sleep 2 +run_mongos \ + 'use myApp\n db.test.insert({ x: 100500 })' \ + "myApp:myPass@$cluster-mongos.$namespace" +# compare_mongos_cmd "find" "myApp:myPass@$cluster-mongos.$namespace" + +wait_backup_agent $cluster-shard1-0 +wait_backup_agent $cluster-shard1-1 +wait_backup_agent $cluster-shard1-2 +wait_backup_agent $cluster-shard3-0 +wait_backup_agent $cluster-shard3-1 +wait_backup_agent $cluster-shard3-2 +wait_backup_agent $cluster-shard5-0 +wait_backup_agent $cluster-shard5-1 +wait_backup_agent $cluster-shard5-2 +wait_backup_agent $cluster-shard7-0 +wait_backup_agent $cluster-shard7-1 +wait_backup_agent $cluster-shard7-2 +backup_name_aws="backup-aws-s3" +backup_name_minio="backup-minio" +backup_name_gcp="backup-gcp-cs" + +desc 'run backups' +run_backup minio +wait_backup "$backup_name_minio" + +if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then + run_backup aws-s3 + run_backup gcp-cs + + wait_backup "$backup_name_aws" + wait_backup "$backup_name_gcp" +fi + +if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then + desc 'check backup and restore -- aws-s3' + run_restore $backup_name_aws 3 1 "-mongos" + wait_restore $backup_name_aws $cluster "ready" + + desc 'check backup and restore -- gcp-cs' + run_restore $backup_name_gcp 3 1 "-mongos" + wait_restore $backup_name_gcp $cluster "ready" +fi + +desc 'check backup and restore -- minio' +run_restore $backup_name_minio 3 1 "-mongos" + +sleep 120 +wait_restore $backup_name_minio $cluster "ready" + +destroy $namespace diff --git a/e2e-tests/functions b/e2e-tests/functions index 3384eb2573..f0478fa79a 100755 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -6,12 +6,8 @@ API="psmdb.percona.com/v1" OPERATOR_VERSION="1.15.0" IMAGE=${IMAGE:-"perconalab/percona-server-mongodb-operator:${GIT_BRANCH}"} IMAGE_PMM=${IMAGE_PMM:-"perconalab/pmm-client:dev-latest"} -IMAGE_MONGOD=${IMAGE_MONGOD:-"perconalab/percona-server-mongodb-operator:main-mongod5.0"} -IMAGE_MONGOD_CHAIN=${IMAGE_MONGOD_CHAIN:-$' -perconalab/percona-server-mongodb-operator:main-mongod4.4 -perconalab/percona-server-mongodb-operator:main-mongod5.0 -perconalab/percona-server-mongodb-operator:main-mongod6.0'} -IMAGE_BACKUP=${IMAGE_BACKUP:-"perconalab/percona-server-mongodb-operator:main-backup"} +IMAGE_MONGOD=${IMAGE_MONGOD:-"percona/percona-server-mongodb:4.4.10-11"} +IMAGE_BACKUP=${IMAGE_BACKUP:-"percona/percona-backup-mongodb:2.0.4"} SKIP_BACKUPS_TO_AWS_GCP_AZURE=${SKIP_BACKUPS_TO_AWS_GCP_AZURE:-1} PMM_SERVER_VER=${PMM_SERVER_VER:-"9.9.9"} IMAGE_PMM_SERVER_REPO=${IMAGE_PMM_SERVER_REPO:-"perconalab/pmm-server"} diff --git a/e2e-tests/init-deploy/compare/backup-44.json b/e2e-tests/init-deploy/compare/backup-44.json index 99be5f1e7d..3d371a8940 100644 --- a/e2e-tests/init-deploy/compare/backup-44.json +++ b/e2e-tests/init-deploy/compare/backup-44.json @@ -388,7 +388,6 @@ }, "actions": [ "appendOplogNote", - "applyOps", "checkFreeMonitoringStatus", "connPoolStats", "forceUUID", diff --git a/e2e-tests/init-deploy/compare/clusterAdmin-44.json b/e2e-tests/init-deploy/compare/clusterAdmin-44.json index 134049ab79..462ed06e56 100644 --- a/e2e-tests/init-deploy/compare/clusterAdmin-44.json +++ b/e2e-tests/init-deploy/compare/clusterAdmin-44.json @@ -142,23 +142,6 @@ "update" ] }, - { - "resource": { - "db": "local", - "collection": "system.healthlog" - }, - "actions": [ - "changeStream", - "collStats", - "dbHash", - "dbStats", - "find", - "killCursors", - "listCollections", - "listIndexes", - "planCacheRead" - ] - }, { "resource": { "db": "local", @@ -245,14 +228,6 @@ "unlock", "useUUID" ] - }, - { - "resource": { - "anyResource": true - }, - "actions": [ - "dbCheck" - ] } ] } diff --git a/e2e-tests/run-distro.csv b/e2e-tests/run-distro.csv index 48eae85cad..180999ac24 100644 --- a/e2e-tests/run-distro.csv +++ b/e2e-tests/run-distro.csv @@ -1,4 +1,5 @@ arbiter +custom-replset-name data-at-rest-encryption data-sharded default-cr diff --git a/e2e-tests/run-minikube.csv b/e2e-tests/run-minikube.csv index 33c58f302e..ca1ea822fa 100644 --- a/e2e-tests/run-minikube.csv +++ b/e2e-tests/run-minikube.csv @@ -1,4 +1,5 @@ arbiter +custom-replset-name default-cr demand-backup demand-backup-physical diff --git a/e2e-tests/run-pr.csv b/e2e-tests/run-pr.csv index ea43ddfc3e..50e9d9c9ea 100644 --- a/e2e-tests/run-pr.csv +++ b/e2e-tests/run-pr.csv @@ -1,4 +1,5 @@ arbiter +custom-replset-name cross-site-sharded data-at-rest-encryption data-sharded diff --git a/e2e-tests/run-release.csv b/e2e-tests/run-release.csv index 15c1dde6bb..1c225a93b4 100644 --- a/e2e-tests/run-release.csv +++ b/e2e-tests/run-release.csv @@ -1,4 +1,5 @@ arbiter +custom-replset-name cross-site-sharded data-at-rest-encryption data-sharded diff --git a/pkg/psmdb/container.go b/pkg/psmdb/container.go index 53da63f19c..230b0e42a0 100644 --- a/pkg/psmdb/container.go +++ b/pkg/psmdb/container.go @@ -80,10 +80,17 @@ func container(ctx context.Context, cr *api.PerconaServerMongoDB, replset *api.R MountPath: "/etc/users-secret", }) } + hostPort := int32(0) if cr.CompareVersion("1.12.0") < 0 { hostPort = cr.Spec.Mongod.Net.HostPort } + + rsName := replset.Name + if name, err := replset.CustomReplsetName(); err == nil { + rsName = name + } + container := corev1.Container{ Name: name, Image: cr.Spec.Image, @@ -111,7 +118,7 @@ func container(ctx context.Context, cr *api.PerconaServerMongoDB, replset *api.R }, { Name: "MONGODB_REPLSET", - Value: replset.Name, + Value: rsName, }, }, EnvFrom: []corev1.EnvFromSource{ diff --git a/pkg/psmdb/mongos.go b/pkg/psmdb/mongos.go index 875b046af9..37c1a9b73c 100644 --- a/pkg/psmdb/mongos.go +++ b/pkg/psmdb/mongos.go @@ -235,6 +235,9 @@ func mongosContainer(cr *api.PerconaServerMongoDB, useConfigFile bool, cfgInstan if cr.CompareVersion("1.14.0") >= 0 { container.Command = []string{BinMountPath + "/ps-entry.sh"} + + container.LivenessProbe.Exec.Command[0] = "/opt/percona/mongodb-healthcheck" + container.ReadinessProbe.Exec.Command[0] = "/opt/percona/mongodb-healthcheck" } return container, nil From 7465ee79cfc0614ea4f461e112a37b1f6f693acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20G=C3=BCne=C5=9F?= Date: Wed, 23 Aug 2023 08:28:49 +0300 Subject: [PATCH 4/6] fix Jenkinsfile --- Jenkinsfile | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b82088a39e..036ab6093a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -428,26 +428,7 @@ pipeline { } stage('cluster4') { steps { -<<<<<<< HEAD clusterRunner('cluster4') -======= - CreateCluster('cluster2') - runTest('custom-replset-name', 'cluster2') - runTest('one-pod', 'cluster2') - runTest('ignore-labels-annotations', 'cluster2') - runTest('monitoring-2-0', 'cluster2') - runTest('arbiter', 'cluster2') - runTest('service-per-pod', 'cluster2') - runTest('liveness', 'cluster2') - runTest('smart-update', 'cluster2') - runTest('version-service', 'cluster2') - runTest('users', 'cluster2') - runTest('data-sharded', 'cluster2') - runTest('non-voting', 'cluster2') - runTest('demand-backup-eks-credentials', 'cluster2') - runTest('data-at-rest-encryption', 'cluster2') - ShutdownCluster('cluster2') ->>>>>>> e52ca30e (CUSTOM-149: Fix liveness probe if custom replset name for 1.14.0 (#1258)) } } stage('cluster5') { From 86f1941f821e32dc13a422c14666386d39ea8b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20G=C3=BCne=C5=9F?= Date: Fri, 8 Sep 2023 16:16:51 +0300 Subject: [PATCH 5/6] fix images --- e2e-tests/functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-tests/functions b/e2e-tests/functions index 438bdcd138..874945b418 100755 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -6,8 +6,8 @@ API="psmdb.percona.com/v1" OPERATOR_VERSION="1.15.0" IMAGE=${IMAGE:-"perconalab/percona-server-mongodb-operator:${GIT_BRANCH}"} IMAGE_PMM=${IMAGE_PMM:-"perconalab/pmm-client:dev-latest"} -IMAGE_MONGOD=${IMAGE_MONGOD:-"percona/percona-server-mongodb:4.4.10-11"} -IMAGE_BACKUP=${IMAGE_BACKUP:-"percona/percona-backup-mongodb:2.0.4"} +IMAGE_MONGOD=${IMAGE_MONGOD:-"perconalab/percona-server-mongodb-operator:main-mongod5.0"} +IMAGE_BACKUP=${IMAGE_BACKUP:-"perconalab/percona-server-mongodb-operator:main-backup"} SKIP_BACKUPS_TO_AWS_GCP_AZURE=${SKIP_BACKUPS_TO_AWS_GCP_AZURE:-1} PMM_SERVER_VER=${PMM_SERVER_VER:-"9.9.9"} IMAGE_PMM_SERVER_REPO=${IMAGE_PMM_SERVER_REPO:-"perconalab/pmm-server"} From 5d9ea86b393e5a0f2b1160e2688dd04046137093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20G=C3=BCne=C5=9F?= Date: Mon, 11 Sep 2023 10:32:59 +0300 Subject: [PATCH 6/6] address review comments --- .../custom-replset-name/conf/some-name.yml | 31 ------------------- e2e-tests/functions | 4 +++ pkg/psmdb/mongos.go | 2 ++ 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/e2e-tests/custom-replset-name/conf/some-name.yml b/e2e-tests/custom-replset-name/conf/some-name.yml index 2d698ae981..4ac3efb960 100644 --- a/e2e-tests/custom-replset-name/conf/some-name.yml +++ b/e2e-tests/custom-replset-name/conf/some-name.yml @@ -36,37 +36,6 @@ spec: endpointUrl: https://storage.googleapis.com image: percona/percona-server-mongodb:4.4.10-11 imagePullPolicy: Always - mongod: - net: - hostPort: 0 - port: 27017 - operationProfiling: - mode: slowOp - rateLimit: 100 - slowOpThresholdMs: 100 - security: - enableEncryption: false - encryptionCipherMode: AES256-CBC - encryptionKeySecret: tee-pro-mongodb-encryption-key - redactClientLogData: false - setParameter: - ttlMonitorSleepSecs: 60 - wiredTigerConcurrentReadTransactions: 128 - wiredTigerConcurrentWriteTransactions: 128 - storage: - engine: wiredTiger - inMemory: - engineConfig: - inMemorySizeRatio: 0.9 - wiredTiger: - collectionConfig: - blockCompressor: snappy - engineConfig: - cacheSizeRatio: 0.5 - directoryForIndexes: false - journalCompressor: snappy - indexConfig: - prefixCompression: true pmm: enabled: false replsets: diff --git a/e2e-tests/functions b/e2e-tests/functions index 874945b418..512da38525 100755 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -7,6 +7,10 @@ OPERATOR_VERSION="1.15.0" IMAGE=${IMAGE:-"perconalab/percona-server-mongodb-operator:${GIT_BRANCH}"} IMAGE_PMM=${IMAGE_PMM:-"perconalab/pmm-client:dev-latest"} IMAGE_MONGOD=${IMAGE_MONGOD:-"perconalab/percona-server-mongodb-operator:main-mongod5.0"} +IMAGE_MONGOD_CHAIN=${IMAGE_MONGOD_CHAIN:-$' +perconalab/percona-server-mongodb-operator:main-mongod4.4 +perconalab/percona-server-mongodb-operator:main-mongod5.0 +perconalab/percona-server-mongodb-operator:main-mongod6.0'} IMAGE_BACKUP=${IMAGE_BACKUP:-"perconalab/percona-server-mongodb-operator:main-backup"} SKIP_BACKUPS_TO_AWS_GCP_AZURE=${SKIP_BACKUPS_TO_AWS_GCP_AZURE:-1} PMM_SERVER_VER=${PMM_SERVER_VER:-"9.9.9"} diff --git a/pkg/psmdb/mongos.go b/pkg/psmdb/mongos.go index 48245bab47..cc4467b6ab 100644 --- a/pkg/psmdb/mongos.go +++ b/pkg/psmdb/mongos.go @@ -237,7 +237,9 @@ func mongosContainer(cr *api.PerconaServerMongoDB, useConfigFile bool, cfgInstan if cr.CompareVersion("1.14.0") >= 0 { container.Command = []string{BinMountPath + "/ps-entry.sh"} + } + if cr.CompareVersion("1.15.0") >= 0 { container.LivenessProbe.Exec.Command[0] = "/opt/percona/mongodb-healthcheck" container.ReadinessProbe.Exec.Command[0] = "/opt/percona/mongodb-healthcheck" }