Skip to content

Commit

Permalink
CLOUDP-202214 Error on MDB 7
Browse files Browse the repository at this point in the history
  • Loading branch information
slaskawi committed Sep 27, 2023
1 parent 1199b3a commit d897995
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion controllers/replica_set_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/blang/semver"
"github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -52,6 +54,8 @@ const (

lastSuccessfulConfiguration = "mongodb.com/v1.lastSuccessfulConfiguration"
lastAppliedMongoDBVersion = "mongodb.com/v1.lastAppliedMongoDBVersion"

ignoreMdb7ErrorEnvVar = "IGNORE_MDB_7_ERROR"
)

func init() {
Expand Down Expand Up @@ -622,7 +626,16 @@ func (r *ReplicaSetReconciler) buildService(mdb mdbv1.MongoDBCommunity, portMana
// it checks that the attempted Spec is valid in relation to the Spec that resulted from that last successful configuration.
// The validation also returns the lastSuccessFulConfiguration Spec as mdbv1.MongoDBCommunitySpec.
func (r ReplicaSetReconciler) validateSpec(mdb mdbv1.MongoDBCommunity) (error, *mdbv1.MongoDBCommunitySpec) {

if !envvar.ReadBool(ignoreMdb7ErrorEnvVar) {
semverVersion, err := semver.Make(mdb.Spec.Version)
if err != nil {
r.log.Warnf("could not parse version %v", mdb.Spec.Version)
} else {
if semverVersion.Major >= 7 {
return fmt.Errorf("monggodb >= 7 is not supported"), nil
}
}
}
lastSuccessfulConfigurationSaved, ok := mdb.Annotations[lastSuccessfulConfiguration]
if !ok {
// First version of Spec
Expand Down

0 comments on commit d897995

Please sign in to comment.