Skip to content

Add a spec draft for the new distro namespace.#1

Merged
smoser merged 2 commits into
canonical:masterfrom
PCManticore:specs
Feb 13, 2015
Merged

Add a spec draft for the new distro namespace.#1
smoser merged 2 commits into
canonical:masterfrom
PCManticore:specs

Conversation

@PCManticore
Copy link
Copy Markdown

This initial draft targets a proposed API for the new distro submodule,
which in turn is composed by other cohesive subnamespaces, that targets
one specialized are. A basic API is laid out, which describes how namespaces
interacts with objects from other namespaces and so on.

I propose to have a spec folder in the repo, where we could track our design decissions and all that, a la Python's PEPs. A location such as this helps when we are in doubt why something was added as is.
Anyway, this draft mostly targets a shallow description of the API. A more thorough document will follow it, if the proposed changes are accepted. I'll also have a pull request with the base classes and all the goodies, so that we could start putting actual code in the distros in the meanwhile.

This initial draft targets a proposed API for the new distro submodule,
which in turn is composed by other cohesive subnamespaces, that targets
one specialized are. A basic API is laid out, which describes how namespaces
interacts with objects from other namespaces and so on.
Comment thread specs/distros.rst Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One concern I would have with structuring the modules this way (i.e. cloudinit.distros.<function>.<distro>) is that it makes it more difficult to install new distro packages cleanly. Let's say that Foo GNU/Linux want to use cloud-init by installing a separate package (which just puts their own files in place, rather than them forking cloud-init downstream and modifying it there).

They will have to maintain an odd looking tree (.../network/foo.py, .../users/foo.py, etc.), and install a separate file in to each of these directories on install.

If, instead, it were to be cloudinit.distros.., then they could just have .../foo/network.py, .../foo/users.py and install that entire directory in to .../cloudinit/distros.

Ideally (in my mind), the distros would sit in a Python namespace package, so that installing different distros would be relatively painless.

