Skip to content

Commit

Permalink
Added logic for provisioning On-premises Cassandra cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
testisnullus committed Oct 1, 2023
1 parent ffc2a11 commit 1f7811b
Show file tree
Hide file tree
Showing 2,029 changed files with 230,411 additions and 89,925 deletions.
5 changes: 0 additions & 5 deletions apis/clusterresources/v1beta1/postgresqluser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ type ClusterInfo struct {
Event string `json:"event,omitempty"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
5 changes: 5 additions & 0 deletions apis/clusterresources/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ type SecretReference struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}
18 changes: 16 additions & 2 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type CassandraRestoreFrom struct {

// CassandraSpec defines the desired state of Cassandra
type CassandraSpec struct {
RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty"`
OnPremisesSpec *CassandraOnPremisesSpec `json:"onPremisesSpec,omitempty"`
RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty"`
Cluster `json:",inline"`
DataCentres []*CassandraDataCentre `json:"dataCentres,omitempty"`
LuceneEnabled bool `json:"luceneEnabled,omitempty"`
Expand All @@ -67,6 +68,19 @@ type CassandraSpec struct {
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}

type CassandraOnPremisesSpec struct {
DeleteDisksWithVM bool `json:"deleteDisksWithVM,omitempty"`
StorageClassName string `json:"storageClassName"`
OSDiskSize string `json:"OSDiskSize"`
DataDiskSize string `json:"dataDiskSize"`
SSHGatewayCPU int64 `json:"sshGatewayCPU"`
SSHGatewayMemory string `json:"sshGatewayMemory"`
NodeCPU int64 `json:"nodeCPU"`
NodeMemory string `json:"nodeMemory"`
OSImageURL string `json:"osImageURL"`
CloudInitScriptNamespacedName *NamespacedName `json:"cloudInitScriptNamespacedName"`
}

// CassandraStatus defines the observed state of Cassandra
type CassandraStatus struct {
ClusterStatus `json:",inline"`
Expand Down Expand Up @@ -141,7 +155,7 @@ func (c *Cassandra) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.C
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.SnapshotUploadPrefix + c.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (os *OpenSearch) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.SnapshotUploadPrefix + os.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (pg *PostgreSQL) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.PgBackupPrefix + pg.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (r *Redis) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.Clust
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.SnapshotUploadPrefix + r.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ type privateLinkStatus struct {
EndPointServiceName string `json:"endPointServiceName,omitempty"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}

type PrivateLinkStatuses []*privateLinkStatus

func (p1 PrivateLinkStatuses) Equal(p2 PrivateLinkStatuses) bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (r *AWSEndpointServicePrincipalReconciler) handleCreate(ctx context.Context
err = json.Unmarshal(b, &principal.Status)
if err != nil {
l.Error(err, "failed to parse an AWS endpoint service principal resource response from Instaclustr")
r.EventRecorder.Eventf(principal, models.Warning, models.ConvertionFailed,
r.EventRecorder.Eventf(principal, models.Warning, models.ConversionFailed,
"Failed to parse an AWS endpoint service principal resource response from Instaclustr. Reason: %v", err,
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/clusterresources/clusterbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (r *ClusterBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reques
)

r.EventRecorder.Eventf(
backup, models.Warning, models.ConvertionFailed,
backup, models.Warning, models.ConversionFailed,
"Start timestamp annotation convertion to int is failed. Reason: %v",
err,
)
Expand Down
2 changes: 1 addition & 1 deletion controllers/clusterresources/postgresqluser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (r *PostgreSQLUserReconciler) createPostgreSQLFirewallRule(
firewallRule := &clusterresourcesv1beta1.ClusterNetworkFirewallRule{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterNetworkFirewallRuleKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: firewallRuleName,
Expand Down
4 changes: 2 additions & 2 deletions controllers/clusters/cadence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (r *CadenceReconciler) HandleCreateCluster(
logger.Error(err, "Cannot convert Cadence cluster manifest to API spec",
"cluster manifest", cadence.Spec)

r.EventRecorder.Eventf(cadence, models.Warning, models.ConvertionFailed,
r.EventRecorder.Eventf(cadence, models.Warning, models.ConversionFailed,
"Cluster convertion from the Instaclustr API to k8s resource is failed. Reason: %v", err)

return models.ReconcileRequeue
Expand Down Expand Up @@ -267,7 +267,7 @@ func (r *CadenceReconciler) HandleUpdateCluster(
"cluster ID", cadence.Status.ID,
)

r.EventRecorder.Eventf(cadence, models.Warning, models.ConvertionFailed,
r.EventRecorder.Eventf(cadence, models.Warning, models.ConversionFailed,
"Cluster convertion from the Instaclustr API to k8s resource is failed. Reason: %v", err)

return models.ReconcileRequeue
Expand Down
Loading

0 comments on commit 1f7811b

Please sign in to comment.