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

ncm-nfs: Allow daemon to reload to be specified #1621

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ncm-nfs/src/main/pan/components/nfs/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type ${project.artifactId}_component = {
If true, missing exports forces an empty exports file and a NFS service reload.
If false, missing exports has no effect.}
'server' : boolean = true
@{ Daemon to reload when changes are made }
'daemon' : string_trimmed = 'nfs-server'
@{This is a list of dicts with "path" giving the export path and
"hosts" being a dict of host/option entries where the key is the escaped host name and
the value the export options(e.g. for "nfsclient.example.org(rw)",
Expand Down
4 changes: 2 additions & 2 deletions ncm-nfs/src/main/perl/nfs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ sub Configure
if (! exists($tree->{server}) || $tree->{server}) {
if ($self->exports($tree)) {
# Force a reload of the nfs daemon.
$self->info("Forcing nfs reload");
$self->info("Forcing ", $tree->{daemon}, " reload");
# report error on failure
CAF::Service->new(["nfs"], log => $self)->reload();
CAF::Service->new([$tree->{daemon}], log => $self)->reload();
};
} else {
$self->verbose("Not a NFS server configuration");
Expand Down
16 changes: 12 additions & 4 deletions ncm-nfs/src/test/perl/configure.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings;

use Test::More;
use Test::Quattor qw(configure configure_noserver configure_nomounts);
use Test::Quattor qw(configure configure_noserver configure_nomounts configure_daemon);
use Test::MockModule;

use Test::Quattor::RegexpTest;
Expand Down Expand Up @@ -42,14 +42,14 @@ foreach my $change (qw(exports)){
command_history_reset();
$res = {$change => 1};
is($cmp->Configure($cfg), 1, "Configure returns 1 (change $change)");
ok(command_history_ok([qr{service nfs reload}]), "nfs service reload when $change changed");
ok(command_history_ok([qr{service nfs-server reload}]), "nfs service reload when $change changed");
};

foreach my $change (qw(fstab_changed action)){
command_history_reset();
$res = {$change => 1};
is($cmp->Configure($cfg), 1, "Configure returns 1 (change $change)");
ok(command_history_ok(undef, [qr{service nfs reload}]), "no nfs service reload when $change changed");
ok(command_history_ok(undef, [qr{service nfs-server reload}]), "no nfs service reload when $change changed");
};

# noserver config
Expand All @@ -58,7 +58,7 @@ foreach my $change (qw(exports fstab_changed action)){
command_history_reset();
$res = {$change => 1};
is($cmp->Configure($nosrvcfg), 1, "Configure returns 1 (change $change) with server=false");
ok(command_history_ok(undef, [qr{service nfs reload}]), "no nfs service reload when $change changed with server=false");
ok(command_history_ok(undef, [qr{service nfs-server reload}]), "no nfs service reload when $change changed with server=false");
};

# noserver config
Expand All @@ -68,5 +68,13 @@ $process_mounts_arg = undef;
is($cmp->Configure($nomounts), 1, "Configure returns 1 without mounts");
ok(!defined($process_mounts_arg), "no nfs process_mounts without mounts");

# configure with alternative daemon set
my $cfgdaemon = get_config_for_profile('configure_daemon');
foreach my $change (qw(exports)){
command_history_reset();
$res = {$change => 1};
is($cmp->Configure($cfgdaemon), 1, "Configure returns 1 (change $change)");
ok(command_history_ok([qr{service nfs-kernel-server reload}]), "nfs-server service reload when $change changed");
};

done_testing();
5 changes: 5 additions & 0 deletions ncm-nfs/src/test/resources/configure_daemon.pan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object template configure_daemon;

include 'fstab_simple';

"/software/components/nfs/daemon" = 'nfs-kernel-server';