Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in get_dhcp_pid (CoreOS) #2784

Merged
merged 3 commits into from
Mar 10, 2023
Merged

Fix bug in get_dhcp_pid (CoreOS) #2784

merged 3 commits into from
Mar 10, 2023

Conversation

narrieta
Copy link
Member

@narrieta narrieta commented Mar 10, 2023

CoreOs and derivatives (e.g. Flatcar) use "systemctl show -p MainPID systemd-networkd" to get the PID of the DHCP client. This command will return something similar to "MainPID=<PID>", while the existing code expects only an int (the "<PID>" part). This is a very old bug exposed by adding Flatcar to the tests.

The fix removes "MainPID=" from the command's output.

The PR also includes some fixes for pylint pointing out issues in import statements.

@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #2784 (bff66e2) into develop (3aebcdd) will increase coverage by 0.01%.
The diff coverage is 82.36%.

❗ Current head bff66e2 differs from pull request most recent head 473632d. Consider uploading reports for the commit 473632d to get more accurate results

@@             Coverage Diff             @@
##           develop    #2784      +/-   ##
===========================================
+ Coverage    71.97%   71.99%   +0.01%     
===========================================
  Files          103      104       +1     
  Lines        15692    15844     +152     
  Branches      2486     2268     -218     
===========================================
+ Hits         11295    11407     +112     
- Misses        3881     3914      +33     
- Partials       516      523       +7     
Impacted Files Coverage Δ
azurelinuxagent/common/future.py 36.36% <0.00%> (-0.85%) ⬇️
azurelinuxagent/ga/collect_logs.py 81.15% <0.00%> (-0.36%) ⬇️
azurelinuxagent/common/logcollector.py 88.35% <33.33%> (+0.04%) ⬆️
azurelinuxagent/common/osutil/factory.py 91.11% <33.33%> (-2.00%) ⬇️
azurelinuxagent/daemon/main.py 71.42% <33.33%> (+0.29%) ⬆️
azurelinuxagent/common/osutil/fedora.py 46.51% <46.51%> (ø)
azurelinuxagent/common/cgroupconfigurator.py 72.19% <57.89%> (-1.39%) ⬇️
azurelinuxagent/common/protocol/hostplugin.py 87.76% <75.00%> (+0.09%) ⬆️
azurelinuxagent/common/protocol/wire.py 77.37% <84.90%> (-1.18%) ⬇️
azurelinuxagent/ga/exthandlers.py 86.06% <87.50%> (+0.37%) ⬆️
... and 16 more

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@narrieta narrieta merged commit 355dd09 into Azure:develop Mar 10, 2023
@narrieta narrieta deleted the flatcar branch March 10, 2023 20:07
jepio added a commit to flatcar/scripts that referenced this pull request Nov 15, 2023
This is the current version being deployed to the Azure fleet for other
distros. This update contains a fix for:

  Failed to get the PID of the DHCP client: invalid literal for int() with base 10: 'MainPID=1640'

The upstream fix (stripping MainPid=) is in
Azure/WALinuxAgent#2784.

The patch has also been updated to fix the error:

  Unable to setup the persistent firewall rules: [Errno 30] Read-only file system: '/lib/systemd/system/waagent-network-setup.service'

by redirecting unit file installation to /etc/systemd/system.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
jepio added a commit to flatcar/scripts that referenced this pull request Nov 15, 2023
This is the current version being deployed to the Azure fleet for other
distros. This update contains a fix for:

  Failed to get the PID of the DHCP client: invalid literal for int() with base 10: 'MainPID=1640'

The upstream fix (stripping MainPid=) is in
Azure/WALinuxAgent#2784.

The patch has also been updated to fix the error:

  Unable to setup the persistent firewall rules: [Errno 30] Read-only file system: '/lib/systemd/system/waagent-network-setup.service'

by redirecting unit file installation to /etc/systemd/system.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
jepio added a commit to flatcar/scripts that referenced this pull request Nov 16, 2023
This is the current version being deployed to the Azure fleet for other
distros. This update contains a fix for:

  Failed to get the PID of the DHCP client: invalid literal for int() with base 10: 'MainPID=1640'

The upstream fix (stripping MainPid=) is in
Azure/WALinuxAgent#2784.

The patch has also been updated to fix the error:

  Unable to setup the persistent firewall rules: [Errno 30] Read-only file system: '/lib/systemd/system/waagent-network-setup.service'

by redirecting unit file installation to /etc/systemd/system. This
change requires handling in manglefs.sh as package installation
unfortunately uses the same path.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
jepio added a commit to flatcar/scripts that referenced this pull request Nov 16, 2023
This is the current version being deployed to the Azure fleet for other
distros. This update contains a fix for:

  Failed to get the PID of the DHCP client: invalid literal for int() with base 10: 'MainPID=1640'

The upstream fix (stripping MainPid=) is in
Azure/WALinuxAgent#2784.

The patch has also been updated to fix the error:

  Unable to setup the persistent firewall rules: [Errno 30] Read-only file system: '/lib/systemd/system/waagent-network-setup.service'

by redirecting unit file installation to /etc/systemd/system. This change
requires handling in manglefs.sh as package installation unfortunately uses the
same path. This also requires adding a dependency on systemd-sysext.service to
that unit, as it depends on python.

A final change is handling interface restart. RedHat and Ubuntu bounce a single
link while Flatcar has so far used the "coreos" implementation (restart the
whole systemd-networkd), which forced a full dhcp lease renewal. Follow the
approaches of other distros by copying their implementation of restart_if.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
jepio added a commit to flatcar/scripts that referenced this pull request Nov 17, 2023
This is the current version being deployed to the Azure fleet for other
distros. This update contains a fix for:

  Failed to get the PID of the DHCP client: invalid literal for int() with base 10: 'MainPID=1640'

The upstream fix (stripping MainPid=) is in
Azure/WALinuxAgent#2784.

The patch has also been updated to fix the error:

  Unable to setup the persistent firewall rules: [Errno 30] Read-only file system: '/lib/systemd/system/waagent-network-setup.service'

by redirecting unit file installation to /etc/systemd/system. This change
requires handling in manglefs.sh as package installation unfortunately uses the
same path. This also requires adding a dependency on systemd-sysext.service to
that unit, as it depends on python.

A final change is handling interface restart. RedHat and Ubuntu bounce a single
link while Flatcar has so far used the "coreos" implementation (restart the
whole systemd-networkd), which forced a full dhcp lease renewal. Follow the
approaches of other distros by copying their implementation of restart_if.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
jepio added a commit to flatcar/scripts that referenced this pull request Nov 17, 2023
This is the current version being deployed to the Azure fleet for other
distros. This update contains a fix for:

  Failed to get the PID of the DHCP client: invalid literal for int() with base 10: 'MainPID=1640'

The upstream fix (stripping MainPid=) is in
Azure/WALinuxAgent#2784.

The patch has also been updated to fix the error:

  Unable to setup the persistent firewall rules: [Errno 30] Read-only file system: '/lib/systemd/system/waagent-network-setup.service'

by redirecting unit file installation to /etc/systemd/system. This change
requires handling in manglefs.sh as package installation unfortunately uses the
same path. This also requires adding a dependency on systemd-sysext.service to
that unit, as it depends on python, which is done through a drop-in.

A final change is handling interface restart. RedHat and Ubuntu bounce a single
link while Flatcar has so far used the "coreos" implementation (restart the
whole systemd-networkd), which forced a full dhcp lease renewal. Follow the
approaches of other distros by copying their implementation of restart_if.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants