worker_counts=0 disables Landscape services instead of maximizes resource usage like the charm config says

Bug #2092054 reported by Ryan Stewart
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Landscape Charm
New
Undecided
Unassigned

Bug Description

When you set worker_counts=0, it disables key Landscape services by setting them to 0 in /etc/default/landscape, instead of maximizes resource usage like the charm config says.

As per the description: "If set to 0, the charm will automatically pick a value, trying to maximize the use of the computer/memory resources available on the unit."

Either the charm needs to reflect the documentation, or the documentation needs to reflect what actually happens.

Revision history for this message
Kyle Metscher (kmetscher) wrote :

There doesn't appear to be any check for a zero value when the charm starts up and ingests its config:

# charm.py
def _start_services(self) -> bool:
        """
        Starts all Landscape Server systemd services. Returns True if
        successful, False otherwise.
        """
        self.unit.status = MaintenanceStatus("Starting services")
        is_leader = self.unit.is_leader()
        deployment_mode = self.model.config.get("deployment_mode")
        is_standalone = deployment_mode == "standalone"

        update_default_settings(
            {
                "RUN_ALL": "no",
                "RUN_APISERVER": str(self.model.config["worker_counts"]),
                "RUN_ASYNC_FRONTEND": "yes",
                "RUN_JOBHANDLER": "yes",
                "RUN_APPSERVER": str(self.model.config["worker_counts"]),
                "RUN_MSGSERVER": str(self.model.config["worker_counts"]),
                "RUN_PINGSERVER": str(self.model.config["worker_counts"]),
                "RUN_CRON": "yes" if is_leader else "no",
                "RUN_PACKAGESEARCH": "yes" if is_leader else "no",
                "RUN_PACKAGEUPLOADSERVER": (
                    "yes" if is_leader and is_standalone else "no"
                ),
                "RUN_PPPA_PROXY": "no",
            }
        )

Nor in the method that writes out the defaults file, which just writes k=v for each line:

# settings_files.py
def update_default_settings(updates: dict) -> None:
    """
    Updates the Landscape Server default settings file.

    This file is mainly used to determine which services should be
    running for this installation.
    """
    with open(DEFAULT_SETTINGS, "r") as settings_fp:
        new_lines = []

        for line in settings_fp:
            if "=" in line and line.split("=")[0] in updates:
                key = line.split("=")[0]
                new_line = f'{key}="{updates[key]}"\n'
            else:
                new_line = line

            new_lines.append(new_line)

    with open(DEFAULT_SETTINGS, "w") as settings_file:
        settings_file.write("".join(new_lines))

Documentation should be updated as this functionality doesn't appear to be implemented anywhere. As an interim fix, zero could just be turned into 1 or yes, but actual autoscaling/resource maximization would require a new charm feature.

Revision history for this message
Ryan Stewart (stew3254) wrote :

We ended up changing the value to 1 for now. Thanks for looking into this!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.