From 2d51c6f13e51f9c2504363aaef3d9d67ca7dbe41 Mon Sep 17 00:00:00 2001 From: Jiaqi Luo <6218999+jiaqiluo@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:39:46 -0700 Subject: [PATCH] fix the bug where the value of delete_local_data is dropped by the ghodssyaml.Marshal function due to the same field has different names in YAML tag and JSON tag --- cluster/cluster.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cluster/cluster.go b/cluster/cluster.go index a0a683a9..2c61155c 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -687,10 +687,15 @@ func parseNodeDrainInput(clusterFile string, rkeConfig *v3.RancherKubernetesEngi nodeDrainInput.GracePeriod = DefaultNodeDrainGracePeriod update = true } else { - // TODO: ghodssyaml.Marshal is losing the user provided value for GracePeriod, investigate why, till then assign the provided value explicitly + // add back user's value because ghodssyaml.Marshal drops the value due to the same field has different names in YAML tag and JSON tag nodeDrainInput.GracePeriod = int(providedGracePeriod) } + // add back user's value because ghodssyaml.Marshal drops the value due to the same field has different names in YAML tag and JSON tag + if val, ok := nodeDrainInputMap["delete_local_data"].(bool); ok { + nodeDrainInput.DeleteLocalData = val + } + if update { rkeConfig.UpgradeStrategy.DrainInput = &nodeDrainInput }