Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

The type of VirtualMachineScaleSetExtension is not set correctly #2605

Closed
AbelHu opened this issue Jan 19, 2020 · 2 comments · Fixed by #2640
Closed

The type of VirtualMachineScaleSetExtension is not set correctly #2605

AbelHu opened this issue Jan 19, 2020 · 2 comments · Fixed by #2640
Labels
bug Something isn't working
Milestone

Comments

@AbelHu
Copy link
Member

AbelHu commented Jan 19, 2020

Describe the bug
In CreateAgentVMSS, the type of VirtualMachineScaleSetExtension is not set correctly.

https://github.com/Azure/aks-engine/blob/master/pkg/engine/virtualmachinescalesets.go#L779
VMSS:

"extensionProfile":{"extensions":[{"name":"vmssCSE","properties":{"publisher":"Microsoft.Compute","type":"CustomScriptExtension","typeHandlerVersion":"1.8","autoUpgradeMinorVersion":true,"settings":{}}},{"name":"akswinnp1-AKSWindowsBilling","properties":{"publisher":"Microsoft.AKS","type":"Compute.AKS-Engine.Linux.Billing","typeHandlerVersion":"1.0","autoUpgradeMinorVersion":true,"settings":{}}},{"name":"Microsoft.Azure.Geneva.GenevaMonitoring","properties":{"publisher":"Microsoft.Azure.Geneva","type":"GenevaMonitoring","typeHandlerVersion":"2.0","autoUpgradeMinorVersion":true,"settings":{}}}]}

Generated ARM template:

{\"extensions\":[{\"name\":\"vmssCSE\",\"properties\":{\"autoUpgradeMinorVersion\":true,\"protectedSettings\":{\"commandToExecute\":\"[concat('echo %DATE%,%TIME%,%COMPUTERNAME% \\u0026\\u0026 powershell.exe -ExecutionPolicy Unrestricted -command \\\"', '$arguments = ', variables('singleQuote'),'-MasterIP ',variables('kubernetesAPIServerIP'),' -KubeDnsServiceIp ',parameters('kubeDnsServiceIp'),' -MasterFQDNPrefix ',variables('masterFqdnPrefix'),' -Location ',variables('location'),' -TargetEnvironment ',parameters('targetEnvironment'),' -AgentKey ',parameters('clientPrivateKey'),' -AADClientId ',variables('servicePrincipalClientId'),' -AADClientSecret ',variables('singleQuote'),variables('singleQuote'),base64(variables('servicePrincipalClientSecret')),variables('singleQuote'),variables('singleQuote'),' -NetworkAPIVersion ',variables('apiVersionNetwork'),' ',variables('singleQuote'), ' ; ', variables('windowsCustomScriptSuffix'), '\\\" \\u003e %SYSTEMDRIVE%\\\\AzureData\\\\CustomDataSetupScript.log 2\\u003e\\u00261 ; exit $LASTEXITCODE')]\"},\"publisher\":\"Microsoft.Compute\",\"settings\":{},\"type\":\"CustomScriptExtension\",\"typeHandlerVersion\":\"1.8\"}},{\"name\":\"[concat(variables('winnp1VMNamePrefix'), '-AKSWindowsBilling')]\",\"properties\":{\"autoUpgradeMinorVersion\":true,\"publisher\":\"Microsoft.AKS\",\"settings\":{},\"type\":\"Compute.AKS-Engine.Linux.Billing\",\"typeHandlerVersion\":\"1.0\"}}]}

Steps To Reproduce

Expected behavior
The type of VirtualMachineScaleSetExtension should be changed to Compute.AKS.Windows.Billing
or Compute.Engine.Linux.Billing but it is still Compute.AKS-Engine.Linux.Billing
AKS Engine version
0.45.0

Kubernetes version
1.16.1

Additional context
I use below snippet code to verify it

// You can edit this code!
// Click here and start typing.
package main
import (
    "encoding/json"
    "fmt"
    "github.com/Azure/go-autorest/autorest/to"
)
type VirtualMachineScaleSetExtension struct {
    // Name - The name of the extension.
    Name *string `json:"name,omitempty"`
    // Type - READ-ONLY; Resource type
    Type                                       *string `json:"type,omitempty"`
    *VirtualMachineScaleSetExtensionProperties `json:"properties,omitempty"`
    // ID - READ-ONLY; Resource Id
    ID *string `json:"id,omitempty"`
}
type VirtualMachineScaleSetExtensionProperties struct {
    // ForceUpdateTag - If a value is provided and is different from the previous value, the extension handler will be forced to update even if the extension configuration has not changed.
    ForceUpdateTag *string `json:"forceUpdateTag,omitempty"`
    // Publisher - The name of the extension handler publisher.
    Publisher *string `json:"publisher,omitempty"`
    // Type - Specifies the type of the extension; an example is "CustomScriptExtension".
    Type *string `json:"type,omitempty"`
    // TypeHandlerVersion - Specifies the version of the script handler.
    TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"`
    // AutoUpgradeMinorVersion - Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true.
    AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"`
    // Settings - Json formatted public settings for the extension.
    Settings interface{} `json:"settings,omitempty"`
    // ProtectedSettings - The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all.
    ProtectedSettings interface{} `json:"protectedSettings,omitempty"`
    // ProvisioningState - READ-ONLY; The provisioning state, which only appears in the response.
    ProvisioningState *string `json:"provisioningState,omitempty"`
    // ProvisionAfterExtensions - Collection of extension names after which this extension needs to be provisioned.
    ProvisionAfterExtensions *[]string `json:"provisionAfterExtensions,omitempty"`
}
func main() {
    e := VirtualMachineScaleSetExtension{
        Name: to.StringPtr("haha"),
        VirtualMachineScaleSetExtensionProperties: &VirtualMachineScaleSetExtensionProperties{
            Publisher:               to.StringPtr("Microsoft.AKS"),
            Type:                    to.StringPtr("Compute.AKS-Engine.Linux.Billing"),
            TypeHandlerVersion:      to.StringPtr("1.0"),
            AutoUpgradeMinorVersion: to.BoolPtr(true),
            Settings:                map[string]interface{}{},
        },
    }
    s, _ := json.Marshal(e)
    fmt.Println(string(s))
    
    e.Type = to.StringPtr("Compute.AKS.Windows.Billing")
    e.VirtualMachineScaleSetExtensionProperties.Type = to.StringPtr("Compute.AKS.Windows.Billing")
    s, _ = json.Marshal(e)
    fmt.Println(string(s))
}

Output:

{"name":"haha","properties":{"publisher":"Microsoft.AKS","type":"Compute.AKS-Engine.Linux.Billing","typeHandlerVersion":"1.0","autoUpgradeMinorVersion":true,"settings":{}}}
{"name":"haha","type":"Compute.AKS.Windows.Billing","properties":{"publisher":"Microsoft.AKS","type":"Compute.AKS.Windows.Billing","typeHandlerVersion":"1.0","autoUpgradeMinorVersion":true,"settings":{}}}

@AbelHu AbelHu added the bug Something isn't working label Jan 19, 2020
@welcome
Copy link

welcome bot commented Jan 19, 2020

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

@CecileRobertMichon
Copy link
Contributor

⚠️ IMPORTANT: this needs to be fixed before the next Azure SDK for Go update. After offline discussion we realized this was due to a change in the SDK since v0.36.0 (version AKS Engine is currently using) and now.

cc @mboersma @jackfrancis @devigned

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants