Fix unhandled apt_configure case (SC-526)#1065
Conversation
cloudinit/config/cc_apt_configure.py
Outdated
| default = None | ||
| for mirror_cfg_elem in mirror_cfg_list: | ||
| arches = mirror_cfg_elem.get("arches") | ||
| arches = mirror_cfg_elem.get("arches", []) |
There was a problem hiding this comment.
If mirror_cfg_elem = {'arches', None}, we still have a problem. I haven't checked so this might not even be possible, but just in general for these sorts of operations I prefer something more like
arches = mirror_cfg_elem.get("arches") or []There was a problem hiding this comment.
Good catch, that looks like a safer pattern to use.
|
A second look at this suggests that setting From the docs:
For a security mirror config: Consider the following resulting log: Note that the security mirror falls back to the primary mirror. It looks like the schema attempts to make arches 'required', however I didn't see any warnings about arches in the logs. Considering this config doesn't follow the rules "must have an entry for arches", I would expect a warning log to be dropped at a minimum, rather than failing over to the primary mirror without any mention that the config is invalid. I think probably the right solution is in addition to |
|
Good catch about the schema. Yes, we should fail schema validation on that and emit a warning. Though I still think we should handle the empty case. |
Agreed |
|
I'm still working on this. I noticed another schema issue with this module: Note that the |
c76b26b to
f643853
Compare
|
The failing test pulls in the example from readthedocs and runs it. The test is fixed in #1068, so I can either pull that fix into this one, or wait until that one is merged. |
|
Easiest to just wait for #1068 and then rebase I think. |
f643853 to
b8055d5
Compare
Don't throw an exception when mirror arch is unspecified.
b8055d5 to
8af4c2c
Compare
|
I had to tweak some tests after rebasing. I think it's ready for review now. |
Proposed Commit Message
Test Steps
Use the following config.
Checklist: