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

Cadence packaged provisioning was refactored #726

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

testisnullus
Copy link
Collaborator

No description provided.

@testisnullus testisnullus self-assigned this Feb 27, 2024
@testisnullus testisnullus force-pushed the cadence-packaged-solution-refactor branch 4 times, most recently from e9c66ee to 2504b1b Compare February 28, 2024 09:48
Comment on lines 353 to 355
if pp.UseAdvancedVisibility != old[i].UseAdvancedVisibility ||
pp.SolutionSize != old[i].SolutionSize {
return models.ErrImmutablePackagedProvisioning
}
Copy link
Collaborator

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

Suggested change
if pp.UseAdvancedVisibility != old[i].UseAdvancedVisibility ||
pp.SolutionSize != old[i].SolutionSize {
return models.ErrImmutablePackagedProvisioning
}
if *pp != *old[i] {
return models.ErrImmutablePackagedProvisioning
}

Comment on lines 496 to 499
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)
}
Copy link
Collaborator

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) {
Copy link
Collaborator

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.

@testisnullus testisnullus force-pushed the cadence-packaged-solution-refactor branch from 2504b1b to c49e3c3 Compare February 28, 2024 16:09
@testisnullus testisnullus force-pushed the cadence-packaged-solution-refactor branch 2 times, most recently from 14e0905 to e840aa5 Compare February 28, 2024 16:27
@@ -238,3 +241,36 @@ func reconcileExternalChanges(c client.Client, r record.EventRecorder, obj Objec

return nil
}

func CalculateAvailableNetworks(cadenceNetwork string) ([]string, error) {
Copy link
Collaborator

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

Comment on lines 800 to 806
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
}
Copy link
Contributor

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

@testisnullus testisnullus force-pushed the cadence-packaged-solution-refactor branch from e840aa5 to e5ca7ac Compare February 29, 2024 17:29
Comment on lines 668 to 726
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
}
Copy link
Contributor

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

@testisnullus testisnullus force-pushed the cadence-packaged-solution-refactor branch 2 times, most recently from c0ffaa6 to 7ee8400 Compare March 1, 2024 13:50
@testisnullus testisnullus force-pushed the cadence-packaged-solution-refactor branch from 7ee8400 to 65e399a Compare March 4, 2024 17:19
@ribaraka ribaraka merged commit 2b72599 into main Mar 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants