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

Added support for devuan linux distribution #2553

Merged
merged 6 commits into from
May 18, 2022

Conversation

peter9370
Copy link
Contributor

@peter9370 peter9370 commented Apr 14, 2022

Description

Issue #

Added support for linux distribution devuan

Will only work on devuan version 4 (chimaera) or later. In earlier versions of devuan, waagent uses the python module platform.linux_distribution to get the distribution details. If run under devuan, this incorrectly reports "debian" as the distro.

Devuan version 4 uses python 3.9, and in this, platform.linux_distribution has been removed, forcing waagent to use
distro.linux_distribution instead: this correctly identifies devuan.


PR information

  • [y ] The title of the PR is clear and informative.
  • [y] There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • [y ] New Unit tests were added for the changes made

Quality of Code and Contribution Guidelines

@narrieta narrieta changed the base branch from master to develop April 15, 2022 15:13
@narrieta narrieta self-assigned this Apr 15, 2022
(Will only work with Devuan >= 4 (Chimaera) - reason is
that in Devuan < 4, the platform.linux_distribution module is
used to get distro details - and this module is unable to
distinguish between Debian and Devuan. In Chimaera, python3 is 3.9,
and in this, platform.linux_distribution has been removed, so that
distro details are obtained using distro.linux_distribution - which
is able to distinguish between Debian and Devuan)

Details:

- added azurelinuxagent/common/osutil/devuan.py
- modified azurelinuxagent/common/osutil/factory.py to use devuan.py
- added init and config files for devuan
- modified setup.py for devuan support
- modified tests/common/osutil/test_factory.py to test devuan support
Copy link
Member

@narrieta narrieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updated PR, and sorry the long, long delay getting to this.

LGTM, but have a few questions/comments that I posted in my review.

Thanks again.

# Add firewall rules to protect access to Azure host node services
# Note:
# - The default is false to protect the state of existing VMs
OS.EnableFirewall=n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not recommend disabling this, what is the motivation for defaulting to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Norberto, thanks for looking into the changes for this pull request.

I based the default waagent.conf for devuan on the one for debian, and this appears to be the only one in which OS.EnableFirewall is disabled. I'm happy to enable it in the waagent.conf for devuan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just uploaded three changes to the devuan_support_new branch. The changes include setting waagent.conf to default to OS.EnableFirewall to y

azurelinuxagent/common/osutil/devuan.py Show resolved Hide resolved
# non-daemon instances of waagent may be running concurrently (e.g. when
# "waagent -deprovision" is being run) and attempts to ensure that any
# non-daemon instances are preserved when the daemon instance is stopped.
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the motivation for the checks on the pid file? i'm a little concerned about those because we are planning on re-structuring the agent and may not need a pid file, and not having that file may affect this script.

in particular "waagent -deprovision" should not be executed while the agent service is running, since a running agent may re-create part of the state that deprovision is trying to delete,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new init script was based on observations whilst trying waagent on a local test VM - I noticed that using the existing init script, an attempt to stop waagent also killed an instance which was running in a terminal. I can't remember what the terminal instance was running - it wasn't a deprovision. The script was an attempt to cope with any foreseeable possibility - maybe it addresses possibilities which couldn't actually exist in practice.

I wondered about rewriting the script so that it doesn't rely on PID files, and works out which are the daemon and non-daemon instances just from the output of the ps command. That should insulate it against any possibility that the use of pidfiles could be dropped in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just uploaded a new version of the devuan init script - I've rewritten it completely to remove all references to, and operations on, a pid file: it now operates only on the basis of output from the ps command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the update

Copy link
Member

@narrieta narrieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of minor comments (about commented-out code), but LGTM

i'll do an automation run tomorrow morning

thanks for your contribution. and sorry again for all the delays

local NDPIDLIST i NDPIDCT
declare -a NDPIDLIST
debugmsg "check_non_daemon_instance: after init, #NDPIDLIST=${#NDPIDLIST[*]}"
# NDPIDLIST=$( ps ax |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left-over code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now removed the commented-out lines (I'd only retained them for reference during local testing).

# just start waagent
debugmsg "start_waagent: waagent is not currently running"
log_daemon_msg "Starting ${NAME} daemon"
# start-stop-daemon --start --quiet --pidfile ${PIDFILE} --background --name "${NAME}" --exec ${INTERPRETER} -- ${DAEMON} ${DAEMON_ARGS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now removed the commented-out code lines - only retained for reference during local testing.

debugmsg "start_waagent: trying to stop waagent first, and then start it"
stop_waagent
log_daemon_msg "Starting ${NAME} daemon"
# start-stop-daemon --start --quiet --pidfile ${PIDFILE} --background --name ${NAME} --exec ${INTERPRETER} -- ${DAEMON} ${DAEMON_ARGS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now removed the commented-out codelines - I'd retained them for reference during local testing

# non-daemon instances of waagent may be running concurrently (e.g. when
# "waagent -deprovision" is being run) and attempts to ensure that any
# non-daemon instances are preserved when the daemon instance is stopped.
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the update

@codecov
Copy link

codecov bot commented May 16, 2022

Codecov Report

Merging #2553 (e2d16e0) into develop (b8ca432) will decrease coverage by 0.01%.
The diff coverage is 62.96%.

@@             Coverage Diff             @@
##           develop    #2553      +/-   ##
===========================================
- Coverage    71.90%   71.88%   -0.02%     
===========================================
  Files          102      103       +1     
  Lines        15476    15503      +27     
  Branches      2464     2466       +2     
===========================================
+ Hits         11128    11145      +17     
- Misses        3848     3858      +10     
  Partials       500      500              
Impacted Files Coverage Δ
azurelinuxagent/common/osutil/devuan.py 58.33% <58.33%> (ø)
azurelinuxagent/common/osutil/factory.py 93.10% <100.00%> (+0.24%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8ca432...e2d16e0. Read the comment docs.

kevinclark19a
kevinclark19a previously approved these changes May 17, 2022
Copy link
Contributor

@kevinclark19a kevinclark19a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, waiting for end-to-end testing to merge.

@narrieta
Copy link
Member

@peter9370 Automation looks OK. Would you check my comments wrt commented-out code and update as needed? I can merge after that. Thanks!

@peter9370
Copy link
Contributor Author

@narrieta Thanks for that - yes, sorry, I had left in some commented-out code lines in the walinuxagent init script: it was mainly for reference in local testing. I've removed the commented-out lines now, and also tidied up a few comments.

No worries about the delay in reviewing the pull request - I know things have been hard in the past two years.

@narrieta
Copy link
Member

@peter9370 thank for this PR!

@narrieta narrieta merged commit cd3b6d2 into Azure:develop May 18, 2022
@peter9370
Copy link
Contributor Author

@narrieta You're welcome - thanks for reviewing and merging my changes.

peter9370 referenced this pull request in MicrosoftDocs/azure-docs Jul 14, 2022
@peter9370
Copy link
Contributor Author

@narrieta Hi Norberto - do you have any idea when the changes to include devuan support will be included in a release?

@narrieta
Copy link
Member

narrieta commented Sep 2, 2022

@peter9370 We should start our next release within 2-3 weeks and this commit will be included there.

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