(ctx context.Context)
| 170 | } |
| 171 | |
| 172 | func (woc *wfOperationCtx) createTaskSet(ctx context.Context) error { |
| 173 | if len(woc.taskSet) == 0 { |
| 174 | return nil |
| 175 | } |
| 176 | |
| 177 | woc.log.Info(ctx, "Creating TaskSet") |
| 178 | labels := map[string]string{} |
| 179 | if woc.controller.Config.InstanceID != "" { |
| 180 | labels[common.LabelKeyControllerInstanceID] = woc.controller.Config.InstanceID |
| 181 | } |
| 182 | taskSet := wfv1.WorkflowTaskSet{ |
| 183 | TypeMeta: metav1.TypeMeta{ |
| 184 | Kind: workflow.WorkflowTaskSetKind, |
| 185 | APIVersion: workflow.APIVersion, |
| 186 | }, |
| 187 | ObjectMeta: metav1.ObjectMeta{ |
| 188 | Namespace: woc.wf.Namespace, |
| 189 | Name: woc.wf.Name, |
| 190 | Labels: labels, |
| 191 | OwnerReferences: []metav1.OwnerReference{ |
| 192 | { |
| 193 | APIVersion: woc.wf.APIVersion, |
| 194 | Kind: woc.wf.Kind, |
| 195 | UID: woc.wf.UID, |
| 196 | Name: woc.wf.Name, |
| 197 | }, |
| 198 | }, |
| 199 | }, |
| 200 | Spec: wfv1.WorkflowTaskSetSpec{ |
| 201 | Tasks: woc.taskSet, |
| 202 | }, |
| 203 | } |
| 204 | woc.log.Debug(ctx, "creating new taskset") |
| 205 | |
| 206 | _, err := woc.controller.wfclientset.ArgoprojV1alpha1().WorkflowTaskSets(woc.wf.Namespace).Create(ctx, &taskSet, metav1.CreateOptions{}) |
| 207 | |
| 208 | if apierr.IsConflict(err) || apierr.IsAlreadyExists(err) { |
| 209 | woc.log.Debug(ctx, "patching the exiting taskset") |
| 210 | spec := map[string]interface{}{ |
| 211 | "metadata": metav1.ObjectMeta{ |
| 212 | Labels: map[string]string{ |
| 213 | common.LabelKeyCompleted: strconv.FormatBool(woc.wf.Status.Fulfilled()), |
| 214 | }, |
| 215 | }, |
| 216 | "spec": wfv1.WorkflowTaskSetSpec{Tasks: woc.taskSet}, |
| 217 | } |
| 218 | // patch the new templates into taskset |
| 219 | err = woc.mergePatchTaskSet(ctx, spec) |
| 220 | if err != nil { |
| 221 | woc.log.WithError(err).Error(ctx, "Failed to patch WorkflowTaskSet") |
| 222 | return fmt.Errorf("failed to patch TaskSet. %v", err) |
| 223 | } |
| 224 | } else if err != nil { |
| 225 | woc.log.WithError(err).Error(ctx, "Failed to create WorkflowTaskSet") |
| 226 | return err |
| 227 | } |
| 228 | return nil |
| 229 | } |
no test coverage detected