Skip to content

Commit

Permalink
issue-598, hadnling of updating bundled use only resources was implem…
Browse files Browse the repository at this point in the history
…ented
  • Loading branch information
Bohdan Siryk authored and Bohdan Siryk committed Oct 26, 2023
1 parent 9f2c68b commit acf5fce
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 48 deletions.
3 changes: 2 additions & 1 deletion apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions apis/clusters/v1beta1/cassandra_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions apis/clusters/v1beta1/kafka_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/opensearch_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions controllers/clusters/cadence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ func (r *CadenceReconciler) newCassandraSpec(cadence *v1beta1.Cadence, latestCas
},
DataCentres: cassandraDataCentres,
PasswordAndUserAuth: cassPasswordAndUserAuth,
BundledUseOnly: true,
}

return &v1beta1.Cassandra{
Expand Down Expand Up @@ -996,6 +997,7 @@ func (r *CadenceReconciler) newKafkaSpec(cadence *v1beta1.Cadence, latestKafkaVe
AllowDeleteTopics: true,
AutoCreateTopics: true,
ClientToClusterEncryption: clientEncryption,
BundledUseOnly: true,
}

return &v1beta1.Kafka{
Expand Down Expand Up @@ -1080,6 +1082,7 @@ func (r *CadenceReconciler) newOpenSearchSpec(cadence *v1beta1.Cadence, oldestOp
},
DataCentres: osDataCentres,
ClusterManagerNodes: managerNodes,
BundledUseOnly: true,
}

return &v1beta1.OpenSearch{
Expand Down
97 changes: 50 additions & 47 deletions pkg/models/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit acf5fce

Please sign in to comment.