socallinuxexpo / scale-network

SCaLE's on-site expo network configurations, wifi, tooling, and scripts
https://www.socallinuxexpo.org/
BSD 3-Clause "New" or "Revised" License
40 stars 16 forks source link

[READY] - inventory fix for aps and apsuse #704

Closed sarcasticadmin closed 3 months ago

sarcasticadmin commented 3 months ago

Description of PR

related to: https://github.com/socallinuxexpo/scale-network/pull/698

Currently failing off master when aps are all defined in apuse.csv:

$ nix build .#scaleInventory
path '/home/rherna/workspace/scale-network/nix' does not contain a 'flake.nix', searching up
error: builder for '/nix/store/0v2dvmnmngz4lislshijlgjbybs2sxqm-scaleInventory.drv' failed with exit code 1;
       last 8 log lines:
       > Traceback (most recent call last):
       >   File "/nix/store/lfs3m43yvcn3hrphicc132py43zqg9x5-scaleInventory/.repo/facts/inventory.py", line 718, in <module>
       >     main()
       >   File "/nix/store/lfs3m43yvcn3hrphicc132py43zqg9x5-scaleInventory/.repo/facts/inventory.py", line 697, in main
       >     aps = populateaps(apsfile, apusefile)
       >   File "/nix/store/lfs3m43yvcn3hrphicc132py43zqg9x5-scaleInventory/.repo/facts/inventory.py", line 299, in populateaps
       >     ipaddr = elems[2]
       > IndexError: list index out of range
       For full logs, run 'nix log /nix/store/0v2dvmnmngz4lislshijlgjbybs2sxqm-scaleInventory.drv'.

Previous Behavior

New Behavior

Tests

sarcasticadmin commented 3 months ago

Ya no worries, i should have caught this when i split the files originally

kylerisse commented 3 months ago

Ya no worries, i should have caught this when i split the files originally

I realized what the issue was while sleeping. I was only spot checking each individual file for validity and not making sure the line count across the two matched. Since that is an OK state, then yup this all makes sense now. Nice fix. I like running inventory pkg as part of CI as a sanity check, this is similar to the step in CI that piped the output of inventory through jq, back when it only spit out json.

I now have a concern about duplicate IPs (or names or mac addresses) existing in a data file, which would still produce a valid inventory pkg run but consumer services would then fail downstream. For example trying to give Kea a config that has multiple DHCP reservations for the same IP and/or mac. Will think about it some more and open an issue if it still makes sense when I get to the NOC.