From a890331115340280bb1878c8baa46670cd6f0814 Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Mon, 26 Aug 2019 10:37:42 -0700 Subject: [PATCH] Improve error message on server-side apply conflicts --- staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go index aaa2de08f13..9f7a994b3c1 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go @@ -418,7 +418,22 @@ func (o *ApplyOptions) Run() error { if isIncompatibleServerError(err) { err = fmt.Errorf("Server-side apply not available on the server: (%v)", err) } + if errors.IsConflict(err) { + err = fmt.Errorf(`%v +Please review the fields above--they currently have other managers. Here +are the ways you can resolve this warning: +* If you intend to manage all of these fields, please re-run the apply + command with the `+"`--force-conflicts`"+` flag. +* If you do not intend to manage all of the fields, please edit your + manifest to remove references to the fields that should keep their + current managers. +* You may co-own fields by updating your manifest to match the existing + value; in this case, you'll become the manager if the other manager(s) + stop managing the field (remove it from their configuration). + +See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err) + } return err }