diff --git a/apis/clusters/v1beta1/cassandra_types.go b/apis/clusters/v1beta1/cassandra_types.go index 060a043fd..71fdf78dc 100644 --- a/apis/clusters/v1beta1/cassandra_types.go +++ b/apis/clusters/v1beta1/cassandra_types.go @@ -395,7 +395,8 @@ func (cs *CassandraSpec) IsEqual(spec CassandraSpec) bool { cs.AreDCsEqual(spec.DataCentres) && cs.LuceneEnabled == spec.LuceneEnabled && cs.PasswordAndUserAuth == spec.PasswordAndUserAuth && - cs.IsSparkEqual(spec.Spark) + cs.IsSparkEqual(spec.Spark) && + cs.BundledUseOnly == spec.BundledUseOnly } func (cs *CassandraSpec) AreDCsEqual(dcs []*CassandraDataCentre) bool { diff --git a/apis/clusters/v1beta1/cassandra_webhook.go b/apis/clusters/v1beta1/cassandra_webhook.go index 8195d30f6..4d4a6fef6 100644 --- a/apis/clusters/v1beta1/cassandra_webhook.go +++ b/apis/clusters/v1beta1/cassandra_webhook.go @@ -160,6 +160,10 @@ func (cv *cassandraValidator) ValidateUpdate(ctx context.Context, old runtime.Ob return models.ErrTypeAssertion } + if oldCluster.Spec.BundledUseOnly && !oldCluster.Spec.IsEqual(c.Spec) { + return models.ErrBundledUseOnlyResourceUpdateIsNotSupported + } + if oldCluster.Spec.RestoreFrom != nil { return nil } diff --git a/apis/clusters/v1beta1/kafka_webhook.go b/apis/clusters/v1beta1/kafka_webhook.go index 4ce2a0868..47971e2ab 100644 --- a/apis/clusters/v1beta1/kafka_webhook.go +++ b/apis/clusters/v1beta1/kafka_webhook.go @@ -173,6 +173,10 @@ func (kv *kafkaValidator) ValidateUpdate(ctx context.Context, old runtime.Object return fmt.Errorf("cannot assert object %v to Kafka", old.GetObjectKind()) } + if oldKafka.Spec.BundledUseOnly && !oldKafka.Spec.IsEqual(k.Spec) { + return models.ErrBundledUseOnlyResourceUpdateIsNotSupported + } + err := k.Spec.validateUpdate(&oldKafka.Spec) if err != nil { return fmt.Errorf("cannot update, error: %v", err) diff --git a/apis/clusters/v1beta1/opensearch_webhook.go b/apis/clusters/v1beta1/opensearch_webhook.go index 5bf96e3b8..41c52dab0 100644 --- a/apis/clusters/v1beta1/opensearch_webhook.go +++ b/apis/clusters/v1beta1/opensearch_webhook.go @@ -211,6 +211,11 @@ func (osv *openSearchValidator) ValidateUpdate(ctx context.Context, old runtime. } oldCluster := old.(*OpenSearch) + + if oldCluster.Spec.BundledUseOnly && !oldCluster.Spec.IsEqual(os.Spec) { + return models.ErrBundledUseOnlyResourceUpdateIsNotSupported + } + if oldCluster.Spec.RestoreFrom != nil { return nil } diff --git a/controllers/clusters/cadence_controller.go b/controllers/clusters/cadence_controller.go index 3c95990b9..50aca3498 100644 --- a/controllers/clusters/cadence_controller.go +++ b/controllers/clusters/cadence_controller.go @@ -752,6 +752,7 @@ func (r *CadenceReconciler) newCassandraSpec(cadence *v1beta1.Cadence, latestCas }, DataCentres: cassandraDataCentres, PasswordAndUserAuth: cassPasswordAndUserAuth, + BundledUseOnly: true, } return &v1beta1.Cassandra{ @@ -996,6 +997,7 @@ func (r *CadenceReconciler) newKafkaSpec(cadence *v1beta1.Cadence, latestKafkaVe AllowDeleteTopics: true, AutoCreateTopics: true, ClientToClusterEncryption: clientEncryption, + BundledUseOnly: true, } return &v1beta1.Kafka{ @@ -1080,6 +1082,7 @@ func (r *CadenceReconciler) newOpenSearchSpec(cadence *v1beta1.Cadence, oldestOp }, DataCentres: osDataCentres, ClusterManagerNodes: managerNodes, + BundledUseOnly: true, } return &v1beta1.OpenSearch{ diff --git a/pkg/models/errors.go b/pkg/models/errors.go index 13b133067..f57193624 100644 --- a/pkg/models/errors.go +++ b/pkg/models/errors.go @@ -16,53 +16,56 @@ limitations under the License. package models -import "errors" +import ( + "errors" +) var ( - ErrNotEmptyCSRs = errors.New("certificate creation allowed only if the user is created on the specific cluster") - ErrEmptyCertGeneratingFields = errors.New("the fields for generating certificate signing request are empty") - ErrZeroDataCentres = errors.New("cluster spec doesn't have data centres") - ErrMoreThanOneKraft = errors.New("cluster spec does not support more than one kraft") - ErrMoreThanThreeControllerNodeCount = errors.New("kraft does not support more than three controller nodes") - ErrNetworkOverlaps = errors.New("cluster network overlaps") - ErrImmutableTwoFactorDelete = errors.New("twoFactorDelete field is immutable") - ErrImmutableCloudProviderSettings = errors.New("cloudProviderSettings are immutable") - ErrImmutableIntraDataCentreReplication = errors.New("intraDataCentreReplication fields are immutable") - ErrImmutableInterDataCentreReplication = errors.New("interDataCentreReplication fields are immutable") - ErrImmutableDataCentresNumber = errors.New("data centres number is immutable") - ErrImmutableSpark = errors.New("spark field is immutable") - ErrImmutableAWSSecurityGroupFirewallRule = errors.New("awsSecurityGroupFirewallRule is immutable") - ErrImmutableTags = errors.New("tags field is immutable") - ErrTypeAssertion = errors.New("unable to assert type") - ErrImmutableSchemaRegistry = errors.New("schema registry is immutable") - ErrImmutableRestProxy = errors.New("rest proxy is immutable") - ErrImmutableKraft = errors.New("kraft is immutable") - ErrImmutableKarapaceSchemaRegistry = errors.New("karapace schema registry is immutable") - ErrImmutableKarapaceRestProxy = errors.New("karapace rest proxy is immutable") - ErrImmutableDedicatedZookeeper = errors.New("dedicated zookeeper nodes cannot be changed") - ErrDecreasedDataCentresNumber = errors.New("data centres number cannot be decreased") - ErrImmutableTargetCluster = errors.New("TargetCluster field is immutable") - ErrImmutableExternalCluster = errors.New("ExternalCluster field is immutable") - ErrImmutableManagedCluster = errors.New("ManagedCluster field is immutable") - ErrIncorrectDayOfWeek = errors.New("dayOfWeek field is invalid") - ErrImmutableAWSArchival = errors.New("AWSArchival array is immutable") - ErrImmutableStandardProvisioning = errors.New("StandardProvisioning array is immutable") - ErrImmutableSharedProvisioning = errors.New("SharedProvisioning array is immutable") - ErrImmutablePackagedProvisioning = errors.New("PackagedProvisioning array is immutable") - ErrImmutableAdvancedVisibility = errors.New("AdvancedVisibility array is immutable") - ErrImmutablePrivateLink = errors.New("PrivateLink array is immutable") - ErrImmutableNodesNumber = errors.New("nodes number is immutable") - ErrImmutableSecretRef = errors.New("secret reference is immutable") - ErrEmptySecretRef = errors.New("secretRef.name and secretRef.namespace should not be empty") - ErrMissingSecretKeys = errors.New("the secret is missing the correct keys for the user") - ErrUserStillExist = errors.New("the user is still attached to the cluster. If you want to delete the user, remove the user from the cluster specification first") - ErrOnlyOneEntityTwoFactorDelete = errors.New("currently only one entity of two factor delete can be filled") - ErrPrivateLinkOnlyWithPrivateNetworkCluster = errors.New("private link is available only for private network clusters") - ErrPrivateLinkSupportedOnlyForSingleDC = errors.New("private link is only supported for a single data centre") - ErrPrivateLinkSupportedOnlyForAWS = errors.New("private link is supported only for an AWS cloud provider") - ErrImmutableSpec = errors.New("resource specification is immutable") - ErrUnsupportedBackupClusterKind = errors.New("backups for provided cluster kind are not supported") - ErrExposeServiceNotCreatedYet = errors.New("expose service is not created yet") - ErrExposeServiceEndpointsNotCreatedYet = errors.New("expose service endpoints is not created yet") - ErrOnlySingleConcurrentResizeAvailable = errors.New("only single concurrent resize is allowed") + ErrNotEmptyCSRs = errors.New("certificate creation allowed only if the user is created on the specific cluster") + ErrEmptyCertGeneratingFields = errors.New("the fields for generating certificate signing request are empty") + ErrZeroDataCentres = errors.New("cluster spec doesn't have data centres") + ErrMoreThanOneKraft = errors.New("cluster spec does not support more than one kraft") + ErrMoreThanThreeControllerNodeCount = errors.New("kraft does not support more than three controller nodes") + ErrNetworkOverlaps = errors.New("cluster network overlaps") + ErrImmutableTwoFactorDelete = errors.New("twoFactorDelete field is immutable") + ErrImmutableCloudProviderSettings = errors.New("cloudProviderSettings are immutable") + ErrImmutableIntraDataCentreReplication = errors.New("intraDataCentreReplication fields are immutable") + ErrImmutableInterDataCentreReplication = errors.New("interDataCentreReplication fields are immutable") + ErrImmutableDataCentresNumber = errors.New("data centres number is immutable") + ErrImmutableSpark = errors.New("spark field is immutable") + ErrImmutableAWSSecurityGroupFirewallRule = errors.New("awsSecurityGroupFirewallRule is immutable") + ErrImmutableTags = errors.New("tags field is immutable") + ErrTypeAssertion = errors.New("unable to assert type") + ErrImmutableSchemaRegistry = errors.New("schema registry is immutable") + ErrImmutableRestProxy = errors.New("rest proxy is immutable") + ErrImmutableKraft = errors.New("kraft is immutable") + ErrImmutableKarapaceSchemaRegistry = errors.New("karapace schema registry is immutable") + ErrImmutableKarapaceRestProxy = errors.New("karapace rest proxy is immutable") + ErrImmutableDedicatedZookeeper = errors.New("dedicated zookeeper nodes cannot be changed") + ErrDecreasedDataCentresNumber = errors.New("data centres number cannot be decreased") + ErrImmutableTargetCluster = errors.New("TargetCluster field is immutable") + ErrImmutableExternalCluster = errors.New("ExternalCluster field is immutable") + ErrImmutableManagedCluster = errors.New("ManagedCluster field is immutable") + ErrIncorrectDayOfWeek = errors.New("dayOfWeek field is invalid") + ErrImmutableAWSArchival = errors.New("AWSArchival array is immutable") + ErrImmutableStandardProvisioning = errors.New("StandardProvisioning array is immutable") + ErrImmutableSharedProvisioning = errors.New("SharedProvisioning array is immutable") + ErrImmutablePackagedProvisioning = errors.New("PackagedProvisioning array is immutable") + ErrImmutableAdvancedVisibility = errors.New("AdvancedVisibility array is immutable") + ErrImmutablePrivateLink = errors.New("PrivateLink array is immutable") + ErrImmutableNodesNumber = errors.New("nodes number is immutable") + ErrImmutableSecretRef = errors.New("secret reference is immutable") + ErrEmptySecretRef = errors.New("secretRef.name and secretRef.namespace should not be empty") + ErrMissingSecretKeys = errors.New("the secret is missing the correct keys for the user") + ErrUserStillExist = errors.New("the user is still attached to the cluster. If you want to delete the user, remove the user from the cluster specification first") + ErrOnlyOneEntityTwoFactorDelete = errors.New("currently only one entity of two factor delete can be filled") + ErrPrivateLinkOnlyWithPrivateNetworkCluster = errors.New("private link is available only for private network clusters") + ErrPrivateLinkSupportedOnlyForSingleDC = errors.New("private link is only supported for a single data centre") + ErrPrivateLinkSupportedOnlyForAWS = errors.New("private link is supported only for an AWS cloud provider") + ErrImmutableSpec = errors.New("resource specification is immutable") + ErrUnsupportedBackupClusterKind = errors.New("backups for provided cluster kind are not supported") + ErrExposeServiceNotCreatedYet = errors.New("expose service is not created yet") + ErrExposeServiceEndpointsNotCreatedYet = errors.New("expose service endpoints is not created yet") + ErrOnlySingleConcurrentResizeAvailable = errors.New("only single concurrent resize is allowed") + ErrBundledUseOnlyResourceUpdateIsNotSupported = errors.New("updating of bundled use resource is not supported") )