From d524ed39a3bb1ded68e60b94970c7ef02b0e6291 Mon Sep 17 00:00:00 2001 From: Dayou Liu <113053330+dayouliu1@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:32:41 -0800 Subject: [PATCH] fix sample_golden_config_db.j2 portchannel undefined (#15311) Add portchannel check to sample_golden_config_db.j2 to resolve errors for topos (specifically mx) that do not have portchannels for golden_config_infra/test_config_reload_with_rendered_golden_config.py when running `sonic-cfggen -d -t /tmp/golden_config_db.j2 > /etc/sonic/golden_config_db.json` --- .../templates/sample_golden_config_db.j2 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/golden_config_infra/templates/sample_golden_config_db.j2 b/tests/golden_config_infra/templates/sample_golden_config_db.j2 index 07a119dd2e5..634711e4225 100644 --- a/tests/golden_config_infra/templates/sample_golden_config_db.j2 +++ b/tests/golden_config_infra/templates/sample_golden_config_db.j2 @@ -1,7 +1,9 @@ {% set portchannels= [] %} -{% for pc, value in PORTCHANNEL.items() %} - {% set _ = portchannels.append(pc) %} -{% endfor %} +{% if PORTCHANNEL is defined %} + {% for pc, value in PORTCHANNEL.items() %} + {% set _ = portchannels.append(pc) %} + {% endfor %} +{% endif %} { "NEW_FEATURE": {