Skip to content

Commit

Permalink
external changes on several failed updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ribaraka authored and OleksiienkoMykyta committed Jan 24, 2024
1 parent 57adbaf commit 7733c4d
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 108 deletions.
51 changes: 49 additions & 2 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ type CassandraDataCentre struct {

// Adds the specified version of Debezium Connector Cassandra to the Cassandra cluster
// +kubebuilder:validation:MaxItems=1
Debezium []DebeziumCassandraSpec `json:"debezium,omitempty"`
Debezium []DebeziumCassandraSpec `json:"debezium,omitempty"`
PrivateLink bool `json:"privateLink,omitempty"`
ShotoverProxy []ShotoverProxySpec `json:"shotoverProxy,omitempty"`
}

type ShotoverProxySpec struct {
NodeSize string `json:"nodeSize"`
}

type DebeziumCassandraSpec struct {
Expand All @@ -104,6 +110,16 @@ func (d *CassandraDataCentre) DebeziumToInstAPI() []*models.Debezium {
return instDebezium
}

func (d *CassandraDataCentre) ShotoverProxyToInstaAPI() []*models.ShotoverProxy {
var instaShotoverProxy []*models.ShotoverProxy
for _, k8sShotoverProxy := range d.ShotoverProxy {
instaShotoverProxy = append(instaShotoverProxy, &models.ShotoverProxy{
NodeSize: k8sShotoverProxy.NodeSize,
})
}
return instaShotoverProxy
}

func (d *CassandraDataCentre) DebeziumEquals(new *CassandraDataCentre) bool {
if len(d.Debezium) != len(new.Debezium) {
return false
Expand All @@ -122,6 +138,21 @@ func (d *CassandraDataCentre) DebeziumEquals(new *CassandraDataCentre) bool {
return true
}

func (d *CassandraDataCentre) ShotoverProxyEquals(new *CassandraDataCentre) bool {
if len(d.ShotoverProxy) != len(new.ShotoverProxy) {
return false
}

for _, oldSP := range d.ShotoverProxy {
for _, newSP := range new.ShotoverProxy {
if newSP.NodeSize != oldSP.NodeSize {
return false
}
}
}
return true
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Expand Down Expand Up @@ -242,6 +273,16 @@ func (cs *CassandraSpec) DebeziumFromInstAPI(iDebeziums []*models.Debezium) (dcs
return debeziums
}

func (cs *CassandraSpec) ShotoverProxyromInstAPI(iShotoverProxys []*models.ShotoverProxy) (sps []ShotoverProxySpec) {
var shotoverProxys []ShotoverProxySpec
for _, iShotoverProxy := range iShotoverProxys {
shotoverProxys = append(shotoverProxys, ShotoverProxySpec{
NodeSize: iShotoverProxy.NodeSize,
})
}
return shotoverProxys
}

func (cs *CassandraSpec) DCsFromInstAPI(iDCs []*models.CassandraDataCentre) (dcs []*CassandraDataCentre) {
for _, iDC := range iDCs {
dcs = append(dcs, &CassandraDataCentre{
Expand All @@ -250,7 +291,9 @@ func (cs *CassandraSpec) DCsFromInstAPI(iDCs []*models.CassandraDataCentre) (dcs
PrivateIPBroadcastForDiscovery: iDC.PrivateIPBroadcastForDiscovery,
ClientToClusterEncryption: iDC.ClientToClusterEncryption,
ReplicationFactor: iDC.ReplicationFactor,
PrivateLink: iDC.PrivateLink,
Debezium: cs.DebeziumFromInstAPI(iDC.Debezium),
ShotoverProxy: cs.ShotoverProxyromInstAPI(iDC.ShotoverProxy),
})
}
return
Expand Down Expand Up @@ -323,9 +366,11 @@ func (cs *CassandraSpec) AreDCsEqual(dcs []*CassandraDataCentre) bool {
if !dataCentre.IsEqual(iDC.DataCentre) ||
iDC.ClientToClusterEncryption != dataCentre.ClientToClusterEncryption ||
iDC.PrivateIPBroadcastForDiscovery != dataCentre.PrivateIPBroadcastForDiscovery ||
iDC.PrivateLink != dataCentre.PrivateLink ||
iDC.ContinuousBackup != dataCentre.ContinuousBackup ||
iDC.ReplicationFactor != dataCentre.ReplicationFactor ||
!dataCentre.DebeziumEquals(iDC) {
!dataCentre.DebeziumEquals(iDC) ||
!dataCentre.ShotoverProxyEquals(iDC) {
return false
}
}
Expand Down Expand Up @@ -356,10 +401,12 @@ func (cdc *CassandraDataCentre) ToInstAPI() *models.CassandraDataCentre {
return &models.CassandraDataCentre{
DataCentre: cdc.DataCentre.ToInstAPI(),
ClientToClusterEncryption: cdc.ClientToClusterEncryption,
PrivateLink: cdc.PrivateLink,
ContinuousBackup: cdc.ContinuousBackup,
PrivateIPBroadcastForDiscovery: cdc.PrivateIPBroadcastForDiscovery,
ReplicationFactor: cdc.ReplicationFactor,
Debezium: cdc.DebeziumToInstAPI(),
ShotoverProxy: cdc.ShotoverProxyToInstaAPI(),
}
}

Expand Down
6 changes: 6 additions & 0 deletions apis/clusters/v1beta1/cassandra_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ type immutableCassandraDCFields struct {
type specificCassandraDC struct {
replicationFactor int
continuousBackup bool
privateLink bool
privateIpBroadcastForDiscovery bool
clientToClusterEncryption bool
}
Expand Down Expand Up @@ -340,6 +341,10 @@ func (cs *CassandraSpec) validateDataCentresUpdate(oldSpec CassandraSpec) error
return models.ErrDebeziumImmutable
}

if !oldDC.ShotoverProxyEquals(newDC) {
return models.ErrShotoverProxyImmutable
}

}

return nil
Expand All @@ -357,6 +362,7 @@ func (cdc *CassandraDataCentre) newImmutableFields() *immutableCassandraDCFields
specificCassandraDC{
replicationFactor: cdc.ReplicationFactor,
continuousBackup: cdc.ContinuousBackup,
privateLink: cdc.PrivateLink,
privateIpBroadcastForDiscovery: cdc.PrivateIPBroadcastForDiscovery,
clientToClusterEncryption: cdc.ClientToClusterEncryption,
},
Expand Down
20 changes: 20 additions & 0 deletions apis/clusters/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions config/crd/bases/clusters.instaclustr.com_cassandras.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,21 @@ spec:
type: integer
privateIpBroadcastForDiscovery:
type: boolean
privateLink:
type: boolean
region:
type: string
replicationFactor:
type: integer
shotoverProxy:
items:
properties:
nodeSize:
type: string
required:
- nodeSize
type: object
type: array
tags:
additionalProperties:
type: string
Expand Down
91 changes: 47 additions & 44 deletions config/samples/clusters_v1beta1_cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,65 @@ kind: Cassandra
metadata:
name: cassandra-cluster
spec:
name: "username-Cassandra"
version: "4.0.10"
privateNetworkCluster: false
name: "mykyta-Cassandra-test" #(immutable)
version: "4.0.10" #(immutable)
privateNetworkCluster: true #(immutable)
dataCentres:
- name: "AWS_cassandra"
region: "US_EAST_1"
debezium:
# - kafkaVpcType: "VPC_PEERED"
# kafkaTopicPrefix: "test"
# kafkaCdcId: "5134aed3-7b98-4ebd-95d0-2e181bdb073b"
# clusterRef:
# name: kafka
# namespace: default
# clusterKind: Kafka
# version: "2.0.1"
cloudProvider: "AWS_VPC"
continuousBackup: false
nodesNumber: 2
- name: "AWS_cassandra" #(mutable)
region: "US_EAST_1" #(immutable)
# debezium:
# - kafkaVpcType: "VPC_PEERED" #(immutable)
# kafkaTopicPrefix: "test" #(immutable)
# kafkaCdcId: "556b283e-d094-4bcf-a068-14fa68c2a43a" #(mutable)
## clusterRef:1
## name: kafka
## namespace: default
## clusterKind: Kafka
# version: "2.0.1" #(immutable)
cloudProvider: "AWS_VPC" #(immutable)
continuousBackup: false #(immutable)
nodesNumber: 6 # (if we updated nodes number to unsupported quantity, for example 7, it will be updated in operator, but can't be updated on Instaclustr, after getting bad request, we can`t roll back changes, and decrees number of nodes )
replicationFactor: 2
privateIpBroadcastForDiscovery: false
network: "172.16.0.0/19"
privateIpBroadcastForDiscovery: false #(immutable)
network: "172.16.0.0/19" #(immutable)
tags:
"tag": "testTag"
clientToClusterEncryption: false
# cloudProviderSettings:
# - customVirtualNetworkId: "vpc-0b69c781969e980a9"
nodeSize: "CAS-DEV-t4g.small-5"
# accountName: "InstaclustrRIYOA"
# - name: "AWS_cassandra2"
# region: "US_EAST_1"
# cloudProvider: "AWS_VPC"
# continuousBackup: false
# nodesNumber: 2
# replicationFactor: 2
# privateIpBroadcastForDiscovery: false
# network: "172.17.0.0/19"
# tags:
# "tag": "testTag"
# clientToClusterEncryption: false
# nodeSize: "CAS-DEV-t4g.small-30"
pciCompliance: false
luceneEnabled: false # can be enabled only on 3.11.13 version of Cassandra
passwordAndUserAuth: true
"tag": "testTag" #(immutable)
clientToClusterEncryption: true #(immutable)
# cloudProviderSettings:
# - customVirtualNetworkId: "vpc-0b69c781969e980a9"
# nodeSize: "CAS-DEV-t4g.small-5" #(mutable)
# nodeSize: "CAS-PRD-r6g.medium-80" #(mutable) # (production node size)
nodeSize: "CAS-PRD-r6g.medium-120" #(mutable) # (production node size)
privateLink: true
shotoverProxy:
- nodeSize: "CSO-PRD-c6g.xlarge-20"
# accountName: "InstaclustrRIYOA"
# - name: "AWS_cassandra2"
# region: "US_EAST_1"
# cloudProvider: "AWS_VPC"
# continuousBackup: false
# nodesNumber: 2
# replicationFactor: 2
# privateIpBroadcastForDiscovery: false
# network: "172.17.0.0/19"
# tags:
# "tag": "testTag"
# clientToClusterEncryption: false
# nodeSize: "CAS-DEV-t4g.small-30"
pciCompliance: false #(immutable)
luceneEnabled: false #(immutable) # can be enabled only on 3.11.13 version of Cassandra (currently it could be enabled on 4.0.10 version as well)
passwordAndUserAuth: true #(immutable)
# userRefs:
# - namespace: default
# name: cassandrauser-sample
# - namespace: default
# name: cassandrauser-sample2
# - namespace: default
# name: cassandrauser-sample3
slaTier: "NON_PRODUCTION"
slaTier: "NON_PRODUCTION" #(immutable)
# resizeSettings:
# - notifySupportContacts: false
# concurrency: 2
# description: "this is a sample of description"
# twoFactorDelete:
# - email: "[email protected]"
#spark:
# - version: "2.3.2" # 3.0.1 for 4.0.4 version of Cassandra | 2.3.2 for 3.11.13 version of Cassandra
# - email: "[email protected]"
14 changes: 7 additions & 7 deletions config/samples/clusters_v1beta1_kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ kind: Kafka
metadata:
name: kafka
spec:
name: "example-Kafka"
name: "mykyta-Kafka-test"
version: "3.5.1"
pciCompliance: false
replicationFactor: 3
partitionsNumber: 3
allowDeleteTopics: true
autoCreateTopics: true
clientToClusterEncryption: false
clientToClusterEncryption: true
privateNetworkCluster: false
slaTier: "NON_PRODUCTION"
# bundledUseOnly: true
# clientBrokerAuthWithMtls: true
clientBrokerAuthWithMtls: true
# dedicatedZookeeper:
# - nodeSize: "KDZ-DEV-t4g.small-30"
# nodesNumber: 3
# twoFactorDelete:
# - email: "asdfadfsdsf"
# phone: "ddsafasdf"
# karapaceSchemaRegistry:
# - version: "3.2.0"
# schemaRegistry:
# - version: "5.0.0"
karapaceSchemaRegistry:
- version: "3.6.2"
# schemaRegistry:
# - version: "5.0.0"
# karapaceRestProxy:
# - integrateRestProxyWithSchemaRegistry: true
# version: "3.2.0"
Expand Down
2 changes: 1 addition & 1 deletion controllers/clusters/cassandra_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (r *CassandraReconciler) handleUpdateCluster(

func (r *CassandraReconciler) handleExternalChanges(c, iCassandra *v1beta1.Cassandra, l logr.Logger) (reconcile.Result, error) {
if !c.Spec.IsEqual(iCassandra.Spec) {
l.Info(msgSpecStillNoMatch,
l.Info(msgExternalChanges,
"specification of k8s resource", c.Spec,
"data from Instaclustr ", iCassandra.Spec)

Expand Down
2 changes: 0 additions & 2 deletions controllers/clusters/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ var msgExternalChanges = "The k8s specification is different from Instaclustr Co
"Update operations are blocked. Please check operator logs and edit the cluster spec manually, " +
"so that it would corresponds to the data from Instaclustr."

var msgSpecStillNoMatch = "k8s resource specification still doesn't match with data on the Instaclustr Console. Double check the difference."

// deleteDefaultUserSecret deletes the secret with default user credentials.
// It ignores NotFound error.
func deleteDefaultUserSecret(
Expand Down
2 changes: 1 addition & 1 deletion controllers/clusters/kafkaconnect_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (r *KafkaConnectReconciler) handleUpdateCluster(ctx context.Context, kc *v1

func (r *KafkaConnectReconciler) handleExternalChanges(kc, ik *v1beta1.KafkaConnect, l logr.Logger) (reconcile.Result, error) {
if !kc.Spec.IsEqual(ik.Spec) {
l.Info(msgSpecStillNoMatch,
l.Info(msgExternalChanges,
"specification of k8s resource", kc.Spec,
"data from Instaclustr ", ik.Spec)

Expand Down
2 changes: 1 addition & 1 deletion controllers/clusters/opensearch_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (r *OpenSearchReconciler) HandleUpdateCluster(

func (r *OpenSearchReconciler) handleExternalChanges(o, iO *v1beta1.OpenSearch, l logr.Logger) (reconcile.Result, error) {
if !o.Spec.IsEqual(iO.Spec) {
l.Info(msgSpecStillNoMatch,
l.Info(msgExternalChanges,
"specification of k8s resource", o.Spec,
"data from Instaclustr ", iO.Spec)

Expand Down
2 changes: 1 addition & 1 deletion controllers/clusters/postgresql_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func (r *PostgreSQLReconciler) handleUserEvent(

func (r *PostgreSQLReconciler) handleExternalChanges(pg, iPg *v1beta1.PostgreSQL, l logr.Logger) (reconcile.Result, error) {
if !pg.Spec.IsEqual(iPg.Spec) {
l.Info(msgSpecStillNoMatch,
l.Info(msgExternalChanges,
"specification of k8s resource", pg.Spec,
"data from Instaclustr ", iPg.Spec)
msgDiffSpecs, err := createSpecDifferenceMessage(pg.Spec, iPg.Spec)
Expand Down
Loading

0 comments on commit 7733c4d

Please sign in to comment.