Revert "Update apply and edit"

This reverts commit 48d3ca23cf.
This commit is contained in:
ymqytw
2016-11-22 21:02:15 -08:00
parent d178bc76ed
commit 9b16b435fc
2 changed files with 8 additions and 14 deletions

View File

@@ -487,7 +487,6 @@ func visitToPatch(originalObj runtime.Object, updates *resource.Info,
preconditions := []strategicpatch.PreconditionFunc{strategicpatch.RequireKeyUnchanged("apiVersion"),
strategicpatch.RequireKeyUnchanged("kind"), strategicpatch.RequireMetadataKeyUnchanged("name")}
patch, err := strategicpatch.CreateTwoWayMergePatch(originalJS, editedJS, currOriginalObj, strategicpatch.SMPatchVersion_1_5, preconditions...)
// If creating a patch fails, retrying with SMPatchVersion_1_0 is not helpful. So we return the error.
if err != nil {
glog.V(4).Infof("Unable to calculate diff, no merge is possible: %v", err)
if strategicpatch.IsPreconditionFailed(err) {
@@ -499,16 +498,13 @@ func visitToPatch(originalObj runtime.Object, updates *resource.Info,
results.version = defaultVersion
patched, err := resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, api.StrategicMergePatchType, patch)
if err != nil {
// Retry SMPatchVersion_1_0 when applying the SMPatchVersion_1_5 patch returns an Internal Error (500).
// Because the failure may be due to the server not supporting the SMPatchVersion_1_5 patch.
if errors.IsInternalError(err) {
patch, err = strategicpatch.CreateTwoWayMergePatch(originalJS, editedJS, currOriginalObj, strategicpatch.SMPatchVersion_1_0)
if err != nil {
glog.V(4).Infof("Unable to calculate diff, no merge is possible: %v", err)
return err
}
patched, err = resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, api.StrategicMergePatchType, patch)
// Retry SMPatchVersion_1_0 when applying the SMPatchVersion_1_5 patch
patch, err = strategicpatch.CreateTwoWayMergePatch(originalJS, editedJS, currOriginalObj, strategicpatch.SMPatchVersion_1_0)
if err != nil {
glog.V(4).Infof("Unable to calculate diff, no merge is possible: %v", err)
return err
}
patched, err = resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, api.StrategicMergePatchType, patch)
if err != nil {
fmt.Fprintln(out, results.addError(err, info))
return nil