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 25, 2023
1 parent 9f2c68b commit f3a98d8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 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
6 changes: 5 additions & 1 deletion pkg/models/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ 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")
Expand Down Expand Up @@ -65,4 +67,6 @@ var (
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 f3a98d8

Please sign in to comment.