bundles/apt: fix metadata key mess (unattended-upgrades vs unattended_upgrades)
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
07157b6335
commit
0ccb983b28
13 changed files with 66 additions and 28 deletions
|
@ -1,3 +1,3 @@
|
|||
nodename="${node.name}"
|
||||
reboot_mail_to="${node.metadata.get('apt/unattended-upgrades/reboot_mail_to', '')}"
|
||||
auto_reboot_enabled="${node.metadata.get('apt/unattended-upgrades/reboot-enabled', True)}"
|
||||
auto_reboot_enabled="${node.metadata.get('apt/unattended-upgrades/reboot_enabled', True)}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
defaults = {
|
||||
'apt': {
|
||||
'unattended_upgrades': {
|
||||
'unattended-upgrades': {
|
||||
'day': 5,
|
||||
'hour': 21,
|
||||
},
|
||||
|
@ -21,8 +21,8 @@ defaults = {
|
|||
'cron/upgrade-and-reboot'
|
||||
)
|
||||
def patchday(metadata):
|
||||
day = metadata.get('apt/unattended_upgrades/day')
|
||||
hour = metadata.get('apt/unattended_upgrades/hour')
|
||||
day = metadata.get('apt/unattended-upgrades/day')
|
||||
hour = metadata.get('apt/unattended-upgrades/hour')
|
||||
|
||||
return {
|
||||
'cron': {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
defaults = {
|
||||
'apt': {
|
||||
'unattended_upgrades': {
|
||||
'unattended-upgrades': {
|
||||
'day': 5,
|
||||
'hour': 21,
|
||||
},
|
||||
|
@ -28,8 +28,8 @@ defaults = {
|
|||
'cron/upgrade-and-reboot'
|
||||
)
|
||||
def patchday(metadata):
|
||||
day = metadata.get('apt/unattended_upgrades/day')
|
||||
hour = metadata.get('apt/unattended_upgrades/hour')
|
||||
day = metadata.get('apt/unattended-upgrades/day')
|
||||
hour = metadata.get('apt/unattended-upgrades/hour')
|
||||
|
||||
return {
|
||||
'cron': {
|
||||
|
|
|
@ -9,7 +9,7 @@ object ScheduledDowntime "unattended_upgrades" {
|
|||
fixed = true
|
||||
|
||||
ranges = {
|
||||
"${days[monitored_node.metadata.get('apt/unattended_upgrades/day')]}" = "${monitored_node.metadata.get('apt/unattended_upgrades/hour')}:${monitored_node.magic_number%30}-${monitored_node.metadata.get('apt/unattended_upgrades/hour')}:${(monitored_node.magic_number%30)+30}"
|
||||
"${days[monitored_node.metadata.get('apt/unattended-upgrades/day')]}" = "${monitored_node.metadata.get('apt/unattended-upgrades/hour')}:${monitored_node.magic_number%30}-${monitored_node.metadata.get('apt/unattended-upgrades/hour')}:${(monitored_node.magic_number%30)+30}"
|
||||
}
|
||||
|
||||
child_options = "DowntimeTriggeredChildren"
|
||||
|
|
|
@ -110,6 +110,13 @@ groups['voc'] = {
|
|||
r"voc\..*",
|
||||
},
|
||||
'metadata': {
|
||||
'apt': {
|
||||
# Move patchday to somewhere where the possibility of
|
||||
# clashing with actual events is less likely.
|
||||
'unattended-upgrades': {
|
||||
'day': 1,
|
||||
},
|
||||
},
|
||||
'location': 'voc',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ groups['linux'] = {
|
|||
'metadata': {
|
||||
'apt': {
|
||||
'unattended-upgrades': {
|
||||
'mail': libs.defaults.hostmaster_email,
|
||||
'reboot_mail_to': libs.defaults.hostmaster_email,
|
||||
},
|
||||
},
|
||||
'backup-client': {
|
||||
|
|
45
hooks/test_metadata_dashes_vs_underscores.py
Normal file
45
hooks/test_metadata_dashes_vs_underscores.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from collections.abc import Mapping
|
||||
|
||||
from bundlewrap.exceptions import BundleError
|
||||
from bundlewrap.utils.text import bold, green
|
||||
from bundlewrap.utils.ui import io
|
||||
|
||||
def test_underscore_vs_dash(node, metadata, path=[]):
|
||||
for k, v in metadata.items():
|
||||
if not isinstance(k, str):
|
||||
continue
|
||||
|
||||
all_dashes = k.replace('_', '-')
|
||||
all_underscores = k.replace('-', '_')
|
||||
|
||||
if k != all_dashes and all_dashes in metadata:
|
||||
raise BundleError('{n} metadata contains both {k} and {p}'.format(
|
||||
n=node.name,
|
||||
k='/'.join(path + [k]),
|
||||
p='/'.join(path + [all_dashes]),
|
||||
))
|
||||
|
||||
if k != all_underscores and all_underscores in metadata:
|
||||
raise BundleError('{n} metadata contains both {k} and {p}'.format(
|
||||
n=node.name,
|
||||
k='/'.join(path + [k]),
|
||||
p='/'.join(path + [all_underscores]),
|
||||
))
|
||||
|
||||
if isinstance(v, Mapping):
|
||||
test_underscore_vs_dash(
|
||||
node,
|
||||
v,
|
||||
path + [k],
|
||||
)
|
||||
|
||||
def test_node(repo, node, **kwargs):
|
||||
test_underscore_vs_dash(
|
||||
node,
|
||||
node.metadata.get(tuple()),
|
||||
)
|
||||
|
||||
io.stdout('{x} {node} metadata contains no dashes-vs-underscores errors'.format(
|
||||
x=green("✓"),
|
||||
node=bold(node.name),
|
||||
))
|
|
@ -14,7 +14,7 @@ nodes['home.kodi-wohnzimmer'] = {
|
|||
'packages': {
|
||||
'intel-media-va-driver-non-free': {},
|
||||
},
|
||||
'unattended_upgrades': {
|
||||
'unattended-upgrades': {
|
||||
'day': 6,
|
||||
'hour': 2,
|
||||
},
|
||||
|
|
|
@ -26,10 +26,10 @@ nodes['home.nas'] = {
|
|||
},
|
||||
},
|
||||
'apt': {
|
||||
'unattended_upgrades': {
|
||||
'unattended-upgrades': {
|
||||
'day': 6,
|
||||
# requires manual decryption of zfs after reboot
|
||||
'reboot-enabled': False,
|
||||
'reboot_enabled': False,
|
||||
},
|
||||
'packages': {
|
||||
'mpv': {},
|
||||
|
|
|
@ -13,7 +13,7 @@ nodes['htz-hel.backup-kunsi'] = {
|
|||
'unattended-upgrades': {
|
||||
# requires manual apply after reboot to unlock dm-crypt
|
||||
# devices
|
||||
'reboot-enabled': False,
|
||||
'reboot_enabled': False,
|
||||
},
|
||||
},
|
||||
'interfaces': {
|
||||
|
|
|
@ -16,7 +16,7 @@ nodes['htz-hel.backup-sophie'] = {
|
|||
'unattended-upgrades': {
|
||||
# requires manual apply after reboot to unlock dm-crypt
|
||||
# devices
|
||||
'reboot-enabled': False,
|
||||
'reboot_enabled': False,
|
||||
},
|
||||
},
|
||||
'backups': {
|
||||
|
|
|
@ -9,13 +9,6 @@ nodes['voc.infobeamer-cms'] = {
|
|||
'webserver',
|
||||
},
|
||||
'metadata': {
|
||||
'apt': {
|
||||
# Move patchday to somewhere where the possibility of
|
||||
# clashing with actual events is less likely.
|
||||
'unattended_upgrades': {
|
||||
'day': 1,
|
||||
},
|
||||
},
|
||||
'backups': {
|
||||
'exclude_from_backups': True,
|
||||
},
|
||||
|
|
|
@ -14,13 +14,6 @@ nodes['voc.pretalx'] = {
|
|||
'sshmon',
|
||||
},
|
||||
'metadata': {
|
||||
'apt': {
|
||||
# Move patchday to somewhere where the possibility of
|
||||
# clashing with actual events is less likely.
|
||||
'unattended_upgrades': {
|
||||
'day': 1,
|
||||
},
|
||||
},
|
||||
'check-mail-received': {
|
||||
't-online': {
|
||||
'email': 'franzi.kunsmann@t-online.de',
|
||||
|
|
Loading…
Reference in a new issue