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

Support for AIX #4713

Closed
wants to merge 1 commit into from
Closed

Conversation

AkashKTripathi
Copy link

We are using this Issue to push the Code changes that are needed to provide IBM AIX OS support for the cloud-init.

In multiple location, where the command are specific to IBM AIX, We have inserted the if condition to check the underlying OS.
We are running AIX specific command only if the AIX is running on that system.

Copy link
Collaborator

@igalic igalic left a comment

Choose a reason for hiding this comment

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

this is a first sweep across the changes. some general comments:

I think this is a case where more than one commit would be very appreciated

subp shouldn't be used with qualified paths, unless there's good reason to do so

@@ -15,6 +15,7 @@
import os.path
import re
import stat
import platform
Copy link
Collaborator

Choose a reason for hiding this comment

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

rather than modify every single module to reject AIX, please extend util.py to extend system_info() and add an is_AIX() function

@@ -19,6 +20,7 @@
from cloudinit.settings import PER_INSTANCE

# This is a tool that cloud init provides
HELPER_TOOL_TPL_AIX = "/opt/freeware/lib/cloud-init/write-ssh-key-fingerprints"
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's no need to modify this, much less hard code it.
all you're doing is calling ./setup.py with different parameters

@@ -24,6 +25,7 @@
frequency = PER_INSTANCE

EXIT_FAIL = 254
AIX = 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

please don't use modifiable globals
once an @lru_cached util.is_AIX() this won't especially be needed

@@ -94,6 +96,9 @@ def givecmdline(pid):
line = output.splitlines()[1]
m = re.search(r"\d+ (\w|\.|-)+\s+(/\w.+)", line)
return m.group(2)
elif AIX:
(ps_out, _err) = subp.subp(["/usr/bin/ps", "-p", str(pid), "-oargs="], rcs=[0, 1])
Copy link
Collaborator

Choose a reason for hiding this comment

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

unless there is a ps in a standard path earlier than this, it shouldn't be necessary to give it the full path

@@ -154,18 +155,26 @@ def handle_ssh_pwauth(pw_auth, distro: Distro):
return

if distro.uses_systemd():
Copy link
Collaborator

Choose a reason for hiding this comment

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

does AIX use systemd?

@@ -306,17 +307,23 @@ class Paths(persistence.CloudInitPickleMixin):
def __init__(self, path_cfgs: dict, ds=None):
self.cfgs = path_cfgs
# Populate all the initial paths
self.cloud_dir: str = path_cfgs.get("cloud_dir", "/var/lib/cloud")
if platform.system().lower() == "aix":
self.cloud_dir: str = path_cfgs.get("cloud_dir", "/opt/freeware/var/lib/cloud")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this shouldn't be done here, see #4677

if platform.system().lower() == "aix":
CLOUD_CONFIG = "/opt/freeware/etc/cloud/cloud.cfg"
else:
CLOUD_CONFIG = "/etc/cloud/cloud.cfg"
Copy link
Collaborator

Choose a reason for hiding this comment

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

please see how we do this for FreeBSD

devlist = list(set(fslist) & set(label_list))
devlist.sort(reverse=True)
if platform.system().lower() == "aix":
devlist = aix_util.find_devs_with("cd0")
Copy link
Collaborator

@igalic igalic Dec 21, 2023

Choose a reason for hiding this comment

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

i know the structure in util.py isn't great, but, why aren't you extending that, rather tumač than touching every DataSource separately?

@@ -0,0 +1,102 @@
# The top level settings are used as module
Copy link
Collaborator

Choose a reason for hiding this comment

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

this file needs to go


