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

Slurm plugin #5

Merged
merged 54 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
acc1611
add run sub-command
bcumming Jul 24, 2024
ef466a9
slurm plugin basic functionality ported
bcumming Jul 25, 2024
0db8af9
merged main
bcumming Jul 25, 2024
44391c9
Merge branch 'main' into slurm
bcumming Jul 25, 2024
fd64048
plugin quits with an error when view is pass without uenv; improve er…
bcumming Jul 25, 2024
a1e91dd
wip on sqlite database support
bcumming Jul 26, 2024
a3faecf
support non-default-constructible types in util::expected
bcumming Jul 26, 2024
e81b71c
use C++20
bcumming Jul 26, 2024
554f613
revert to using util::expected
bcumming Jul 26, 2024
078ec4d
POC of parsing sqlite database works
bcumming Jul 29, 2024
2d52c7d
support !uarch and @system in uenv labels, replace @mount with :mount
bcumming Jul 30, 2024
249cd4f
datastore search supports any combination or name, tag, version, ueac…
bcumming Jul 30, 2024
8e1cedc
generate a mock repo for testing with an app and a tool image
bcumming Jul 30, 2024
e5d8eb6
test repo creation now populates the db
bcumming Jul 31, 2024
e4fba26
rename datastore->repo; support looking up a default repo location
bcumming Aug 9, 2024
2ccc067
add repo parsing to the uenv cli tool
bcumming Aug 12, 2024
2762e91
use % instead of ! for uarch in uenv descriptions
bcumming Aug 13, 2024
78a5b6b
test repo generator puts images in the correct path
bcumming Aug 14, 2024
ccc8035
add --repo flag to the slurm plugin
bcumming Aug 14, 2024
c986371
merge master, force spdlog to use external fmt library instead of std…
bcumming Aug 14, 2024
cf57d3e
make the cli and slurm targets optional in meson
bcumming Aug 15, 2024
003304a
use mount point in meta data as the default mount point, and improve …
bcumming Aug 15, 2024
230c76d
add integration test path with bats installer
bcumming Aug 15, 2024
1f129e2
add bats tests - have to finish porting all tests.
bcumming Aug 15, 2024
401ea7e
clean up slurm plugin log-level setting
bcumming Aug 16, 2024
b60746c
improve quality and consistency of parse error reporting
bcumming Aug 17, 2024
816eff4
set different patterns for console and syslog loggers; console is les…
bcumming Aug 17, 2024
1aa4222
use spdlog everywhere; invalid repo is a warning
bcumming Aug 17, 2024
73d32b3
add two app uenv to the test reop; support ambiguous search tersm
bcumming Aug 19, 2024
badfcec
use a richer type for sha hashes than std::string
bcumming Aug 19, 2024
8aeb30e
support id and sha256 searches
bcumming Aug 19, 2024
3957f71
add image ls command
bcumming Aug 19, 2024
b62b566
add --no-header option to uenv image ls
bcumming Aug 21, 2024
81111d9
correctly parse output for slurm view integration tests
bcumming Aug 21, 2024
46a301c
fix parsing of uenv description with a mount point but no tag (disamb…
bcumming Aug 21, 2024
680359c
support CLUSTER_NAME variable; * flag for system; more integration tests
bcumming Aug 22, 2024
9fcaac7
add rpm build script - not quite working properly yet
bcumming Aug 22, 2024
5c003f2
wip on rpm
bcumming Aug 23, 2024
1233c24
towards building RPMs - add LICENSE file
bcumming Aug 23, 2024
4ac7076
rpmbuild works
bcumming Aug 23, 2024
3e534e4
do not install the license file
bcumming Aug 23, 2024
55ab5f3
improve naming of slurm integration tests
bcumming Aug 26, 2024
f6e442e
update ci workflow to install mount/libmount
bcumming Aug 26, 2024
fb8d956
wip
bcumming Aug 26, 2024
bcdf2a7
fix run_sbatch function
simonpintarelli Aug 26, 2024
524fe6e
no warnings for sub-projects; fix warnings in unit tests
bcumming Aug 26, 2024
bf3acb6
Merge commit 'bcdf2a7' into slurm
bcumming Aug 26, 2024
701fc21
add slurm to ci ubuntu
bcumming Aug 26, 2024
b883e61
slurm plugin validates UENV_MOUNT_LIST in the local context
bcumming Aug 28, 2024
42605ec
ci: install slurm packages
simonpintarelli Aug 28, 2024
4f1aa38
clang format sqlite
simonpintarelli Aug 28, 2024
37bbbb5
rpmbuild: use abs path for dstdir
simonpintarelli Aug 28, 2024
8fe100a
remove rpmbuild --load
simonpintarelli Aug 30, 2024
180ef2d
typo in comment
simonpintarelli Sep 1, 2024
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: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterControlStatement: MultiLine
AfterEnum: false
AfterFunction: false
AfterNamespace: false
Expand Down
2 changes: 1 addition & 1 deletion .clangd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CompileFlags:
Add: [-std=c++17, -Iinclude]
Add: [-std=c++20]
2 changes: 2 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
- uses: actions/checkout@v4
- name: Update apt repositories for ccache
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install util-linux libmount-dev slurm-wlm libslurm-dev slurmd slurmctld slurm-client
- name: Set up ccache
uses: hendrikmuhs/[email protected]
with:
Expand Down
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023-2024, ETH Zürich
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 changes: 36 additions & 22 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
project('uenv', ['cpp'],
default_options : [
'cpp_std=c++17',
'cpp_std=c++20',
'default_library=static',
],
version: files('VERSION'),
meson_version: '>=0.57')
version = meson.project_version()

#default_mount_point = get_option('default_mount_point')
uenv_slurm_plugin = get_option('slurm_plugin')
uenv_cli = get_option('cli')

conf_data = configuration_data()

# configure the dependencies
#

# use meson wrap to provide the dependencies, because the 'default_library=static' option
# will be propogated to each dependency, for a statically linked executable.
catch_dep = subproject('catch2', default_options: 'werror=false').get_variable('catch2_with_main_dep')
cli11_dep = subproject('cli11', default_options: 'werror=false').get_variable('CLI11_dep')
fmt_dep = subproject('fmt', default_options: 'werror=false').get_variable('fmt_dep')
json_dep = subproject('nlohmann_json', default_options: 'werror=false').get_variable('nlohmann_json_dep')
spdlog_dep = subproject('spdlog', default_options: 'werror=false').get_variable('spdlog_dep')
sqlite3_dep = subproject('sqlite3', default_options: 'werror=false').get_variable('sqlite3_dep')
catch_dep = subproject('catch2', default_options: ['werror=false', 'warning_level=0']).get_variable('catch2_with_main_dep')
cli11_dep = subproject('cli11', default_options: ['werror=false', 'warning_level=0']).get_variable('CLI11_dep')
fmt_dep = subproject('fmt', default_options: ['werror=false', 'warning_level=0']).get_variable('fmt_dep')
json_dep = subproject('nlohmann_json', default_options: ['werror=false', 'warning_level=0']).get_variable('nlohmann_json_dep')
spdlog_dep = subproject('spdlog', default_options: ['werror=false', 'warning_level=0','std_format=disabled','external_fmt=enabled']).get_variable('spdlog_dep')
sqlite3_dep = subproject('sqlite3', default_options: ['werror=false', 'warning_level=0']).get_variable('sqlite3_dep')

# the lib dependency is all of the common funtionality shared between the CLI
# and the slurm plugin.
lib_src = [
'src/uenv/cscs.cpp',
'src/uenv/env.cpp',
'src/uenv/envvars.cpp',
'src/uenv/lex.cpp',
'src/uenv/log.cpp',
'src/uenv/meta.cpp',
'src/uenv/parse.cpp',
'src/util/strings.cpp',
'src/uenv/repository.cpp',
'src/util/shell.cpp',
'src/util/strings.cpp',
'src/uenv/uenv.cpp',
]
lib_inc = include_directories('src')
Expand All @@ -44,25 +47,30 @@ lib_dep = declare_dependency(
)

# the uenv executable
uenv_src = [
'src/cli/env.cpp',
'src/cli/start.cpp',
'src/cli/uenv.cpp',
]
uenv_dep = [sqlite3_dep]
if uenv_cli
uenv_src = [
'src/cli/image.cpp',
'src/cli/ls.cpp',
'src/cli/run.cpp',
'src/cli/start.cpp',
'src/cli/uenv.cpp',
]
uenv_dep = [sqlite3_dep]

uenv = executable('uenv',
sources: uenv_src,
dependencies: [uenv_dep, lib_dep, fmt_dep, spdlog_dep, cli11_dep],
c_args: ['-DVERSION="@0@"'.format(version)],
install: true)
cli = executable('uenv',
sources: uenv_src,
dependencies: [uenv_dep, lib_dep, fmt_dep, spdlog_dep, cli11_dep],
c_args: ['-DVERSION="@0@"'.format(version)],
install: true)
endif

unit_src = [
'test/unit/env.cpp',
'test/unit/envvars.cpp',
'test/unit/parse.cpp',
'test/unit/lex.cpp',
'test/unit/main.cpp',
'test/unit/parse.cpp',
'test/unit/repository.cpp',
]

unit = executable('unit',
Expand All @@ -71,3 +79,9 @@ unit = executable('unit',
build_by_default: true,
install: false)

if uenv_slurm_plugin
subdir('src/slurm')
endif

# install the license
#install_data('LICENSE', install_mode : 'rw-r--r--', install_dir : 'license')
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('slurm_plugin', type: 'boolean', value: true)
option('cli', type: 'boolean', value: true)
34 changes: 34 additions & 0 deletions rpm/macros.meson
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%__sourcedir .
%__builddir %{_target_platform}
%__meson_wrap_mode nodownload

%meson_setup \
mkdir -p %{__builddir} \
CFLAGS="${CFLAGS:-%optflags}"; export CFLAGS; \
CXXFLAGS="${CXXFLAGS:-%optflags}"; export CXXFLAGS; \
FFLAGS="${FFLAGS:-%optflags}"; export FFLAGS; \
FCFLAGS="${FCFLAGS:-%optflags}"; export FCFLAGS; \
meson setup %{__sourcedir} %{__builddir} \\\
%{?_enable_debug:-Ddebug=true} \\\
--prefix=%{_prefix} \\\
--bindir=%{_bindir} \\\
--sbindir=%{_sbindir} \\\
--libexecdir=%{_libexecdir} \\\
--libdir=%{_libdir} \\\
--localstatedir=%{_var} \\\
--sharedstatedir=%{_sharedstatedir} \\\
--includedir=%{_includedir} \\\
--datadir=%{_datadir} \\\
--sysconfdir=%{_sysconfdir} \\\
--mandir=%{_mandir} \\\
--infodir=%{_infodir} \\\
--localedir=%{_datadir}/locale \\\
-Dcli=false \\\
-Dslurm_plugin=true \\\
%{nil}

%meson_build \
meson compile %_smp_mflags -C %{__builddir}

%meson_install \
DESTDIR=%buildroot meson install --no-rebuild --skip-subprojects -C %{__builddir}
117 changes: 117 additions & 0 deletions rpm/make-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

usage="$(basename "$0") [-h] [-s,--skip-binary] [--slurm-version] dstdir

Helper script to create a source and binary rpm of the project.

Options:
-h,--help show this help text
-s,--skip-bin skip creation of binary package
--slurm-version slurm version to specify in RPM dependency, defaults to 20.11.9
"

# Default argument
RPM_SLURM_VERSION=20.11.9

# Initialize our own variables
skip_bin=0

# A temporary variable to hold the output of `getopt`
TEMP=$(getopt -o s,h --long skip-bin,help,slurm-version: -- "$@")

# If getopt has reported an error, exit script with an error
if [ $? != 0 ]; then
# echo 'Error parsing options' >&2
echo "${usage}" >&2
exit 1
fi

eval set -- "$TEMP"

# Now go through all the options
while true; do
case "$1" in
-s | --skip-bin)
skip_bin=1
shift
;;
--slurm-version)
shift
RPM_SLURM_VERSION="$1"
shift
;;
-h | --help)
shift
echo "${usage}"
exit 1
;;
--)
shift
break
;;
*)
echo "Internal error! $1"
exit 1
;;
esac
done

