MCPcopy
hub / github.com/argoproj/argo-workflows / createPDBResource

Method createPDBResource

workflow/controller/operator.go:4178–4212  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

4176}
4177
4178func (woc *wfOperationCtx) createPDBResource(ctx context.Context) error {
4179 if woc.execWf.Spec.PodDisruptionBudget == nil {
4180 return nil
4181 }
4182
4183 labels := map[string]string{common.LabelKeyWorkflow: woc.wf.Name}
4184 pdbSpec := *woc.execWf.Spec.PodDisruptionBudget
4185 if pdbSpec.Selector == nil {
4186 pdbSpec.Selector = &metav1.LabelSelector{
4187 MatchLabels: labels,
4188 }
4189 }
4190
4191 newPDB := policyv1.PodDisruptionBudget{
4192 ObjectMeta: metav1.ObjectMeta{
4193 Name: woc.wf.Name,
4194 Labels: labels,
4195 OwnerReferences: []metav1.OwnerReference{
4196 *metav1.NewControllerRef(woc.wf, wfv1.SchemeGroupVersion.WithKind(workflow.WorkflowKind)),
4197 },
4198 },
4199 Spec: pdbSpec,
4200 }
4201 _, err := woc.controller.kubeclientset.PolicyV1().PodDisruptionBudgets(woc.wf.Namespace).Create(ctx, &newPDB, metav1.CreateOptions{})
4202 if err != nil {
4203 if apierr.IsAlreadyExists(err) {
4204 woc.log.Info(ctx, "PDB resource already exists for workflow.")
4205 return nil
4206 }
4207 return err
4208 }
4209 woc.log.Info(ctx, "Created PDB resource for workflow.")
4210 woc.updated = true
4211 return nil
4212}
4213
4214func (woc *wfOperationCtx) deletePDBResource(ctx context.Context) error {
4215 if woc.execWf.Spec.PodDisruptionBudget == nil {

Callers 1

operateMethod · 0.95

Calls 2

CreateMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected