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

Scheduler jobs interceptions fixed #656

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/clusterresources/v1beta1/awsencryptionkey_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type AWSEncryptionKeyList struct {
}

func (aws *AWSEncryptionKey) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(aws).String() + "/" + jobName
return aws.Kind + "/" + client.ObjectKeyFromObject(aws).String() + "/" + jobName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just use UUID-Based Naming. It would be like aws.ObjectMeta.UID + "/" + jobName. You can even add client.ObjectKeyFromObject(aws).String() there. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following solution allows us to easly watch in the operator logs for which resource job is created. However, we can also add UUID to the job name. What do others think about a pattern with UUID included?metadata.uuid/metadata.kind/metadata.namespace/metadata.name/jobid
It looks a bit big, but it provides more uniqueness for JobIDs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed it with @ribaraka and decided to use metadata.kind/metadata.namespace/metadata.name/jobId because it is easier to manage jobs via the operator logs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks also good

}

func (aws *AWSEncryptionKey) NewPatch() client.Patch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ type AWSEndpointServicePrincipal struct {
Status AWSEndpointServicePrincipalStatus `json:"status,omitempty"`
}

func (r *AWSEndpointServicePrincipal) NewPatch() client.Patch {
return client.MergeFrom(r.DeepCopy())
func (p *AWSEndpointServicePrincipal) NewPatch() client.Patch {
return client.MergeFrom(p.DeepCopy())
}

func (r *AWSEndpointServicePrincipal) GetJobID(job string) string {
return r.Namespace + "/" + r.Name + "/" + job
func (p *AWSEndpointServicePrincipal) GetJobID(job string) string {
return p.Kind + "/" + p.Namespace + "/" + p.Name + "/" + job
}

//+kubebuilder:object:root=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type AWSSecurityGroupFirewallRuleList struct {
}

func (fr *AWSSecurityGroupFirewallRule) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(fr).String() + "/" + jobName
return fr.Kind + "/" + client.ObjectKeyFromObject(fr).String() + "/" + jobName
}

func (fr *AWSSecurityGroupFirewallRule) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusterresources/v1beta1/awsvpcpeering_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type AWSVPCPeeringList struct {
}

func (aws *AWSVPCPeering) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(aws).String() + "/" + jobName
return aws.Kind + "/" + client.ObjectKeyFromObject(aws).String() + "/" + jobName
}

func (aws *AWSVPCPeering) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusterresources/v1beta1/azurevnetpeering_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type AzureVNetPeeringList struct {
}

func (azure *AzureVNetPeering) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(azure).String() + "/" + jobName
return azure.Kind + "/" + client.ObjectKeyFromObject(azure).String() + "/" + jobName
}

func (azure *AzureVNetPeering) NewPatch() client.Patch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type ClusterNetworkFirewallRuleList struct {
}

func (fr *ClusterNetworkFirewallRule) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(fr).String() + "/" + jobName
return fr.Kind + "/" + client.ObjectKeyFromObject(fr).String() + "/" + jobName
}

func (fr *ClusterNetworkFirewallRule) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusterresources/v1beta1/gcpvpcpeering_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type GCPVPCPeeringList struct {
}

func (gcp *GCPVPCPeering) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(gcp).String() + "/" + jobName
return gcp.Kind + "/" + client.ObjectKeyFromObject(gcp).String() + "/" + jobName
}

func (gcp *GCPVPCPeering) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusterresources/v1beta1/maintenanceevents_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type MaintenanceEventsList struct {
}

func (me *MaintenanceEvents) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(me).String() + "/" + jobName
return me.Kind + "/" + client.ObjectKeyFromObject(me).String() + "/" + jobName
}

func (me *MaintenanceEvents) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/cadence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func init() {
}

func (c *Cadence) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(c).String() + "/" + jobName
return c.Kind + "/" + client.ObjectKeyFromObject(c).String() + "/" + jobName
}

func (c *Cadence) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ type specificCassandraDC struct {
}

func (c *Cassandra) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(c).String() + "/" + jobName
return c.Kind + "/" + client.ObjectKeyFromObject(c).String() + "/" + jobName
}

func (c *Cassandra) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func init() {
}

func (k *Kafka) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(k).String() + "/" + jobName
return k.Kind + "/" + client.ObjectKeyFromObject(k).String() + "/" + jobName
}

func (k *Kafka) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/kafkaconnect_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ type KafkaConnectList struct {
}

func (k *KafkaConnect) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(k).String() + "/" + jobName
return k.Kind + "/" + client.ObjectKeyFromObject(k).String() + "/" + jobName
}

func (k *KafkaConnect) NewPatch() client.Patch {
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 @@ -561,7 +561,7 @@ type OpenSearchList struct {
}

func (os *OpenSearch) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(os).String() + "/" + jobName
return os.Kind + "/" + client.ObjectKeyFromObject(os).String() + "/" + jobName
}

func (os *OpenSearch) NewPatch() client.Patch {
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 @@ -139,7 +139,7 @@ func init() {
}

func (pg *PostgreSQL) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(pg).String() + "/" + jobName
return pg.Kind + "/" + client.ObjectKeyFromObject(pg).String() + "/" + jobName
}

func (pg *PostgreSQL) NewPatch() client.Patch {
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 @@ -123,7 +123,7 @@ type immutableRedisDCFields struct {
}

func (r *Redis) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(r).String() + "/" + jobName
return r.Kind + "/" + client.ObjectKeyFromObject(r).String() + "/" + jobName
}

func (r *Redis) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/zookeeper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func init() {
}

func (z *Zookeeper) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(z).String() + "/" + jobName
return z.Kind + "/" + client.ObjectKeyFromObject(z).String() + "/" + jobName
}

func (z *Zookeeper) NewPatch() client.Patch {
Expand Down
2 changes: 1 addition & 1 deletion apis/kafkamanagement/v1beta1/kafkaacl_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type KafkaACLList struct {
}

func (kacl *KafkaACL) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(kacl).String() + "/" + jobName
return kacl.Kind + "/" + client.ObjectKeyFromObject(kacl).String() + "/" + jobName
}

func (kacl *KafkaACL) NewPatch() client.Patch {
Expand Down
4 changes: 0 additions & 4 deletions apis/kafkamanagement/v1beta1/kafkauser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ type KafkaUserList struct {
Items []KafkaUser `json:"items"`
}

func (ku *KafkaUser) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(ku).String() + "/" + jobName
}

func (ku *KafkaUser) NewPatch() client.Patch {
old := ku.DeepCopy()
return client.MergeFrom(old)
Expand Down
2 changes: 1 addition & 1 deletion apis/kafkamanagement/v1beta1/mirror_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (m *Mirror) NewPatch() client.Patch {
}

func (m *Mirror) GetJobID(jobName string) string {
return client.ObjectKeyFromObject(m).String() + "/" + jobName
return m.Kind + "/" + client.ObjectKeyFromObject(m).String() + "/" + jobName
}

func (a *MirrorStatus) IsEqual(b *MirrorStatus) bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ import (
"github.com/instaclustr/operator/pkg/instaclustr"
"github.com/instaclustr/operator/pkg/models"
"github.com/instaclustr/operator/pkg/ratelimiter"
"github.com/instaclustr/operator/pkg/scheduler"
)

// OpenSearchEgressRulesReconciler reconciles a OpenSearchEgressRules object
type OpenSearchEgressRulesReconciler struct {
client.Client
Scheme *runtime.Scheme
API instaclustr.API
Scheduler scheduler.Interface
EventRecorder record.EventRecorder
}

Expand Down