Skip to content

ScyllaDBCluster sync duplication across types #2576

Open
@mflendrich

Description

@mflendrich

This is an extract of the conversation in https://github.com/scylladb/scylla-operator/pull/2524/files#r2017366718 to a separate issue.

The automated multi-region capability implementation has introduced substantial repetition of almost-identical logic across the range of types we sync with the remote cluster:

err = controllerhelpers.RunSync(
&status.Conditions,
remoteNamespaceControllerProgressingCondition,
remoteNamespaceControllerDegradedCondition,
sc.Generation,
func() ([]metav1.Condition, error) {
return scc.syncNamespaces(ctx, sc, remoteNamespaceMap, managingClusterDomain)
},
)
if err != nil {
errs = append(errs, fmt.Errorf("can't sync remote namespaces: %w", err))
}
err = controllerhelpers.RunSync(
&status.Conditions,
remoteRemoteOwnerControllerProgressingCondition,
remoteRemoteOwnerControllerDegradedCondition,
sc.Generation,
func() ([]metav1.Condition, error) {
return scc.syncRemoteOwners(ctx, sc, remoteNamespaces, remoteRemoteOwnerMap, managingClusterDomain)
},
)
if err != nil {
errs = append(errs, fmt.Errorf("can't sync remote remoteowners: %w", err))
}
err = controllerhelpers.RunSync(
&status.Conditions,
remoteServiceControllerProgressingCondition,
remoteServiceControllerDegradedCondition,
sc.Generation,
func() ([]metav1.Condition, error) {
return scc.syncServices(ctx, sc, remoteNamespaces, remoteControllers, remoteServiceMap, managingClusterDomain)
},
)
if err != nil {
errs = append(errs, fmt.Errorf("can't sync remote services: %w", err))
}
err = controllerhelpers.RunSync(
&status.Conditions,
remoteEndpointSliceControllerProgressingCondition,
remoteEndpointSliceControllerDegradedCondition,
sc.Generation,
func() ([]metav1.Condition, error) {
return scc.syncEndpointSlices(ctx, sc, remoteNamespaces, remoteControllers, remoteEndpointSlicesMap, managingClusterDomain)
},
)
if err != nil {
errs = append(errs, fmt.Errorf("can't sync remote endpointslices: %w", err))
}
err = controllerhelpers.RunSync(
&status.Conditions,
remoteEndpointsControllerProgressingCondition,
remoteEndpointsControllerDegradedCondition,
sc.Generation,
func() ([]metav1.Condition, error) {
return scc.syncEndpoints(ctx, sc, remoteNamespaces, remoteControllers, remoteEndpointsMap, managingClusterDomain)
},
)
if err != nil {
errs = append(errs, fmt.Errorf("can't sync remote endpoints: %w", err))
}
err = controllerhelpers.RunSync(
&status.Conditions,
remoteScyllaDBDatacenterControllerProgressingCondition,
remoteScyllaDBDatacenterControllerDegradedCondition,
sc.Generation,
func() ([]metav1.Condition, error) {
return scc.syncScyllaDBDatacenters(ctx, sc, remoteNamespaces, remoteControllers, remoteScyllaDBDatacenterMap, managingClusterDomain)
},
)
if err != nil {
errs = append(errs, fmt.Errorf("can't sync remote scylladbdatacenters: %w", err))
}

plus the secret/CM syncers added in #2524.

The scope of this issue is to come up with some pattern to prevent the sprawl of almost-identical implementations under the ScyllaDBCluster controller.

Acceptance Criteria

  • Meaningfully reduced duplication of logic under pkg/controller/scylladbcluster's sync.go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good-first-issueIssue that is good as an onboarding task for newcomerspriority/backlogHigher priority than priority/awaiting-more-evidence.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions