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

Documentation #5

Merged
merged 3 commits into from
Aug 22, 2017
Merged

Documentation #5

merged 3 commits into from
Aug 22, 2017

Conversation

gronke
Copy link
Member

@gronke gronke commented Aug 20, 2017

This pull-request summarizes the documentation of public and private API classes/methods.

@@ -18,6 +18,49 @@


class Jail:
"""
Iocage unit orchestrates a jail's configuration and manages state
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps say iocage Jail unit? Remember iocage is always lowercase, it's our name. That goes for all over.

"""
Iocage unit orchestrates a jail's configuration and manages state

Jails are represented as zfs dataset `zpool/iocage/jails/<NAME>`
Copy link
Contributor

Choose a reason for hiding this comment

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

as a zfs dataset

Directory Structure:

zpool/iocage/jails/<NAME>: The jail's dataset containing it's
configuration and root directory. Iocage legacy used to store
Copy link
Contributor

Choose a reason for hiding this comment

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

lowercase iocage, we can drop and root directory. It's not a directory, but a dataset. And isn't terribly important in this description. I think we should drop the JSON being preferred, and make the language stronger. It's the only supported mechanism. There are a lot of new things and properties, and this will help ease the migrations to it if we only support that mechanism.

a jails configuration as ZFS properties on this dataset. Even
though the modern JSON config mechanism is preferred.

zpool/iocage/jails/<NAME>/root: This directory is the dataset
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be said as This dataset is used as the jail's root when starting the jail. Perhaps instead of origin we say a clone's root or release's root dataset are normally the sources

the jail to be a JSON-style jail and ignores other configuration
mechanisms

zpool/iocage/jails/<NAME>/config: Another supported configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop the word supported, it isn't supported, but is able to be read. We need to offer a cutoff, we don't want to juggle supporting 3 different configuration methods.

NullFS Basejail: The fastest method to spawn a basejail by mounting
read-only directories from the release's root dataset by creating
a snapshot of the release on each boot of the jail. When a release
was updated, the jail is updated as well on the next reboot. This
Copy link
Contributor

Choose a reason for hiding this comment

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

When a release is updated not was. We should clarify that the jails userland will be updated, but not the configuration in /etc. The user would have to check that.

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.

i looked at your docs, but i'm mostly commenting on code 😂

@@ -63,25 +63,28 @@ def read(self):
libiocage.lib.JailConfigJSON.JailConfigJSON.read(self)
self["legacy"] = False
self.logger.log("Configuration loaded from JSON", level="verbose")
return
return "json"
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this one of those instances where we should be returning a tuple value rather than a plain string?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should introduce tuples in another PR. Good idea.

release_name (string):
The jail is created from the release matching the name provided

auto_download (bool): (default=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

auto_download seems to be unused.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, haha! This can be implemented on CLI side, so no need to expose an interface to automatically fetch the release here. Thanks!

if not self.running:
raise libiocage.lib.errors.JailNotRunning(
jail=self,
logger=self.logger
)

def update_jail_state(self):
"""
Invoke update of the jail state from jls output
"""
try:
stdout = subprocess.check_output([
"/usr/sbin/jls",
Copy link
Collaborator

Choose a reason for hiding this comment

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

consiser using --libxo=json here, for easier (no) parsing.

Copy link
Member Author

Choose a reason for hiding this comment

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

💛! But this will go into a separate PR.

def name(self):
"""
The name (formerly UUID) of the Jail
"""
return self.config["id"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does the setter work here?
(i.e.: how do we add validation for this?)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is write-only here. Just an abstraction of a jails given identifier. I'm sure we can improve validation in JailConfig.py

@@ -601,7 +797,14 @@ def __getattr__(self, key):

raise AttributeError(f"Jail property {key} not found")

def getattr_str(self, key):
def getstring(self, key):
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this a public function rather than a __str__ on the properties?
or would that be too convoluted?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would require to wrap all types returned to return a - in case the original value is None.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i wonder if that's an improvement in any regard, esp for downstream users who consume our output automatically.

Copy link
Member Author

Choose a reason for hiding this comment

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

No it's not. When you don't intent to print the outputs, you don't want to get the strings. Some objects, like for example the JailConfigAddresses, are a custom data structure you want to have access to.

@@ -72,7 +72,7 @@ def exec(command, logger=None, ignore_error=False):
if child.returncode > 0:

if logger:
log_level = "spam" if ignore_error else "warning"
log_level = "spam" if ignore_error else "warn"
Copy link
Collaborator

Choose a reason for hiding this comment

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

starting to think our logger levels should also be tuples.

@gronke gronke merged commit 4fea4bf into master Aug 22, 2017
@gronke gronke deleted the pydoc branch August 22, 2017 10:24
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.

None yet

3 participants