Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for cluster webhooks were implemented #733

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,040 changes: 990 additions & 50 deletions .secrets.baseline

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions apis/clusters/v1beta1/cadence_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ func (cv *cadenceValidator) ValidateUpdate(ctx context.Context, old runtime.Obje
}
}

// ensuring if the cluster is ready for the spec updating
if (c.Status.CurrentClusterOperationStatus != models.NoOperation || c.Status.State != models.RunningStatus) && c.Generation != oldCluster.Generation {
if IsClusterNotReadyForSpecUpdate(c.Status.CurrentClusterOperationStatus, c.Status.State, c.Generation, oldCluster.Generation) {
return models.ErrClusterIsNotReadyToUpdate
}

Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type CassandraSpec struct {
GenericClusterSpec `json:",inline"`

RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty" dcomparisonSkip:"true"`
DataCentres []*CassandraDataCentre `json:"dataCentres,omitempty"`
DataCentres []*CassandraDataCentre `json:"dataCentres"`
LuceneEnabled bool `json:"luceneEnabled,omitempty"`
PasswordAndUserAuth bool `json:"passwordAndUserAuth,omitempty"`
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
Expand Down
15 changes: 3 additions & 12 deletions apis/clusters/v1beta1/cassandra_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ func (cv *cassandraValidator) ValidateCreate(ctx context.Context, obj runtime.Ob
}

if c.Spec.RestoreFrom != nil {
if c.Spec.RestoreFrom.ClusterID == "" {
return fmt.Errorf("restore clusterID field is empty")
} else {
return nil
}
return nil
}

err = c.Spec.GenericClusterSpec.ValidateCreation()
Expand All @@ -107,10 +103,6 @@ func (cv *cassandraValidator) ValidateCreate(ctx context.Context, obj runtime.Ob
return err
}

if len(c.Spec.DataCentres) == 0 {
return fmt.Errorf("data centres field is empty")
}

for _, dc := range c.Spec.DataCentres {
//TODO: add support of multiple DCs for OnPrem clusters
if len(c.Spec.DataCentres) > 1 && dc.CloudProvider == models.ONPREMISES {
Expand Down Expand Up @@ -180,11 +172,9 @@ func (cv *cassandraValidator) ValidateUpdate(ctx context.Context, old runtime.Ob
return fmt.Errorf("cannot update immutable fields: %v", err)
}

// ensuring if the cluster is ready for the spec updating
if (c.Status.CurrentClusterOperationStatus != models.NoOperation || c.Status.State != models.RunningStatus) && c.Generation != oldCluster.Generation {
if IsClusterNotReadyForSpecUpdate(c.Status.CurrentClusterOperationStatus, c.Status.State, c.Generation, oldCluster.Generation) {
return models.ErrClusterIsNotReadyToUpdate
}

return nil
}

Expand Down Expand Up @@ -297,6 +287,7 @@ func (cs *CassandraSpec) validateDataCentresUpdate(oldSpec CassandraSpec) error
return fmt.Errorf("number of nodes must be a multiple of replication factor: %v", newDC.ReplicationFactor)
}

continue
}

newDCImmutableFields := newDC.newImmutableFields()
Expand Down
Loading
Loading