Skip to content

[vm_set]: Add fallback default for VM_targets when VMs are not required#23361

Merged
auspham merged 1 commit intosonic-net:masterfrom
ediwibowo-msft:docker-keysight-api-server_vm_required
Mar 27, 2026
Merged

[vm_set]: Add fallback default for VM_targets when VMs are not required#23361
auspham merged 1 commit intosonic-net:masterfrom
ediwibowo-msft:docker-keysight-api-server_vm_required

Conversation

@ediwibowo-msft
Copy link
Copy Markdown
Contributor

@ediwibowo-msft ediwibowo-msft commented Mar 26, 2026

Description of PR

Summary:
When ptf_imagename is docker-keysight-api-server, vm_required is set to false, which skips the block that defines VM_targets. However, remove_topo.yml and add_topo.yml reference VM_targets unconditionally, causing VM_targets is undefined errors during topology teardown.

This change adds a top-level fallback that sets VM_targets to an empty list when it is not defined.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

Topology setup and teardown should not fail when VMs are intentionally not required. For the docker-keysight-api-server PTF image, VM creation is skipped by design, but downstream tasks still assume VM_targets exists. That leads to avoidable teardown failures caused by an undefined variable rather than a real topology issue.

How did you do it?

Added a top-level fallback in ansible/roles/vm_set/tasks/main.yml to initialize VM_targets to an empty list when it is not defined. This matches the existing defensive pattern already used for dpu_targets and allows add_topo.yml and remove_topo.yml to evaluate safely even when VM setup is skipped.

How did you verify/test it?

Verified the change by reviewing the execution flow for the case where ptf_imagename == 'docker-keysight-api-server' and confirming that:

  • vm_required can be false
  • the VM initialization block can be skipped
  • VM_targets is still defined afterward
  • downstream references in topology add/remove tasks can execute without VM_targets is undefined

Any platform specific information?

This change is primarily relevant to environments using docker-keysight-api-server, where VMs are not required. It is otherwise low risk because it only provides a default empty list when VM_targets was previously undefined.

Supported testbed topology if it's a new test case?

Not applicable. This is not a new test case.

Documentation

No documentation update is required for this bug fix.

When ptf_imagename is 'docker-keysight-api-server', vm_required is set
to false, which skips the block that defines VM_targets. However,
remove_topo.yml and add_topo.yml reference VM_targets unconditionally,
causing 'VM_targets is undefined' errors during topology teardown.

Add a top-level fallback that sets VM_targets to an empty list when it
is not defined.

Signed-off-by: Edi Wibowo <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@auspham auspham enabled auto-merge (squash) March 26, 2026 23:38
@wangxin
Copy link
Copy Markdown
Collaborator

wangxin commented Mar 27, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@wangxin wangxin disabled auto-merge March 27, 2026 00:03
@auspham auspham merged commit 8812290 into sonic-net:master Mar 27, 2026
18 of 19 checks passed
@ediwibowo-msft
Copy link
Copy Markdown
Contributor Author

ADO PBI# 37299108

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Mar 27, 2026
…ed (sonic-net#23361)

When ptf_imagename is 'docker-keysight-api-server', vm_required is set
to false, which skips the block that defines VM_targets. However,
remove_topo.yml and add_topo.yml reference VM_targets unconditionally,
causing 'VM_targets is undefined' errors during topology teardown.

Add a top-level fallback that sets VM_targets to an empty list when it
is not defined.

Signed-off-by: Edi Wibowo <[email protected]>
Signed-off-by: mssonicbld <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202511: #23377

@ediwibowo-msft ediwibowo-msft deleted the docker-keysight-api-server_vm_required branch March 28, 2026 02:49
@ediwibowo-msft ediwibowo-msft restored the docker-keysight-api-server_vm_required branch March 28, 2026 02:50
@ediwibowo-msft ediwibowo-msft deleted the docker-keysight-api-server_vm_required branch March 28, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants