[action] [PR:27669] [vm_set]: Enable ptf_use_docker_network for BMC topology only when the docker network exists - #1416
Merged
Conversation
…e docker network exists
### Description of PR
Summary:
Fixes #26542
#26405 sets `ptf_use_docker_network` to true for every BMC topology. In that mode the PTF container is created with `network_mode: {{ mgmt_bridge }}` plus a static IP on a docker network of that name, and the `Bind topology` step that would otherwise give the PTF a veth on the Linux management bridge is skipped. On servers whose `mgmt_bridge` is a Linux bridge there is no docker network of that name, so `add-topo` fails at `Create ptf container` with `Parameter error: network named br0 could not be found`.
This change probes for the docker network with `docker network inspect {{ mgmt_bridge }}` and enables the mode only when the network exists. Servers that have it keep the docker network path introduced by #23813 and #26405. Servers without it keep the Linux-bridge path, where the bind step attaches a veth into the PTF netns. An explicit `ptf_use_docker_network` setting from group_vars or host_vars still wins, since both new tasks skip when the variable is already defined.
### Type of change
- [x] Bug fix
- [x] Testbed and Framework(new/improvement)
- [ ] New Test case
- [ ] Skipped for non-supported platforms
- [ ] Test case improvement
### Back port request
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511
- [ ] 202512
- [ ] 202605
Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): #26542
Failure type: regression
### Tested branch
- [x] master
### Test result
- master: `bmc-shared-mgmt` topology on a test server where `mgmt_bridge` is a Linux bridge and no docker network of that name exists. Before the change, `add-topo` fails at `Create ptf container` as reported in #26542. With the change, `Check whether a docker network named "br0" exists` returns rc 1, the enable task is skipped, `Create ptf container` and `Bind topology bmc-shared-mgmt to VMs` both report changed, and the play ends with `failed=0`.
### Approach
#### What is the motivation for this PR?
Restore `add-topo` for BMC topologies on servers that use a Linux management bridge, which #26405 broke by assuming a docker network named after `mgmt_bridge` is present.
#### How did you do it?
In `add_topo.yml` and `renumber_topo.yml`, replace the unconditional `set_fact: ptf_use_docker_network: true` for BMC topologies with a `docker network inspect {{ mgmt_bridge }}` probe (`failed_when: false`, `changed_when: false`) followed by the same `set_fact`, now conditioned on the probe returning rc 0. Both tasks run only when `'bmc' in topo` and `ptf_use_docker_network` is not already defined.
#### How did you verify/test it?
See Test result. The probe-positive branch (docker network present, docker mode enabled) is the same code path #26405 exercised.
#### Any platform specific information?
Applies to BMC topologies only. No change for other topologies.
#### Supported testbed topology if it's a new test case?
N/A
### Documentation
N/A
Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
Collaborator
Author
|
Original PR: sonic-net/sonic-mgmt#27669 |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
Author
|
/azp run |
1 similar comment
Collaborator
Author
|
/azp run |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
13 tasks
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes #26542
#26405 sets
ptf_use_docker_networkto true for every BMC topology. In that mode the PTF container is created withnetwork_mode: {{ mgmt_bridge }}plus a static IP on a docker network of that name, and theBind topologystep that would otherwise give the PTF a veth on the Linux management bridge is skipped. On servers whosemgmt_bridgeis a Linux bridge there is no docker network of that name, soadd-topofails atCreate ptf containerwithParameter error: network named br0 could not be found.This change probes for the docker network with
docker network inspect {{ mgmt_bridge }}and enables the mode only when the network exists. Servers that have it keep the docker network path introduced by #23813 and #26405. Servers without it keep the Linux-bridge path, where the bind step attaches a veth into the PTF netns. An explicitptf_use_docker_networksetting from group_vars or host_vars still wins, since both new tasks skip when the variable is already defined.Type of change
Back port request
Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): #26542
Failure type: regression
Tested branch
Test result
bmc-shared-mgmttopology on a test server wheremgmt_bridgeis a Linux bridge and no docker network of that name exists. Before the change,add-topofails atCreate ptf containeras reported in #26542. With the change,Check whether a docker network named "br0" existsreturns rc 1, the enable task is skipped,Create ptf containerandBind topology bmc-shared-mgmt to VMsboth report changed, and the play ends withfailed=0.Approach
What is the motivation for this PR?
Restore
add-topofor BMC topologies on servers that use a Linux management bridge, which #26405 broke by assuming a docker network named aftermgmt_bridgeis present.How did you do it?
In
add_topo.ymlandrenumber_topo.yml, replace the unconditionalset_fact: ptf_use_docker_network: truefor BMC topologies with adocker network inspect {{ mgmt_bridge }}probe (failed_when: false,changed_when: false) followed by the sameset_fact, now conditioned on the probe returning rc 0. Both tasks run only when'bmc' in topoandptf_use_docker_networkis not already defined.How did you verify/test it?
See Test result. The probe-positive branch (docker network present, docker mode enabled) is the same code path #26405 exercised.
Any platform specific information?
Applies to BMC topologies only. No change for other topologies.
Supported testbed topology if it's a new test case?
N/A
Documentation
N/A
Signed-off-by: Sonic Build Admin sonicbld@microsoft.com