# Remaining dstdir is in $1
dstdir=$(realpath $1)

# Check if the positional argument was provided
if [ -z "$dstdir" ]; then
echo "${usage}" >&2
exit 1
fi

# Print the parsed arguments
echo "skip_bin=$skip_bin"
echo "dstdir=$dstdir"
echo "RPM_SLURM_VERSION=$RPM_SLURM_VERSION"

set -euo pipefail

# absolute path to this script (where the spec file is located)
_scriptdir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")

# the project root directory
_projectdir=$(realpath "${_scriptdir}/../")

SLURM_UENV_MOUNT_VERSION=$(sed 's/-.*//' "${_scriptdir}/../VERSION")

rm -rf "${dstdir}"
mkdir -p "${dstdir}"

echo SLURM_UENV_MOUNT_VERSION=$SLURM_UENV_MOUNT_VERSION
echo _scriptdir=$_scriptdir
echo _projectdir=$_projectdir
tarball=slurm-uenv-mount-"${SLURM_UENV_MOUNT_VERSION}".tar.gz

(
cd "${dstdir}"

mkdir -p BUILD BUILDROOT RPMS SOURCES SPECS SRPMS

source_prefix="slurm-uenv-mount-${SLURM_UENV_MOUNT_VERSION}"

(
cd "${_projectdir}"
git archive --format=tar.gz --output="${dstdir}/SOURCES/${tarball}" HEAD
)

cp "${_scriptdir}/slurm-uenv-mount.spec" SPECS/
sed -i "s|UENVMNT_VERSION|${SLURM_UENV_MOUNT_VERSION}|g" SPECS/slurm-uenv-mount.spec
sed -i "s|RPM_SLURM_VERSION|${RPM_SLURM_VERSION}|g" SPECS/slurm-uenv-mount.spec

# create src rpm
rpmbuild -bs --define "_topdir ." SPECS/slurm-uenv-mount.spec

if [ "${skip_bin}" -eq "0" ]; then
# create binary rpm
rpmbuild --nodeps --define "_topdir $(pwd)" \
--define "set_build_flags CXXFLAGS=\"-O2 -Wall -Wpedantic\"" \
--define "_vpath_srcdir ${source_prefix}" \
--rebuild SRPMS/slurm-uenv-mount-*.src.rpm
fi
)
31 changes: 31 additions & 0 deletions rpm/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# For building RPMs.

