Skip to content

Commit

Permalink
Merge pull request #488 from alexandrevilain/fix/persistence-jobs-length
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevilain authored Aug 29, 2023
2 parents 7370b81 + b715d65 commit cc4e636
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions controllers/reconcile_persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ func sanitizeVersionToName(version *version.Version) string {
return strings.ReplaceAll(version.String(), ".", "-")
}

func datastoreTypeShortName(datastore v1beta1.DatastoreType) string {
switch datastore {
case v1beta1.CassandraDatastore:
return "cass"
case v1beta1.ElasticsearchDatastore:
return "es"
case v1beta1.PostgresSQLDatastore:
return "pg"
case v1beta1.PostgresSQL12Datastore:
return "pg12"
case v1beta1.MySQLDatastore:
return "my"
case v1beta1.MySQL8Datastore:
return "my8"
default:
return ""
}
}

// applyStatusDatastoreTypeDefaultValue sets default value on the status.persistence.[store].type for clusters created with operator =< 0.15.1.
// This field was added in the status type to run temporal-sql-tool's update-schema when SQL plugin is updated from postgres to postgres12.
// To run this the operator should track the datastore type when its created.
Expand Down Expand Up @@ -170,7 +189,7 @@ func (r *TemporalClusterReconciler) reconcilePersistence(ctx context.Context, cl
},
},
{
Name: fmt.Sprintf("update-visibility-schema-v-%s-%s", sanitizeVersionToName(cluster.Spec.Version), cluster.Spec.Persistence.VisibilityStore.GetType()),
Name: fmt.Sprintf("update-visibility-schema-v-%s-%s", sanitizeVersionToName(cluster.Spec.Version), datastoreTypeShortName(cluster.Spec.Persistence.VisibilityStore.GetType())),
Command: getDatabaseScriptCommand(persistence.UpdateVisibilitySchemaScript),
Skip: func(owner runtime.Object) bool {
c := owner.(*v1beta1.TemporalCluster)
Expand Down Expand Up @@ -218,7 +237,7 @@ func (r *TemporalClusterReconciler) reconcilePersistence(ctx context.Context, cl
},
},
&reconciler.Job{
Name: fmt.Sprintf("update-secondary-visibility-schema-v-%s-%s", sanitizeVersionToName(cluster.Spec.Version), cluster.Spec.Persistence.SecondaryVisibilityStore.GetType()),
Name: fmt.Sprintf("update-2nd-visibility-schema-v-%s-%s", sanitizeVersionToName(cluster.Spec.Version), datastoreTypeShortName(cluster.Spec.Persistence.SecondaryVisibilityStore.GetType())),
Command: getDatabaseScriptCommand(persistence.UpdateSecondaryVisibilitySchemaScript),
Skip: func(owner runtime.Object) bool {
c := owner.(*v1beta1.TemporalCluster)
Expand Down

0 comments on commit cc4e636

Please sign in to comment.