-
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
KafkaConnect code base refactor #709
Conversation
db62598
to
d28f2e0
Compare
type KafkaConnectDataCentreStatus struct { | ||
GenericDataCentreStatus `json:",inline"` | ||
|
||
NumberOfNodes int `json:"numberOfNodes,omitempty"` |
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.
please try to make it generic
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.
A bit hard because some resources don't have any numberOfNodes
inside their dataCentres so if we add the field to the generic status it will exist inside the resource status but never filled. The only way to implement it for such resources is to count it on my own. WDYT?
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 think we should count it on our end. Also, I'm considering moving this field into the 'Status,' which allows us to use the print column annotations (for convenient displaying of the total nodes number) and simplifies the calculation when dealing with multiple data centers.
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.
return k.GenericDataCentreSpec.Equals(&o.GenericDataCentreSpec) && | ||
k.NumberOfNodes == o.NumberOfNodes && | ||
k.ReplicationFactor == o.ReplicationFactor | ||
} |
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.
nodeSize is missing
settings := cc.GCPConnectorSettings[i] | ||
if *gSetting != *settings { | ||
for i := range ks.CustomConnectors { | ||
if !slices.Equals(ks.CustomConnectors[i].AWSConnectorSettings, o[i].AWSConnectorSettings) || |
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.
EqualsPtr
func (ks *KafkaConnectSpec) FromInstAPI(instaModel *models.KafkaConnectCluster) { | ||
ks.GenericClusterSpec.FromInstAPI(&instaModel.GenericClusterFields) | ||
ks.DCsFromInstAPI(instaModel.DataCentres) | ||
ks.TargetClustersFromInstAPI(instaModel.TargetCluster) | ||
ks.CustomConnectorsFromInstAPI(instaModel.CustomConnectors) |
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.
version is missing
|
||
func (s *KafkaConnectDataCentreStatus) FromInstAPI(instaModel *models.KafkaConnectDataCentre) { | ||
s.GenericDataCentreStatus.FromInstAPI(&instaModel.GenericDataCentreFields) | ||
s.nodesFromInstAPI(instaModel.Nodes) |
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.
try to make nodesFromInstAPI generic
managedCluster := kc.Spec.GetManagedCluster() | ||
|
||
kc.Spec.FromInstAPI(&instaModel) | ||
|
||
if managedCluster != nil && managedCluster.ClusterRef != nil { | ||
kc.Spec.GetManagedCluster().ClusterRef = managedCluster.ClusterRef | ||
} |
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.
move managedCluster
into FromInstAPI
e0df0d7
to
e76f27a
Compare
e76f27a
to
49d0b34
Compare
cs.DataCentres = dcs | ||
} | ||
|
||
func (c *CassandraSpec) getDC(name string) int { |
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.
how about naming the function such as GetDCIndexByName
?
@@ -179,6 +175,10 @@ func (kcv *kafkaConnectValidator) ValidateUpdate(ctx context.Context, old runtim | |||
|
|||
kafkaconnectlog.Info("validate update", "name", kc.Name) | |||
|
|||
if kc.Annotations[models.ResourceStateAnnotation] == models.CreatingEvent { |
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.
SyncEvent
spec: | ||
name: "example-cassandra" #(immutable) | ||
name: "bohdan-cassandra" #(immutable) |
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.
revert
"sigs.k8s.io/controller-runtime/pkg/ratelimiter" | ||
|
||
rlimiter "github.com/instaclustr/operator/pkg/ratelimiter" | ||
|
||
"github.com/instaclustr/operator/apis/clusters/v1beta1" | ||
"github.com/instaclustr/operator/pkg/exposeservice" |
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.
no need for a gap
return fmt.Errorf("failed to get managed cluster id by ref %s/%s for kind %s, err: %w", | ||
managedCluster.ClusterRef.Namespace, | ||
managedCluster.ClusterRef.Name, |
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 think you can use here AsNamespaced().String
@@ -655,6 +620,10 @@ func (r *KafkaConnectReconciler) SetupWithManager(mgr ctrl.Manager) error { | |||
return false | |||
} | |||
|
|||
if newObj.Status.ID == "" && newObj.Annotations[models.ResourceStateAnnotation] == models.CreatingEvent { |
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.
SyncEvent
49d0b34
to
1efbe0c
Compare
No description provided.