Skip to content

Commit c1fd94a

Browse files
authored
CLOUDP-202214 Error on MDB 7 (#1396)
* CLOUDP-202214 Error on MDB 7 * Updated the error message * Release notes * Added unit test * Updated release notes
1 parent 76d4b13 commit c1fd94a

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

controllers/replica_set_controller.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"github.com/blang/semver"
8+
"github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar"
79
"os"
810
"strconv"
911
"strings"
@@ -52,6 +54,8 @@ const (
5254

5355
lastSuccessfulConfiguration = "mongodb.com/v1.lastSuccessfulConfiguration"
5456
lastAppliedMongoDBVersion = "mongodb.com/v1.lastAppliedMongoDBVersion"
57+
58+
ignoreMdb7ErrorEnvVar = "IGNORE_MDB_7_ERROR"
5559
)
5660

5761
func init() {
@@ -622,7 +626,16 @@ func (r *ReplicaSetReconciler) buildService(mdb mdbv1.MongoDBCommunity, portMana
622626
// it checks that the attempted Spec is valid in relation to the Spec that resulted from that last successful configuration.
623627
// The validation also returns the lastSuccessFulConfiguration Spec as mdbv1.MongoDBCommunitySpec.
624628
func (r ReplicaSetReconciler) validateSpec(mdb mdbv1.MongoDBCommunity) (error, *mdbv1.MongoDBCommunitySpec) {
625-
629+
if !envvar.ReadBool(ignoreMdb7ErrorEnvVar) {
630+
semverVersion, err := semver.Make(mdb.Spec.Version)
631+
if err != nil {
632+
r.log.Warnf("could not parse version %v", mdb.Spec.Version)
633+
} else {
634+
if semverVersion.Major >= 7 {
635+
return fmt.Errorf("mongodb >= 7.0.0 is not supported"), nil
636+
}
637+
}
638+
}
626639
lastSuccessfulConfigurationSaved, ok := mdb.Annotations[lastSuccessfulConfiguration]
627640
if !ok {
628641
// First version of Spec

controllers/replicaset_controller_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ func TestKubernetesResources_AreCreated(t *testing.T) {
171171
assert.NotEmpty(t, s.Data[automationconfig.ConfigKey])
172172
}
173173

174+
func TestKubernetesResources_MongoDB7IsRejected(t *testing.T) {
175+
mdb := newTestReplicaSet()
176+
mdb.Spec.Version = "7.0.0"
177+
178+
mgr := client.NewManager(&mdb)
179+
r := NewReconciler(mgr)
180+
181+
res, err := r.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: mdb.Namespace, Name: mdb.Name}})
182+
183+
assert.NoError(t, err)
184+
assert.Equal(t, true, res.Requeue)
185+
assert.Equal(t, time.Duration(0), res.RequeueAfter)
186+
}
187+
174188
func TestStatefulSet_IsCorrectlyConfigured(t *testing.T) {
175189
t.Setenv(construct.MongodbRepoUrl, "docker.io/mongodb")
176190
t.Setenv(construct.MongodbImageEnv, "mongodb-community-server")

docs/RELEASE_NOTES.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
1-
# MongoDB Kubernetes Operator 0.X.X
1+
# MongoDB Kubernetes Operator 0.8.3
22

33
## MongoDBCommunity Resource
44

55
- Changes
6-
- Introduced support for X.509 authentication for client and agent
7-
- `spec.security.authentication.modes` now supports value `X509`
8-
- The agent authentication mode will default to the value in `spec.security.authentication.modes` if there is only one specified.
9-
- Otherwise, agent authentication will need to be specified through `spec.security.authentication.agentMode`.
10-
- When agent authentication is set to `X509`, the field `spec.security.authentication.agentCertificateSecretRef` can be set (default is `agent-certs`).
11-
- The secret that `agentCertificateSecretRef` points to should contain a signed X.509 certificate (under the `tls.crt` key) and a private key (under `tls.key`) for the agent.
12-
- X.509 users can be added the same way as before under `spec.users`. The `db` field must be set to `$external` for X.509 authentication.
13-
- For these users, `scramCredentialsSecretName` and `passwordSecretRef` should **not** be set.
14-
- Sample resource [yaml](config/samples/mongodb.com_v1_mongodbcommunity_x509.yaml)
15-
- Sample agent certificate [yaml](config/samples/external_access/agent-certificate.yaml)
16-
- Add support for configuring [logRotate](https://www.mongodb.com/docs/ops-manager/current/reference/cluster-configuration/#mongodb-instances) on the automation-agent. The settings can be found under `processes[n].logRotate.<setting>`.
17-
- Additionally, [systemLog](https://www.mongodb.com/docs/manual/reference/configuration-options/#systemlog-options) can now be configured. In particular the settings: `path`, `destination` and `logAppend`.
18-
19-
# MongoDB Kubernetes Operator 0.8.2
20-
21-
## Kubernetes Operator
22-
23-
- Changes
24-
- Fix a bug when overriding tolerations causing an endless reconciliation loop ([1344](https://github.com/mongodb/mongodb-kubernetes-operator/issues/1344)).
25-
26-
## Updated Image Tags
27-
28-
- mongodb-kubernetes-operator:0.8.2
29-
- mongodb-agent:12.0.25.7724-1
30-
31-
_All the images can be found in:_
32-
33-
https://quay.io/mongodb
34-
https://hub.docker.com/r/mongodb/mongodb-community-server
6+
- MongoDB 7.0.0 and onwards is not supported. Supporting it requires a newer Automation Agent version. Until a new version is available, the Operator will fail all deployments with this version. To ignore this error and force the Operator to reconcile these resources, use `IGNORE_MDB_7_ERROR` environment variable and set it to `true`.

0 commit comments

Comments
 (0)