From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Oguz Bektas <o.bektas@proxmox.com>
Subject: Re: [pve-devel] [PATCH container] pct fstrim: add 'ignore_mp' parameter
Date: Wed, 28 Oct 2020 17:16:39 +0100 [thread overview]
Message-ID: <1f81eb46-d7fc-c22e-fc82-318d2f0e69b9@proxmox.com> (raw)
In-Reply-To: <20201028111135.226496-1-o.bektas@proxmox.com>
On 28.10.20 12:11, Oguz Bektas wrote:
> parameter to ignore mountpoints when doing fstrim on a container
>
> root@pve:~# pct fstrim 123 --ignore_mp
> /var/lib/lxc/123/rootfs/: 0 B (0 bytes) trimmed
> root@pve:~# pct fstrim 123
> /var/lib/lxc/123/rootfs/: 0 B (0 bytes) trimmed
> /var/lib/lxc/123/rootfs/test: 321.1 MiB (336654336 bytes) trimmed
>
> Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
> ---
> src/PVE/CLI/pct.pm | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
> index df4e9f8..056ae78 100755
> --- a/src/PVE/CLI/pct.pm
> +++ b/src/PVE/CLI/pct.pm
> @@ -767,6 +767,10 @@ __PACKAGE__->register_method ({
> additionalProperties => 0,
> properties => {
> vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
> + ignore_mp => {
1. new parameters are prefer as kebab-case, at least if that command provides
no other casing/separation variants in its options.
2. no description -> NAK
> + optional => 1,
> + type => 'boolean',
> + },
> },
> },
> returns => { type => 'null' },
> @@ -785,11 +789,16 @@ __PACKAGE__->register_method ({
> PVE::LXC::Config->foreach_volume($conf, sub {
> my ($name, $mp) = @_;
> $path = $mp->{mp};
> + if ($param->{ignore_mp}) {
> + return if $name =~ '^mp[0-9]*';
why is the regex in a string, not a // and why * ?
Could be also just:
return if $param->{'ignore-mountpoints'} && $name =~ /^mp\d+/;
but no hard feelings here.
> + }
> my $cmd = ["fstrim", "-v", "$rootdir$path"];
> PVE::Tools::run_command($cmd);
> });
> };
> - warn $@ if $@;
> + if (my $err = $@) {
> + warn $err;
> + }
not neded for this patch, and not really a improvement, the `warn $@ if $@;` is
quite widely used, and not considered as "bad", IIRC.
>
> PVE::LXC::umount_all($vmid, $storecfg, $conf, 0);
> PVE::LXC::Config->remove_lock($vmid, 'fstrim');
>
prev parent reply other threads:[~2020-10-28 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 11:11 Oguz Bektas
2020-10-28 16:16 ` Thomas Lamprecht [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=1f81eb46-d7fc-c22e-fc82-318d2f0e69b9@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=o.bektas@proxmox.com \
--cc=pve-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