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

get Redhat tree copies working #151

Merged
merged 17 commits into from
Jul 29, 2024
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
382 changes: 382 additions & 0 deletions BUILD.rst

Large diffs are not rendered by default.

137 changes: 3 additions & 134 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,6 @@ NOTE:
The tests are disabled for now because the C consumer does lose messages.


Source Code Documentation
-------------------------

Partial implementation of Doxygen docs.
to view::

sudo apt install doxygen
sudo apt install graphviz
doxygen

and run, and it will create the browseable docs/html/ subdirectory
with some documentation. Although only a few files out of the total
have been properly annoted so far, doxygen is configured to extract
as much information from the code as possible. (We have some pretty
call/caller graphs now!)

Limitations of the C implementation
-----------------------------------

Expand All @@ -205,74 +189,6 @@ Limitations of the C implementation
- The C implementation uses the libc(7) regular expression routines, which
are a little more limited than python ones.

Build Dependencies
------------------

The librabbitmq version needs to be > 0.8, this is newer than what is in
ubuntu 16.04. So you need to git clone from https://github.com/alanxz/rabbitmq-c
then built it there. The launchpad PPA has a backport included to take care of
this::

export RABBIT_BUILD=*directory where rabbit has been built*


librabbitmq-dev - AMQP client library written in C - Dev Files
libssl-dev - OpenSSL client library (used for hash algorithms.)
libjson-c-dev - json-c header files.

run dependencies::

librabbitmq4 - AMQP client library written in C
libssl - OpenSSL client library.
libjson-c3 - JSON manupulation library (for v03 parsing)

On RPM-based distributions::

librabbitmq-devel
json-c-devel

This JSON library changed API multiple times in it's history. Sarrac development
platform is ubuntu 18.04, where the libjson-c3 library is provided. Older linux
versions may have incompatible library versions and may not build or run correctly.
The Makefile includes the -DHAVE_JSONC option in CFLAGS. Removing this option
disables v03 message parsing, but makes it possible to build on such systems.
v03 posting will still work (dependency only required to receive messages.)

BUILD OPTIONS
-------------

FORCE_LIBC_REGEX
~~~~~~~~~~~~~~~~

This option is set by default as it is usually desired.
If you see::

2018-11-21 00:08:17,315 [ERROR] invalid regular expression: .*\/tmp\/.*. Ignored

and the regex is valid... the symptom we had was that the library was
calling a version of the regular expresison routines included in a binary
(ksh93 in this case) instead of the ones in libc that were expected.
without this option being set, the shim library will compile and user
Korn Shell regular expression grammar instead of the libc/posix ones.
This is confusing in practice.

Set the option::

-DFORCE_LIBC_REGEX=\"/lib/x86_64-linux-gnu/libc.so.6\"

to the file containing the regcomp and regexec routines what are to be
used. The code uses dynamic library loading to force use of the specified
routines. Obviously this setting is architecture dependent and would
need adjustment if compiling on another platform, such as ARM or MIPS.

SR_DEBUG_LOGS
~~~~~~~~~~~~~

To disable all log file support, so that diagnostics messages
are sent to standard error instead, include::

-DSR_DEBUG_LOGS=1


Dorval Computing Centre
-----------------------
Expand All @@ -289,60 +205,13 @@ To load sr3_cpost::

or it may be installed in the system locations (/usr/bin, etc...)

Build Process
-------------

Branches
--------

The main repository of sarrac is: https://github.com/MetPX/sarrac
As of 2022/12, development is on v3 compatible version of sarrac, now called metpx-sr3c.
The customer switched to sr3, so there is no need to continue with v2.
The existing git branches and their roles:

* development ... the default development branch, launchpad.net daily packages built from here.
* pre-release ... v03 pre-release branch, tracks development punctually. launchpad.net pre-release packages built from here.
* stable ... v03 release branch, tracks pre-release punctually. launchpad.net stable packages built from here.
* v2 ... v2 development branch. (legacy)
* v2_stable ... v2 release branch, tracks v2 punctually. (legacy)
* issueXXX ... branch developed to address a particular issue.
See `Building from Source <BUILD.rst>`_


Release Process
---------------

See `Releases <Release.rst>`_

Proposed Coding Style Guidelines
--------------------------------

Generally, we used `Linux Kernel C Guidelines <https://www.kernel.org/doc/html/v4.10/process/coding-style.html>`_

