Skip to content

Commit

Permalink
Merge branch 'canonical:main' into fall-back-to-cached-ds-if-no-valid…
Browse files Browse the repository at this point in the history
…-ds-found
  • Loading branch information
PengpengSun authored Mar 29, 2024
2 parents 427c3b9 + 9d598f2 commit e95f577
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
name: linkcheck in CI

name: scheduled-linkcheck
on:
push:
branches:
- main
pull_request: {}
workflow_dispatch:
inputs:
failOnError:
description: 'Fail job on link check error'
required: false
default: 'false'
schedule:
- cron: '3 14 * * *'
concurrency:
group: 'ci-${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true

jobs:
linkcheck:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: scheduled
name: scheduled-hypothesis
on:
schedule:
- cron: '3 14 * * *'
Expand Down
8 changes: 6 additions & 2 deletions cloudinit/net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,11 +839,15 @@ def find_entry(mac, driver, device_id):

if len(ops) + len(ups) == 0:
if len(errors):
LOG.debug("unable to do any work for renaming of %s", renames)
LOG.warning(
"Unable to rename interfaces: %s due to errors: %s",
renames,
errors,
)
else:
LOG.debug("no work necessary for renaming of %s", renames)
else:
LOG.debug("achieving renaming of %s with ops %s", renames, ops + ups)
LOG.debug("Renamed %s with ops %s", renames, ops + ups)

for op, mac, new_name, params in ops + ups:
try:
Expand Down
30 changes: 23 additions & 7 deletions cloudinit/net/ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(
# List of commands to run to cleanup state.
self.cleanup_cmds: List[Callable] = []
self.distro = distro
self.cidr = f"{self.ip}/{self.prefix}"

def __enter__(self):
"""Perform ephemeral network setup if interface is not connected."""
Expand Down Expand Up @@ -122,15 +123,16 @@ def __exit__(self, excp_type, excp_value, excp_traceback):

def _bringup_device(self):
"""Perform the ip commands to fully setup the device."""
cidr = "{0}/{1}".format(self.ip, self.prefix)
LOG.debug(
"Attempting setup of ephemeral network on %s with %s brd %s",
self.interface,
cidr,
self.cidr,
self.broadcast,
)
try:
self.distro.net_ops.add_addr(self.interface, cidr, self.broadcast)
self.distro.net_ops.add_addr(
self.interface, self.cidr, self.broadcast
)
except ProcessExecutionError as e:
if "File exists" not in str(e.stderr):
raise
Expand All @@ -150,7 +152,9 @@ def _bringup_device(self):
)
)
self.cleanup_cmds.append(
partial(self.distro.net_ops.del_addr, self.interface, cidr)
partial(
self.distro.net_ops.del_addr, self.interface, self.cidr
)
)

def _bringup_static_routes(self):
Expand Down Expand Up @@ -356,10 +360,22 @@ def get_first_option_value(
class DhcpcdEphemeralIPv4Network(EphemeralIPv4Network):
"""dhcpcd sets up its own ephemeral network and routes"""

def __enter__(self):
return
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def __exit__(self, excp_type, excp_value, excp_traceback):
# clean up after dhcpcd
self.cleanup_cmds.append(
partial(
self.distro.net_ops.link_down,
self.interface,
family="inet",
)
)
self.cleanup_cmds.append(
partial(self.distro.net_ops.del_addr, self.interface, self.cidr)
)

def __enter__(self):
return


Expand Down

0 comments on commit e95f577

Please sign in to comment.