-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat(cv_deploy): Add verification of the duplicated devices #4889
base: devel
Are you sure you want to change the base?
Feat(cv_deploy): Add verification of the duplicated devices #4889
Conversation
Review docs on Read the Docs To test this pull request: # Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4889
# Activate the virtual environment
source test-avd-pr-4889/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/alexeygorbunov/avd.git@feature/verify_devices_on_cv_ex_pr_3957#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/alexeygorbunov/avd.git#/ansible_collections/arista/avd/,feature/verify_devices_on_cv_ex_pr_3957 --force
# Optional: Install AVD examples
cd test-avd-pr-4889
ansible-playbook arista.avd.install_examples |
@@ -87,6 +88,7 @@ The `arista.avd.cv_workflow` module is an Ansible Action Plugin providing the fo | |||
device_list: "{{ ansible_play_hosts }}" | |||
# strict_tags: false | |||
# skip_missing_devices: false | |||
# tolerate_duplicated_devices: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would it be a good idea to tolerate duplicated devices? I know this would restrict existing deployments, but I see it more as a bug that we allow duplicate serials Today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, can't think of any valid scenario where one would on purpose use the same serial/sys_mac on multiple devices.
Default True
is more to have this change as a non-breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it more as a fix, so I am not sure we need this knob. We are just catching invalid inputs earlier instead of waiting until the workspace is built or the devices are broken because we push config to the wrong device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example usecase where we may want to have this knob present and allow duplicated items by default:
- multiple devices, all with both serial_number and system_mac_address set
- all devices have unique serial_numbers but some have overlapping system_mac_address
- this would work OK with AVD+ CV by default as serial_number is prioritized (if set) as an identity attribute (so duplicated system mac would just be ignored by AVD)
- blocking execution in such case (due to the duplicated system mac) would break a valid deployment (although with partially invalid inputs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's change this PR then, to only check for duplicate serials and not have a toggle for it. This is really what is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated system_mac_address may probably cause incorrect config to be pushed to the incorrect device as well. Potential scenario:
- At least 2 devices with "serial_number" not set (in structured inputs) and with the same/duplicated "system_mac_address" set
- Once we fetch
found_devices
(cv_client.get_inventory_devices) and start matching existingdevices
withfound_devices
- we'll update.serial_number
attribute of bothdevices
with real serial number (fetched from CV) matching that duplicated "system_mac_address" (address from the inputs) - At this point we'll have 2 devices with the same 'serial_number' and 'system_mac_address' but different hostnames and designed EOS config.
- We can then end up with serial-based (for ID) containers/configlets on CV holding actual EOS configuration from one of the two raw EoS config files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but then we should never accept duplicate system mac either. It does not make sense to ignore something that could explode easily later.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…es_on_cv_ex_pr_3957
Conflicts have been resolved. A maintainer will review the pull request shortly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, LGTM. Error messages appear as expected for duplicated devices.
|
Change Summary
Add new functionality to validate if
structured config
of the hosts processed bycv_deploy
role contains overlappingserial_number
ormetadata.system_mac_address
values.Related Issue(s)
N/A
Component(s) name
arista.avd.cv_deploy
Proposed changes
deploy_to_cv
workflow to analyzeserial_number
andmetadata.system_mac_address
values (based on their structured_config files generated byeos_designs
) of all targeted hosts.cv_tolerate_duplicated_devices
to control desired behavior of the role if duplicated devices are discovered. Defaultcv_tolerate_duplicated_devices: true
allows workflow to continue even if duplicated devices are discovered. Settingcv_tolerate_duplicated_devices
tofalse
instructs role to terminate role's execution when duplicated devices are discovered.How to test
cv_deploy
molecule test:no_duplicated_devices.yml
tests regularcv_deploy
withserial_number
andmetadata.system_mac_address
values being uniquely set per targeted deviceduplicated_devices_with_tolerance.yml
testscv_deploy
with overlappingserial_number
andmetadata.system_mac_address
values and default value ofcv_tolerate_duplicated_devices
(True
)The following warnings are displayed during the execution:
Same warnings are exposed in
cv_deploy_results
:duplicated_devices_without_tolerance.yml
testscv_deploy
with overlappingserial_number
andmetadata.system_mac_address
values and non-default value ofcv_tolerate_duplicated_devices
(False
)Exception is raised during the execution of the task
arista.avd.cv_deploy : Deploy device configurations and tags to CloudVision
.Execution is stopped and details of the errors are exposed in
cv_deploy_results
:Checklist
User Checklist
Repository Checklist