RPM packaging requires that it performs the `meson setup ...`, `meson compile ...`
and `meson install ...` itself, in a controlled environment. The script provided
here drives that process, after making suitable sacrifices to the RPM packaging gods.

**WARNING**: the tools here build the RPM based on the state of the source code at `HEAD`
in the git repository. If you have uncommitted changes, they will not be reflected
in the generated RPM.

**NOTE**: building RPMs is fiddly business - it isn't you, it is `rpmbuild`. Contact
Ben or Simon for help instead of trying to find good docs on RPMs (they don't exist).

## make-rpm.sh

A script that will generate both source and binary RPMs for the project.

It requires a destination path where the RPM build will occur, and should be run in this path.

```
./rpm-build.sh $HOME/rpm/uenv
```

## macros.meson

The spec file `slurm-uenv-mount.spec` uses macros like `%meson_setup`, which parameterise
calls to meson. Macros for meson are not usually available, so we provide a definition of
the macros in `macros.meson`. They have been modified from the ones provided in the
following RPM:

https://packages.altlinux.org/en/sisyphus/binary/rpm-macros-meson/noarch/2908824343041241330
37 changes: 37 additions & 0 deletions rpm/slurm-uenv-mount.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Name: slurm-uenv-mount
Version: UENVMNT_VERSION
Release: RPM_SLURM_VERSION
Summary: SLURM spank plugin to mount squashfs images.
Prefix: /usr
Requires: slurm = RPM_SLURM_VERSION

License: BSD3
URL: https://github.com/eth-cscs/slurm-uenv-mount
Source0: %{name}-%{version}.tar.gz

BuildRequires: meson gcc slurm-devel

%define _build_id_links none

%description
A SLURM spank plugin to mount squashfs images.

%prep
%autosetup -c

%build
%meson_setup
%meson_build

%install
%meson_install

%post
REQ="required /usr/lib64/libslurm-uenv-mount.so"
CNF=/etc/plugstack.conf.d/99-slurm-uenv-mount.conf
mkdir -p /etc/plugstack.conf.d
echo "$REQ" > "$CNF"

%files
%license LICENSE
%{_libdir}/lib%{name}.so
Loading