but with one pythonic affectation: You know Rule 1? about the tabs with 8 characters? This code base is normally
indented like python instead, use four spaces, and not tabs.

Also, in terms of documenting code, when adding new things one should add comments
keeping in mind compatbility with `doxygen <http://www.doxygen.nl/manual/docblocks.html>`_
Examples::

/**
* descriptive comment above a struct or function declaration.
*/

/**
* sr_config_find_one() - find the name configuration file name
* \param sr_cfg: The configuration to be updated with the configuration found.
* \param original_one: The name provided by the user.
*
* Return pointer to the matching mask if there is one, NULL otherwise.
* The pointer to char will hold the absolute path of the config file corresponding to original_one
*
* Return: pointer to a static char buffer with a path name to the corresponding configuration file.
*/

char foo; /**< description of foo class member */


The code has a mix of comments is not entirely doxygen friendly just yet. Feel free
to improve. Other than that... the kernel C guidelines are the rule.

FIXME: We ran a code reformatter on it once... should probably repeat from time to time, would be
useful to document which one was used. I believe it undoes for the pythonic exception.
36 changes: 4 additions & 32 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ To note changes:
examine results, which include a valgrind run.
- install package so that it is used for flow tests on at least one platform.
- find redhat8 (with local disk) and run make test_shim

- on redhat8, edit Makefile to add -DINTERCEPT_SYSCALL to CFLAGS.

- find ubuntu18 (with local disk) and run make test_shim.
- dch, and touch up your points if need be.
- when ready to release, edit UNRELEASED to an appropriate status, usually unstable.
Expand All @@ -137,6 +140,7 @@ To note changes:
- go to an hpc account (on an intel node)
* mkdir ~/Sarracenia; cd ~/Sarracenia
* git clone https://github.com/MetPX/sarrac metpx-sr3c
* edit Makefile to add -DINTERCEPT_SYSCALL to CFLAGS.
* cd metpx-sr3c
* make rpm_rhel7
- go to a hpc account on a powerpc node
Expand All @@ -148,35 +152,3 @@ The rpm build targets run *rpmbuild* which places the packages in a standard tre
~/rpmbuild/RPMS/<arch>/..rpm on each arch the rpm will be created in the appropriate directory.








Building RPMS
-------------

This is the general procedure when building rpms on a system that has never
had an RPM build on it before.
Clone source to metpx-sr3c directory (needed by rpm build rules)::

git clone https://github.com/MetPX/sarrac metpx-sr3c
cd sr3c

on Suse::

zypper addrepo https://download.opensuse.org/repositories/network:messaging:amqp/openSUSE_Leap_15.1/network:messaging:amqp.repo
zypper refresh
zypper install librabbitmq4 librabbitmq-devel
zypper install libopenssl-devel libjson-c-devel
make rpm_suse15

on Redhat/Centos::

# install dependencies somehow... unclear in general.
make rpm_rhel7


( notes from: https://github.com/MetPX/sarrac/issues/73 )

2 changes: 1 addition & 1 deletion libsr3shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void srshim_realpost(const char *path)
return;
}
if (sr_c->cfg->shim_defer_posting_to_exit) {
sr_shimdebug_msg(1, "srshim_realpost post deferred to exist ... %s\n", fn);
sr_shimdebug_msg(1, "srshim_realpost post deferred to exit ... %s\n", fn);
return;
}

Expand Down
15 changes: 12 additions & 3 deletions shim_copy_baseDir.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'`
MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'`


# job step 0 - setup...
if [ ! -d ~/test ]; then
Expand Down Expand Up @@ -97,13 +100,19 @@ sr3 start subscribe/local_copy.conf

export SR_POST_CONFIG=local_post.conf
if [ "${SYSTEM_SHIM_TEST}" ]; then
export LD_PRELOAD=libsr3shim.so.1.0.0
export LD_PRELOAD=libsr3shim.so.${VERSION}
else
export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0:`pwd`/libsr3c.so.1.0.0
export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}:`pwd`/libsr3c.so.${VERSION}
#export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
fi
export SR_SHIMDEBUG=99
./shim_copy_post2.sh &

if [ "${KNOWN_REDIRECTION_BUG}" ]; then
bash ./shim_copy_post2.sh &
else
./shim_copy_post2.sh &
fi

