public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Christian Ebner <c.ebner@proxmox.com>
Subject: Re: [pbs-devel] [PATCH v2 backup stable-2] pbs2to3: add upgrade checker binary
Date: Wed, 28 Jun 2023 12:48:36 +0200	[thread overview]
Message-ID: <58573646-cfe6-5294-fde9-a4154b118a10@proxmox.com> (raw)
In-Reply-To: <20230628094225.53204-1-c.ebner@proxmox.com>

Am 28.06.23 um 11:42 schrieb Christian Ebner:
> +
> +    fn check_repo_file(
> +        &mut self,
> +        repo_file: APTRepositoryFile,
> +    ) -> Result<(bool, Vec<(String, String)>), Error> {
> +        let mut strange_suite = false;
> +        let mut found_suite: Option<(String, String)> = None;
> +        let mut mismatches = Vec::new();

As already talked off-list, currently only detects mismatches within a file.

> +    fn get_systemd_unit_state(
> +        &mut self,
> +        unit: &str,
> +    ) -> Result<(SystemdUnitState, SystemdUnitState), Error> {
> +        let mut command = std::process::Command::new("systemctl");
> +        command.arg("is-enabled");
> +        command.arg(unit);
> +        let output = command
> +            .output()
> +            .map_err(|err| format_err!("failed to execute {:?} - {}", command, err))?;
> +
> +        let is_enabled_state = match output.stdout.as_slice() {

Nit: I'd prefer enabled_state because it's not a boolean

> +            b"enabled\n" => SystemdUnitState::Enabled,
> +            b"disabled\n" => SystemdUnitState::Disabled,
> +            _ => SystemdUnitState::Unknown,
> +        };
> +
> +        let mut command = std::process::Command::new("systemctl");
> +        command.arg("is-active");
> +        command.arg(unit);
> +        let output = command
> +            .output()
> +            .map_err(|err| format_err!("failed to execute {:?} - {}", command, err))?;
> +
> +        let is_active_state = match output.stdout.as_slice() {

Same

> +            b"active\n" => SystemdUnitState::Active,
> +            b"inactive\n" => SystemdUnitState::Inactive,
> +            b"failed\n" => SystemdUnitState::Failed,
> +            _ => SystemdUnitState::Unknown,
> +        };
> +        Ok((is_enabled_state, is_active_state))
> +    }
> +
> +    fn check_pbs_services(&mut self) -> Result<(), Error> {
> +        self.output.log_info("Checking pbs daemon services..")?;

s/pbs/PBS/

> +
> +        for service in ["proxmox-backup.service", "proxmox-backup-proxy.service"] {
> +            match self.get_systemd_unit_state(service)? {
> +                (_, SystemdUnitState::Active) => {
> +                    self.output.log_pass(
> +                        format!("systemd unit '{}' is in state 'active'", service).as_str(),
> +                    )?;
> +                }
> +                (_, SystemdUnitState::Inactive) => {
> +                    self.output.log_fail(
> +                        format!(
> +                            "systemd unit '{}' is in state 'inactive'\
> +                            \n    Please check the service for errors and start it.",
> +                            service,
> +                        )
> +                        .as_str(),
> +                    )?;
> +                }
> +                (_, SystemdUnitState::Failed) => {
> +                    self.output.log_fail(
> +                        format!(
> +                            "systemd unit '{}' is in state 'failed'\
> +                            \n    Please check the service for errors and start it.",
> +                            service,
> +                        )
> +                        .as_str(),
> +                    )?;
> +                }
> +                (_, _) => {
> +                    self.output.log_fail(
> +                        format!(
> +                            "systemd unit '{}' is not in state 'active'\
> +                            \n    Please check the service for errors and start it.",
> +                            service,
> +                        )
> +                        .as_str(),
> +                    )?;
> +                }
> +            }

The enabled state is ignored? You just look at the active state.

> +        }
> +        Ok(())
> +    }
> +
Other than that, didn't see anything obviously wrong :)




      reply	other threads:[~2023-06-28 10:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  9:42 Christian Ebner
2023-06-28 10:48 ` Fiona Ebner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58573646-cfe6-5294-fde9-a4154b118a10@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal