fix(backend): Sync scheduled workflows v1 if APIVersion and Kind are missing. Fixes #9809 (#9968)

This commit is contained in:
Florian Müller 2023-09-23 20:59:58 +02:00 committed by GitHub
parent 4003e56271
commit dcaafeee8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -62,5 +62,11 @@ func (c *ScheduledWorkflowClient) Get(namespace string, name string) (
"Error retrieving scheduled workflow (%v) in namespace (%v): %v", name, namespace, err)
}
// If the APIVersion and Kind are not set then set them to the default values.
if schedule.APIVersion == "" && schedule.Kind == "" {
schedule.Kind = util.SwfKind
schedule.APIVersion = util.ApiVersionV1
}
return util.NewScheduledWorkflow(schedule), nil
}

View File

@ -31,9 +31,9 @@ const (
SWFlegacy ScheduledWorkflowType = "legacy"
SWFunknown ScheduledWorkflowType = "Unknown"
apiVersionV1 = "kubeflow.org/v1beta1"
apiVersionV2 = "kubeflow.org/v2beta1"
swfKind = "ScheduledWorkflow"
ApiVersionV1 = "kubeflow.org/v1beta1"
ApiVersionV2 = "kubeflow.org/v2beta1"
SwfKind = "ScheduledWorkflow"
)
// ScheduledWorkflow is a type to help manipulate ScheduledWorkflow objects.
@ -160,9 +160,9 @@ func (s *ScheduledWorkflow) ToStringForStore() string {
}
func (s *ScheduledWorkflow) GetVersion() ScheduledWorkflowType {
if strings.HasPrefix(s.APIVersion, apiVersionV1) && s.Kind == swfKind {
if strings.HasPrefix(s.APIVersion, ApiVersionV1) && s.Kind == SwfKind {
return SWFv1
} else if strings.HasPrefix(s.APIVersion, apiVersionV2) && s.Kind == swfKind {
} else if strings.HasPrefix(s.APIVersion, ApiVersionV2) && s.Kind == SwfKind {
return SWFv2
} else if s.APIVersion == "" && s.Kind == "" {
return SWFlegacy