unset SR_POST_CONFIG
unset SR_SHIMDEBUG
unset LD_PRELOAD
Expand Down
14 changes: 11 additions & 3 deletions shim_copy_flatten.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'`
MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'`


# job step 0 - setup...
if [ ! -d ~/test ]; then
Expand Down Expand Up @@ -95,13 +98,18 @@ sr3 start subscribe/local_copy.conf

export SR_POST_CONFIG=local_post.conf
if [ "${SYSTEM_SHIM_TEST}" ]; then
export LD_PRELOAD=libsr3shim.so.1.0.0
export LD_PRELOAD=libsr3shim.so.${VERSION}
else
export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0
export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}
export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
fi
export SR_SHIMDEBUG=99
./shim_copy_post.sh &
if [ "${KNOWN_REDIRECTION_BUG}" ]; then
bash ./shim_copy_post.sh &
else
./shim_copy_post.sh &
fi

unset SR_POST_CONFIG
unset SR_SHIMDEBUG
unset LD_PRELOAD
Expand Down
15 changes: 12 additions & 3 deletions shim_copy_mirror.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@


VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'`
MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'`

# job step 0 - setup...
if [ ! -d ~/test ]; then
mkdir ~/test
Expand Down Expand Up @@ -98,13 +101,19 @@ sr3 start subscribe/local_copy.conf

export SR_POST_CONFIG=local_post.conf
if [ "${SYSTEM_SHIM_TEST}" ]; then
export LD_PRELOAD=libsr3shim.so.1.0.0
export LD_PRELOAD=libsr3shim.so.${VERSION}
else
export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0
export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}
export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
fi
export SR_SHIMDEBUG=99
./shim_copy_post2.sh &

if [ "${KNOWN_REDIRECTION_BUG}" ]; then
bash ./shim_copy_post2.sh &
else
./shim_copy_post2.sh &
fi

unset SR_POST_CONFIG
unset SR_SHIMDEBUG
unset LD_PRELOAD
Expand Down
15 changes: 12 additions & 3 deletions shim_copy_mirror_sftp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'`
MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'`


# job step 0 - setup...
if [ ! -d ~/test ]; then
Expand Down Expand Up @@ -94,13 +97,19 @@ sr3 start subscribe/local_copy.conf

export SR_POST_CONFIG=local_post.conf
if [ "${SYSTEM_SHIM_TEST}" ]; then
export LD_PRELOAD=libsr3shim.so.1.0.0
export LD_PRELOAD=libsr3shim.so.${VERSION}
else
export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0
export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}
export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
fi
export SR_SHIMDEBUG=99
./shim_copy_post2.sh &

if [ "${KNOWN_REDIRECTION_BUG}" ]; then
bash ./shim_copy_post2.sh &
else
./shim_copy_post2.sh &
fi

unset SR_POST_CONFIG
unset SR_SHIMDEBUG
unset LD_PRELOAD
Expand Down
21 changes: 13 additions & 8 deletions shim_copy_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ cd shim_dirA
which bash

echo "FIXME: KNOWN ISSUE redirection close does not get posted!"
echo "#test 1 sha512 000 capturing stdout"
bash -c 'echo "hoho" >> ./hoho'
#echo "#test 1 sha512 000 capturing stdout"
#bash -c 'echo "hoho" >> ./hoho'

echo "#test 0 comment 010 shim copy posting start"
echo "#test 1 sha512 c program run."
Expand Down Expand Up @@ -83,17 +83,22 @@ mv dirone dirthree
echo "#test 1 link 135 symlink in a sub-dir"
ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four

echo "#test 1 sha512 create test_file"
echo "#test 1 sha512 142 create test_file with redirection"
echo 1 >test_file
echo "#test 1 sha512 update test_file"
echo "#test 1 sha512 151 update test_file"
touch test_file

echo "#test 1 rename move test_file into dirthree subdir"
echo "#test 1 rename 152 move test_file into dirthree subdir"
mv test_file dirthree
echo "#test 1 sha512 create test_file (again)"

echo "#test 1 sha512 162 create test_file (again)"
echo 2 >test_file
echo "#no post from touch, refused as repeat"
touch test_file

if [ ! "${KNOWN_REDIRECTION_BUG}" ]; then
echo "#no post from touch, refused as repeat"
touch test_file
fi

echo "#test 1 rename move test_file into dirthree subdir (new name)"
mv test_file dirthree/new_test_file

Expand Down
Loading