Skip to content

Commit

Permalink
Merge pull request #1621 from jrha/nfs_daemon
Browse files Browse the repository at this point in the history
ncm-nfs: Allow daemon to reload to be specified
  • Loading branch information
wpoely86 authored Sep 29, 2023
2 parents afe5eb7 + 0fa66c3 commit f8dbf0f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
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';

0 comments on commit f8dbf0f

Please sign in to comment.