-
Notifications
You must be signed in to change notification settings - Fork 0
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
Cadence packaged provisioning was refactored #726
Conversation
e9c66ee
to
2504b1b
Compare
if pp.UseAdvancedVisibility != old[i].UseAdvancedVisibility || | ||
pp.SolutionSize != old[i].SolutionSize { | ||
return models.ErrImmutablePackagedProvisioning | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may compare it this way because PackagedProvisioning
is comparable type
if pp.UseAdvancedVisibility != old[i].UseAdvancedVisibility || | |
pp.SolutionSize != old[i].SolutionSize { | |
return models.ErrImmutablePackagedProvisioning | |
} | |
if *pp != *old[i] { | |
return models.ErrImmutablePackagedProvisioning | |
} |
contains := validation.Contains(pp.SolutionSize, models.SolutionSizes) | ||
if !contains { | ||
return fmt.Errorf("the %s solution size is not supported. Supported ones: %v", pp.SolutionSize, models.SolutionSizes) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may use kubebuilder enum annotations for this type of validation. WDYT?
return "", nil | ||
} | ||
|
||
func calculateAvailableNetworks(cadenceNetwork string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot specify network when you use packaged provisioning for cadence.
2504b1b
to
c49e3c3
Compare
14e0905
to
e840aa5
Compare
controllers/clusters/helpers.go
Outdated
@@ -238,3 +241,36 @@ func reconcileExternalChanges(c client.Client, r record.EventRecorder, obj Objec | |||
|
|||
return nil | |||
} | |||
|
|||
func CalculateAvailableNetworks(cadenceNetwork string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this one should not be exported
func (r *CadenceReconciler) reconcileNetwork(availableCIDRs []string, app string) (string, error) { | ||
switch app { | ||
case models.CassandraAppKind: | ||
return availableCIDRs[1], nil | ||
case models.KafkaAppKind: | ||
return availableCIDRs[2], nil | ||
case models.OpenSearchAppKind: | ||
return availableCIDRs[3], nil | ||
} | ||
|
||
return &v1beta1.Cassandra{ | ||
TypeMeta: typeMeta, | ||
ObjectMeta: metadata, | ||
Spec: spec, | ||
}, nil | ||
return "", nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that errors are not being returned in this function. Perhaps consider removing the error from the return parameters
e840aa5
to
e5ca7ac
Compare
func (r *CadenceReconciler) reconcileAppDCs(c *v1beta1.Cadence, availableCIDRs []string, app string) (any, error) { | ||
network := r.reconcileNetwork(availableCIDRs, app) | ||
|
||
genericDataCentreSpec := v1beta1.GenericDataCentreSpec{ | ||
Region: c.Spec.DataCentres[0].Region, | ||
CloudProvider: c.Spec.DataCentres[0].CloudProvider, | ||
ProviderAccountName: c.Spec.DataCentres[0].ProviderAccountName, | ||
Network: network, | ||
} | ||
|
||
switch app { | ||
case models.CassandraAppKind: | ||
var privateIPBroadcast bool | ||
if c.Spec.PrivateNetwork { | ||
privateIPBroadcast = true | ||
} | ||
|
||
genericDataCentreSpec.Name = models.CassandraChildDCName | ||
cassandraDCs := []*v1beta1.CassandraDataCentre{ | ||
{ | ||
Email: c.Spec.TwoFactorDelete[0].Email, | ||
Phone: c.Spec.TwoFactorDelete[0].Phone, | ||
GenericDataCentreSpec: genericDataCentreSpec, | ||
NodeSize: c.Spec.CalculateNodeSize( | ||
c.Spec.DataCentres[0].CloudProvider, | ||
c.Spec.PackagedProvisioning[0].SolutionSize, | ||
models.CassandraAppKind, | ||
), | ||
NodesNumber: 3, | ||
ReplicationFactor: 3, | ||
PrivateIPBroadcastForDiscovery: privateIPBroadcast, | ||
}, | ||
} | ||
|
||
return cassandraDCs, nil | ||
|
||
case models.KafkaAppKind: | ||
genericDataCentreSpec.Name = models.KafkaChildDCName | ||
kafkaDCs := []*v1beta1.KafkaDataCentre{ | ||
{ | ||
GenericDataCentreSpec: genericDataCentreSpec, | ||
NodeSize: c.Spec.CalculateNodeSize( | ||
c.Spec.DataCentres[0].CloudProvider, | ||
c.Spec.PackagedProvisioning[0].SolutionSize, | ||
models.KafkaAppKind, | ||
), | ||
NodesNumber: 3, | ||
}, | ||
} | ||
return kafkaDCs, nil | ||
|
||
case models.OpenSearchAppKind: | ||
genericDataCentreSpec.Name = models.OpenSearchChildDCName | ||
openSearchDCs := []*v1beta1.OpenSearchDataCentre{ | ||
{ | ||
GenericDataCentreSpec: genericDataCentreSpec, | ||
NumberOfRacks: 3, | ||
}, | ||
} | ||
return openSearchDCs, nil | ||
} | ||
var cassNodeSize, network string | ||
var cassNodesNumber, cassReplicationFactor int | ||
var cassPrivateIPBroadcastForDiscovery, cassPasswordAndUserAuth bool | ||
for _, pp := range c.Spec.PackagedProvisioning { | ||
cassNodeSize = pp.BundledCassandraSpec.NodeSize | ||
network = pp.BundledCassandraSpec.Network | ||
cassNodesNumber = pp.BundledCassandraSpec.NodesNumber | ||
cassReplicationFactor = pp.BundledCassandraSpec.ReplicationFactor | ||
cassPrivateIPBroadcastForDiscovery = pp.BundledCassandraSpec.PrivateIPBroadcastForDiscovery | ||
cassPasswordAndUserAuth = pp.BundledCassandraSpec.PasswordAndUserAuth | ||
|
||
return nil, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't seem to return any errors. Please remove error
parameter
c0ffaa6
to
7ee8400
Compare
7ee8400
to
65e399a
Compare
No description provided.