# If there exist sysconfig/default variable override files use it...
[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init
[ -f /etc/default/cloud-init ] && . /etc/default/cloud-init
Copy link
Collaborator

Choose a reason for hiding this comment

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

other init systems also allow disabling with the existence of a file

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Hey @AkashKTripathi,

Thanks for this contribution to cloud-init. As described in the contribution guide, you will need to sign the CLA before this contribution can be accepted.

A few initial comments on the code:

This is a large contribution; props for putting this together! There is a fair amount of work still before this can be merged into upstream cloud-init. I'll outline below what needs to happen next (assuming CLA gets signed). If you have any questions, please don't hesitate to ask.

Validating this contribution

If you are able to provide instructions for running AIX locally in a VM or in a cloud, that would greatly improve the upstream developers' abilities to verify and review this and future contributions to the AIX portions of cloud-init code. Our support matrix of clouds and virtual machine platforms is pretty long. A pointer to some working instructions on how to run AIX on Qemu would be very beneficial. I haven't found anything authoritative or that didn't require building Qemu from source, but then again I didn't look very hard.

There are syntactical errors in this code. That makes me wonder if this version has ran on AIX. Please make sure that this code can at least boot and run on an instance of AIX. Once it can, please attach the logs (/var/log/cloud-init.log and /var/log/cloud-init-output.log). This will help us to review and verify the functionality of this code. We typically look for tracebacks and errors in the logs for indicators of issues.

Tests

Numerous existing tests are failing. I just ran the CI job so that you can look at what failed. These can run from the source tree using tox, which automatically installs test dependencies via pip. For the formatting issues, tox -e do_format will fix most of them (we use black).

Linters and static analyzers

These test simple things like syntax and type checking.

tox -e ruff
tox -e mypy
tox -e pylint
tox -e check_format

Unit Tests

tox -e py3

Integration Tests

These are very powerful and there are many ways to use them. The easiest way is probably to install lxd and then run tests locally using the following command. I typically use Ubuntu but I have tested this method on a few other distributions as well.

CLOUD_INIT_SOURCE="IN_PLACE" tox -e integration-tests-ci   

Once these integration tests all pass, your code will be ready for a more in depth review.

New Unit Tests

Kudos for adding your own unit tests. I haven't taken a close look yet, but that's a great sign for code quality.

A quick skim through the tests does reveal a few things to consider. I honestly don't know how they are supposed to work or how to run them. We use pytest for our tests, and invoke pytest using tox. These come with a bit of complexity, but they allow us to do lots of things powerfully and expressively: manage test dependencies automatically with pip, disable tests when they aren't supported by the platform that they run on, provide simple one line invocations to run various types of tests, etc, etc. I think we'll want at the very least to be using pytest for new tests so that they can be integrated into the rest of the test suite. This will allow us to disable these tests if, for example, they only work on AIX, but allow you to still run the distro-agnostic unittests when you run tox -e py3 on AIX. See this page in the docs for some pointers on pytest.

# instead of optical disk to fetch network config. This check make sure
# that customer always uses latest config data even if the instance-id
# is matching
init.purge_cache(True)
Copy link
Member

Choose a reason for hiding this comment

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

One more comment:

This is a pretty big change to cloud-init. What justification do you have for it? Also, which datasources have you tested this on? Wouldn't this break any user using nocloud with only a CIDATA drive?

Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Jan 19, 2024
@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label Jan 22, 2024
@holmanb
Copy link
Member

holmanb commented Jan 22, 2024

@AkashKTripathi Any update on this?

Copy link

github-actions bot commented Feb 6, 2024

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Feb 6, 2024
@github-actions github-actions bot closed this Feb 13, 2024
@holmanb holmanb reopened this Feb 13, 2024
@holmanb
Copy link
Member

holmanb commented Feb 13, 2024

@AkashKTripathi Is there any interest in making this happen still?

@AkashKTripathi
Copy link
Author

@AkashKTripathi Is there any interest in making this happen still?

Hi @holmanb
we are working on it. we will update you

@github-actions github-actions bot closed this Feb 22, 2024
@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label Feb 23, 2024
@holmanb holmanb reopened this Feb 23, 2024
Copy link

github-actions bot commented Mar 8, 2024

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Mar 8, 2024
@github-actions github-actions bot closed this Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale-pr Pull request is stale; will be auto-closed soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants