Skip to content

local variable 'enableScriptParameters' referenced before assignment #256

Open
@MarkRx

Description

@MarkRx

Using VMSS 1.26.2.0 VMs are sometimes failing to start with the below error:

/var/log/waagent.log:

2025-05-16T18:29:33.610196Z INFO ExtHandler [Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0] Executing command: /var/lib/waagent/Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0/Handler.sh -disable with environment variabl
es: {"AZURE_GUEST_AGENT_EXTENSION_PATH": "/var/lib/waagent/Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0", "AZURE_GUEST_AGENT_EXTENSION_VERSION": "1.26.2.0", "AZURE_GUEST_AGENT_WIRE_PROTOCOL_ADDRESS": "168.63.129.16", "ConfigSequenceNum
ber": "0", "AZURE_GUEST_AGENT_EXTENSION_SUPPORTED_FEATURES": "[{"Key": "ExtensionTelemetryPipeline", "Value": "1.0"}]"}
Fri May 16 18:29:33 UTC 2025- /usr/bin/python3 path exists
2025/05/16 18:29:33 [Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0] cwd is /var/lib/waagent/Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0
2025/05/16 18:29:33 [Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0] Change log file to /var/log/azure/Microsoft.VisualStudio.Services.TeamServicesAgentLinux/extension.log
2025-05-16T18:29:35.619108Z ERROR ExtHandler ExtHandler Event: name=Microsoft.VisualStudio.Services.TeamServicesAgentLinux, op=Disable, message=[ExtensionOperationError] Non-zero exit code: 53, /var/lib/waagent/Microsoft.VisualStudio.Services.TeamService
sAgentLinux-1.26.2.0/Handler.sh -disable
[stdout]
2025/05/16 18:29:33 ERROR:[Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0] Error occured during Read config settings. local variable 'enableScriptParameters' referenced before assignment

[stderr]
, duration=0

Note this error shows up in #245 which has been closed as fixed.

I believe it is failing on this line.

It looks like enableScriptParameters is missing.

      if('enableScriptParameters' in public_settings):
        handler_utility.log("using public enableScriptParameters")
        enableScriptParameters = public_settings['enableScriptParameters']
      elif('enableScriptParameters' in protected_settings):
        handler_utility.log("using protected enableScriptParameters")
        enableScriptParameters = protected_settings['enableScriptParameters']

Here is the settings file (203.settings). protectedSettings is an empty string but perhaps that gets wiped at some point.

sudo cat /var/lib/waagent/Microsoft.VisualStudio.Services.TeamServicesAgentLinux-1.26.2.0/config/*.settings | jq
{
  "runtimeSettings": [
    {
      "handlerSettings": {
        "publicSettings": {
          "isPipelinesAgent": true,
          "agentFolder": "/agent",
          "agentDownloadUrl": "https://vstsagentpackage.azureedge.net/agent/4.255.0/vsts-agent-linux-x64-4.255.0.tar.gz",
          "enableScriptDownloadUrl": "https://vstsagenttools.blob.core.windows.net/tools/ElasticPools/Linux/17/enableagent.sh"
        },
        "protectedSettings": "",
        "protectedSettingsCertThumbprint": "<redacted>"
      }
    }
  ]
}

I don't know where this file comes from or how it was placed there. Should the script handle the case when enableScriptParameters is missing? Or is something upstream not properly setting that key in the dictionary?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions