Skip to content

Commit

Permalink
Update the NFS resource for Ubuntu 22 (#2185)
Browse files Browse the repository at this point in the history
Split the ubuntu NFS resource into three, one for each version of Ubuntu we
support, 18, 20, and 22.  Since the difference is with 20 and 18 will soon be removed.
Ubuntu 22 uses a new config file for NFS see https://ubuntu.com/server/docs/service-nfs
for details.  Upgrading the nfs third party resource to 5.0.1+ resulted in failures similar
to the known issue sous-chefs/nfs#93.  Setting the server
template in the :setup action will preserve the default nfs.conf file and allow
for us to override any values we need without removing the history of the config
for users.  Also created more useful names for the two different types of
config files used for NFS.

Co-authored-by: Himani Anil Deshpande <[email protected]>
  • Loading branch information
dreambeyondorange and himani2411 authored May 25, 2023
1 parent 3291b9f commit 9284cbe
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
action_class do
def override_server_template
edit_resource(:template, node['nfs']['config']['server_template']) do
source 'nfs/nfs.conf.erb'
source 'nfs/default-nfs-kernel-server.conf.erb'
cookbook 'aws-parallelcluster-environment'
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
action_class do
def override_server_template
edit_resource(:template, node['nfs']['config']['server_template']) do
source 'nfs/nfs.conf.erb'
source 'nfs/default-nfs-kernel-server.conf.erb'
cookbook 'aws-parallelcluster-environment'
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.

provides :nfs, platform: 'ubuntu'
provides :nfs, platform: 'ubuntu', platform_version: '18.04'

unified_mode true

Expand All @@ -32,7 +32,7 @@
action_class do
def override_server_template
edit_resource(:template, node['nfs']['config']['server_template']) do
source 'nfs/nfs.conf.erb'
source 'nfs/default-nfs-kernel-server.conf.erb'
cookbook 'aws-parallelcluster-environment'
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

#
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "LICENSE.txt" file accompanying this file.
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.

provides :nfs, platform: 'ubuntu', platform_version: '20.04'

unified_mode true

use 'partial/_install_nfs_debian'
use 'partial/_install_nfs4_and_disable'
use 'partial/_configure'

default_action :setup

action :setup do
action_install_nfs
action_install_nfs4
action_disable_start_at_boot
end

action_class do
def override_server_template
edit_resource(:template, node['nfs']['config']['server_template']) do
source 'nfs/default-nfs-kernel-server.conf.erb'
cookbook 'aws-parallelcluster-environment'
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

#
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "LICENSE.txt" file accompanying this file.
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.

provides :nfs, platform: 'ubuntu' do |node|
node['platform_version'].to_i >= 22
end

unified_mode true

use 'partial/_install_nfs_debian'
use 'partial/_install_nfs4_and_disable'
use 'partial/_configure'

default_action :setup

action :setup do
action_install_nfs
action_install_nfs4
action_disable_start_at_boot
node.default['nfs']['config']['server_template'] = '/etc/nfs.conf.d/parallelcluster-nfs.conf'
end

action_class do
def override_server_template
edit_resource(:template, node['nfs']['config']['server_template']) do
source 'nfs/nfs-ubuntu22+.conf.erb'
cookbook 'aws-parallelcluster-environment'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,26 @@ def self.configure(chef_run)
is_expected.to configure_nfs('configure')
end

if %w(amazon centos ubuntu).include?(platform)
if %w(amazon centos).include?(platform)
it 'overrides nfs config with custom template' do
is_expected.to create_template(server_template)
.with(source: 'nfs/nfs.conf.erb')
.with(source: 'nfs/default-nfs-kernel-server.conf.erb')
.with(cookbook: 'aws-parallelcluster-environment')
end

elsif %w(ubuntu).include?(platform)
it 'overrides nfs config with custom template' do
if version.to_i >= 22
is_expected.to create_template(server_template)
.with(source: 'nfs/nfs-ubuntu22+.conf.erb')
.with(cookbook: 'aws-parallelcluster-environment')
else
is_expected.to create_template(server_template)
.with(source: 'nfs/default-nfs-kernel-server.conf.erb')
.with(cookbook: 'aws-parallelcluster-environment')
end
end

elsif platform == 'redhat'
it 'uses nfs config template shipped with nfs cookbook' do
is_expected.to create_template(server_template)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Chef for <%= node['fqdn'] %>
# Local modifications will be overwritten.

[lockd]
port = <%= node['nfs']['port']['lockd'] %>
udp-port = <%= node['nfs']['port']['lockd'] %>

[mountd]
port = <%= node['nfs']['port']['mountd'] %>

[statd]
port = <%= node['nfs']['port']['statd'] %>
outgoing-port = <%= node['nfs']['port']['statd_out'] %>

[nfsd]
threads = <%= node['nfs']['threads'] %>
<% unless node['nfs']['v2'].nil? -%>
vers2 = <%= node['nfs']['v2'] %>
<% end -%>
<% unless node['nfs']['v3'].nil? -%>
vers3 = <%= node['nfs']['v3'] %>
<% end -%>
<% unless node['nfs']['v4'].nil? -%>
vers4 = <%= node['nfs']['v4'] %>
<% end -%>

0 comments on commit 9284cbe

Please sign in to comment.