From c7b83356966e3251422bd09661006023cdede973 Mon Sep 17 00:00:00 2001 From: shanalily Date: Mon, 16 Jul 2018 14:16:43 -0700 Subject: [PATCH] removed datadisk to allow scale after upgrade --- pkg/acsengine/transform/transform.go | 15 ++++++++++++++- .../k8s_agent_upgrade_template.json | 8 -------- .../transformtestfiles/k8s_scale_template.json | 8 -------- .../k8s_vnet_scale_template.json | 8 -------- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/pkg/acsengine/transform/transform.go b/pkg/acsengine/transform/transform.go index 30129d05c0..edc32c0793 100644 --- a/pkg/acsengine/transform/transform.go +++ b/pkg/acsengine/transform/transform.go @@ -299,7 +299,7 @@ func (t *Transformer) NormalizeMasterResourcesForScaling(logger *logrus.Entry, t delete(hardwareProfile, vmSizeFieldName) } - if !t.removeCustomData(logger, resourceProperties) || !t.removeImageReference(logger, resourceProperties) { + if !t.removeCustomData(logger, resourceProperties) || !t.removeDataDisks(logger, resourceProperties) || !t.removeImageReference(logger, resourceProperties) { continue } } @@ -321,6 +321,19 @@ func (t *Transformer) removeCustomData(logger *logrus.Entry, resourceProperties return ok } +func (t *Transformer) removeDataDisks(logger *logrus.Entry, resourceProperties map[string]interface{}) bool { + storageProfile, ok := resourceProperties[storageProfileFieldName].(map[string]interface{}) + if !ok { + logger.Warnf("Template improperly formatted. Could not find: %s", storageProfileFieldName) + return ok + } + + if storageProfile[dataDisksFieldName] != nil { + delete(storageProfile, dataDisksFieldName) + } + return ok +} + func (t *Transformer) removeImageReference(logger *logrus.Entry, resourceProperties map[string]interface{}) bool { storageProfile, ok := resourceProperties[storageProfileFieldName].(map[string]interface{}) if !ok { diff --git a/pkg/acsengine/transform/transformtestfiles/k8s_agent_upgrade_template.json b/pkg/acsengine/transform/transformtestfiles/k8s_agent_upgrade_template.json index c8c59ff5a3..b2de4a286c 100644 --- a/pkg/acsengine/transform/transformtestfiles/k8s_agent_upgrade_template.json +++ b/pkg/acsengine/transform/transformtestfiles/k8s_agent_upgrade_template.json @@ -1991,14 +1991,6 @@ } }, "storageProfile": { - "dataDisks": [ - { - "createOption": "attach", - "diskSizeGB": "128", - "lun": 0, - "name": "[concat(variables('masterVMNamePrefix'), copyIndex(variables('masterOffset')),'-etcddisk')]" - } - ], "osDisk": { "caching": "ReadWrite", "createOption": "FromImage" diff --git a/pkg/acsengine/transform/transformtestfiles/k8s_scale_template.json b/pkg/acsengine/transform/transformtestfiles/k8s_scale_template.json index 51849f8acd..e58027a40d 100644 --- a/pkg/acsengine/transform/transformtestfiles/k8s_scale_template.json +++ b/pkg/acsengine/transform/transformtestfiles/k8s_scale_template.json @@ -2173,14 +2173,6 @@ } }, "storageProfile": { - "dataDisks": [ - { - "createOption": "Empty", - "diskSizeGB": "128", - "lun": 0, - "name": "[concat(variables('masterVMNamePrefix'), copyIndex(variables('masterOffset')),'-etcddisk')]" - } - ], "osDisk": { "caching": "ReadWrite", "createOption": "FromImage" diff --git a/pkg/acsengine/transform/transformtestfiles/k8s_vnet_scale_template.json b/pkg/acsengine/transform/transformtestfiles/k8s_vnet_scale_template.json index eb5829fdd1..ff04d84923 100644 --- a/pkg/acsengine/transform/transformtestfiles/k8s_vnet_scale_template.json +++ b/pkg/acsengine/transform/transformtestfiles/k8s_vnet_scale_template.json @@ -2117,14 +2117,6 @@ } }, "storageProfile": { - "dataDisks": [ - { - "createOption": "Empty", - "diskSizeGB": "128", - "lun": 0, - "name": "[concat(variables('masterVMNamePrefix'), copyIndex(variables('masterOffset')),'-etcddisk')]" - } - ], "osDisk": { "caching": "ReadWrite", "createOption": "FromImage"