What do you think?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  •  cloudinit/distros/**init**.py
    
  •                    base.py
    
  •                    factory.py
    
  •                    network/
    

One concern I would have with structuring the modules this way (i.e. cloudinit.distros..) is that it makes it more difficult to install new distro packages cleanly. Let's say that Foo GNU/Linux want to use cloud-init by installing a separate package (which just puts their own files in place, rather than them forking cloud-init downstream and modifying it there).

They will have to maintain an odd looking tree (.../network/foo.py, .../users/foo.py, etc.), and install a separate file in to each of these directories on install.

If, instead, it were to be cloudinit.distros.., then they could just have .../foo/network.py, .../foo/users.py and install that entire directory in to .../cloudinit/distros.

Ideally (in my mind), the distros would sit in a Python namespace package, so that installing different distros would be relatively painless.

What do you think?

I'm apt to agree with Daniel here.
Claudiu, was there a reason for your layout ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm actually agreeing with Daniel, too. My first intention was to separate the concerns from inside the distro into more useful and cohesive subnamespaces, but the side effect is an increased maintenance for adding custom distros, which didn't crossed my mind initially. I'll update the spec then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd also think we should use namespaces (and likely https://pypi.python.org/pypi/stevedore ? ) for finding distros; although I'd also rather have distros actually contribute to cloud-init and not have everything they do be a plugin; seems slightly premature I think to do that at this early of a stage; but something we should keep in mind...

@PCManticore
Copy link
Copy Markdown
Author

Thanks guys for the review!

@smoser
Copy link
Copy Markdown
Collaborator

smoser commented Jan 29, 2015

Claudiu, can you address those comments above and update ? looks good other than that.

This patch drops the use of separate namespaces for different concerns,
such as networking, users and filesystem, instead, it proposes using
modules in a distro, as in `distro_name.network`, `distro_name.filesystem` etc.
which is better when trying to add new additional distros.

Also, it drops the concept of containers-as-creators, instead the objects
returned by methods as `routes` or `users` could be implemented
in the term of a sequence (for instance a namedtuple). The creation
of an object is moved in an object class itself, e.g. Route.create,
instead of RouteContainer.create.
smoser added a commit that referenced this pull request Feb 13, 2015
Add a spec draft for the new distro namespace.
@smoser smoser merged commit 53cbb45 into canonical:master Feb 13, 2015
paride pushed a commit to paride/cloud-init that referenced this pull request Jun 18, 2021
This reverts commit 3ef22ed.

Comments are not supported in debconf templates and cause errors like:

  Template parse error near `# Oracle DS absent to retain orig behavior:
      Oracle(Bionic) == OpenStack detected',
      in stanza canonical#1 of /var/lib/dpkg/info/cloud-init.templates
dermotbradley added a commit to dermotbradley/cloud-init that referenced this pull request Dec 29, 2022
Fixes the creation of single partitions on MBR devices. Currently this
fails with the following debug output:

cc_disk_setup.py[DEBUG]: Calculating partition layout
cc_disk_setup.py[DEBUG]:    Layout is: 0,
cc_disk_setup.py[DEBUG]: Creating partition table on /dev/sdb
subp.py[DEBUG]: Running command ['/sbin/sfdisk', '--Linux', '--unit=S',
'--force', '/dev/sdb'] with allowed return codes [0] (shell=False,
capture=True)
util.py[DEBUG]: Creating partition on /dev/sdb took 0.237 seconds
util.py[WARNING]: Failed partitioning operation
Failed to partition device /dev/sdb
Unexpected error while running command.
Command: ['/sbin/sfdisk/', '--Linux', '--unit=S', '--force', '/dev/sdb']
Exit code: 1
Reason: -
Stdout: Checking that no-one is using this disk right now ... OK

        Disk /dev/sdb: 16 MiB, 16777216 bytes, 32768 sectors
        Disk model: HARDDISK
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes

        >>> Created a new DOS disklabel with disk identifier 0xb3604c9a.
        /dev/sdb1: Leaving.
Stderr: sfdisk: --Linux option is unnecessary and deprecated
        Start sector 0 out of range.
        Failed to add canonical#1 partition: Result not representable
util.py[DEBUG]: Failed partitioning operation

On a BIOS/MBR partitioned device the 1st partition cannot start at sector
0 as this is reserved for the MBR.

Fixes LP: #1851438.

Documentation clarifications/corrections and additional examples added.

Also remove "--Linux" and "--unit=S" options from sfdisk calls, these
options have been deprecated since October 2014.
dermotbradley added a commit to dermotbradley/cloud-init that referenced this pull request Jan 5, 2023
Fixes the creation of single partitions on MBR devices. Currently this
fails with the following debug output:

cc_disk_setup.py[DEBUG]: Calculating partition layout
cc_disk_setup.py[DEBUG]:    Layout is: 0,
cc_disk_setup.py[DEBUG]: Creating partition table on /dev/sdb
subp.py[DEBUG]: Running command ['/sbin/sfdisk', '--Linux', '--unit=S',
'--force', '/dev/sdb'] with allowed return codes [0] (shell=False,
capture=True)
util.py[DEBUG]: Creating partition on /dev/sdb took 0.237 seconds
util.py[WARNING]: Failed partitioning operation
Failed to partition device /dev/sdb
Unexpected error while running command.
Command: ['/sbin/sfdisk/', '--Linux', '--unit=S', '--force', '/dev/sdb']
Exit code: 1
Reason: -
Stdout: Checking that no-one is using this disk right now ... OK

        Disk /dev/sdb: 16 MiB, 16777216 bytes, 32768 sectors
        Disk model: HARDDISK
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes

        >>> Created a new DOS disklabel with disk identifier 0xb3604c9a.
        /dev/sdb1: Leaving.
Stderr: sfdisk: --Linux option is unnecessary and deprecated
        Start sector 0 out of range.
        Failed to add canonical#1 partition: Result not representable
util.py[DEBUG]: Failed partitioning operation

On a BIOS/MBR partitioned device the 1st partition cannot start at sector
0 as this is reserved for the MBR.

Fixes LP: #1851438.

Documentation clarifications/corrections and additional examples added.

Also remove "--Linux" and "--unit=S" options from sfdisk calls, these
options have been deprecated since October 2014.
aciba90 pushed a commit that referenced this pull request Jan 5, 2023
Fixes the creation of single partitions on MBR devices. Currently this
fails with the following debug output:

cc_disk_setup.py[DEBUG]: Calculating partition layout
cc_disk_setup.py[DEBUG]:    Layout is: 0,
cc_disk_setup.py[DEBUG]: Creating partition table on /dev/sdb
subp.py[DEBUG]: Running command ['/sbin/sfdisk', '--Linux', '--unit=S',
'--force', '/dev/sdb'] with allowed return codes [0] (shell=False,
capture=True)
util.py[DEBUG]: Creating partition on /dev/sdb took 0.237 seconds
util.py[WARNING]: Failed partitioning operation
Failed to partition device /dev/sdb
Unexpected error while running command.
Command: ['/sbin/sfdisk/', '--Linux', '--unit=S', '--force', '/dev/sdb']
Exit code: 1
Reason: -
Stdout: Checking that no-one is using this disk right now ... OK

        Disk /dev/sdb: 16 MiB, 16777216 bytes, 32768 sectors
        Disk model: HARDDISK
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes

        >>> Created a new DOS disklabel with disk identifier 0xb3604c9a.
        /dev/sdb1: Leaving.
Stderr: sfdisk: --Linux option is unnecessary and deprecated
        Start sector 0 out of range.
        Failed to add #1 partition: Result not representable
util.py[DEBUG]: Failed partitioning operation

On a BIOS/MBR partitioned device the 1st partition cannot start at sector
0 as this is reserved for the MBR.

Documentation clarifications/corrections and additional examples added.

Also remove "--Linux" and "--unit=S" options from sfdisk calls, these
options have been deprecated since October 2014.

Note: This is not a change of behavior because the change provoking
the error was introduced in util-linux 2.26 in Xenial. Thus, every
supported cloud-init version fails.

LP: #1851438
This was referenced May 10, 2023
@s-makin s-makin mentioned this pull request Nov 17, 2023
2 tasks
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.

5 participants