@@ -967,7 +967,7 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
967
967
968
968
// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
969
969
// Convert modelJob into scheduledWorkflow.
970
- scheduledWorkflow , err := tmpl .ScheduledWorkflow (job )
970
+ scheduledWorkflow , err := tmpl .ScheduledWorkflow (job , r . getOwnerReferences () )
971
971
if err != nil {
972
972
return nil , util .Wrap (err , "Failed to create a recurring run during scheduled workflow creation" )
973
973
}
@@ -1012,6 +1012,27 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
1012
1012
return r .jobStore .CreateJob (job )
1013
1013
}
1014
1014
1015
+ func (r * ResourceManager ) getOwnerReferences () []v1.OwnerReference {
1016
+ ownerName := common .GetStringConfigWithDefault ("OWNER_NAME" , "" )
1017
+ ownerAPIVersion := common .GetStringConfigWithDefault ("OWNER_API_VERSION" , "" )
1018
+ ownerKind := common .GetStringConfigWithDefault ("OWNER_KIND" , "" )
1019
+ ownerUID := types .UID (common .GetStringConfigWithDefault ("OWNER_UID" , "" ))
1020
+
1021
+ if ownerName == "" || ownerAPIVersion == "" || ownerKind == "" || ownerUID == "" {
1022
+ glog .Info ("Missing ScheduledWorkflow owner fields. Proceeding without OwnerReferences" )
1023
+ return []v1.OwnerReference {}
1024
+ } else {
1025
+ return []v1.OwnerReference {
1026
+ {
1027
+ APIVersion : ownerAPIVersion ,
1028
+ Kind : ownerKind ,
1029
+ Name : ownerName ,
1030
+ UID : ownerUID ,
1031
+ },
1032
+ }
1033
+ }
1034
+ }
1035
+
1015
1036
// Enables or disables a recurring run with given id.
1016
1037
func (r * ResourceManager ) ChangeJobMode (ctx context.Context , jobId string , enable bool ) error {
1017
1038
job , err := r .GetJob (jobId )
0 commit comments