Skip to content

Commit

Permalink
[BugFix] use Patch not Update to modify service object (#387)
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao authored Jan 5, 2024
1 parent 62e9bdd commit 5ee1ac0
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions pkg/k8sutils/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func ApplyService(ctx context.Context, k8sClient client.Client, svc *corev1.Serv
}

svc.ResourceVersion = esvc.ResourceVersion
return UpdateClientObject(ctx, k8sClient, svc)
return k8sClient.Patch(ctx, svc, client.Merge)
}

func ApplyDeployment(ctx context.Context, k8sClient client.Client, deploy *appv1.Deployment) error {
Expand Down Expand Up @@ -177,15 +177,6 @@ func UpdateClientObject(ctx context.Context, k8sClient client.Client, object cli
return nil
}

// PatchClientObject patch object when the object exist. if not return error.
func PatchClientObject(ctx context.Context, k8sClient client.Client, object client.Object) error {
if err := k8sClient.Patch(ctx, object, client.Merge); err != nil {
return err
}

return nil
}

// DeleteStatefulset delete statefulset.
func DeleteStatefulset(ctx context.Context, k8sClient client.Client, namespace, name string) error {
logger := logr.FromContextOrDiscard(ctx)
Expand Down

0 comments on commit 5ee1ac0

Please sign in to comment.