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

Merlin server configuration through commands #365

Merged
merged 57 commits into from
Jun 22, 2022

Conversation

ryannova
Copy link
Member

@ryannova ryannova commented May 27, 2022

A command interface to change/add/remove/edit the merlin server configuration, which can be utilized using the 'merlin server config' sub-command. Users should be encouraged to edit configurations through the command interface rather than through editing configuration files. This helps to maintain format consistency and schema of configuration files for merlin server. Note: Users might still need to changes configuration files if there are more fine tune adjustments needed for specific situations, or when options are not available within the 'merlin server config' command. Edits to configurations are only made to the configuration file located either in the main or local configuration directory. In order for these new changes to take effect(with some notable exceptions such as --add-user and --remove-user), merlin server must be restarted. A new command 'merlin server restart' has been added to provide convenience for users when needed to restart the container. A list of available configuration can be seen in the changelog below.

Added layer of security which requires users to authenticate before they are allowed access data within the merlin server containers. Authentication utilizes ACL(Access Control List) already implemented within redis to authenicate users. On merlin server initialization a "default" user with password listed in the redis.conf file is created.(This can be changed using the -p,--password, but defaults to 'merlin_password') A user with the current username of the user on the machine will also be generated. The user's password is generated and stored in the "redis.pass" file within the main merlin config directory. Note: This main password is only generated once and will not generated every time merlin server is initialized. If a new password is needed simply remove the "redis.pass" file and run 'merlin server init' again. Additional users can be added with 'merlin server config' command. A local configuration file called 'redis.users', which lists all users information and permissions are stored in the local configuration directory. Users added or removed using 'merlin server config' are applied to the current running container if there is one. If there are no running containers, changes will only apply the next time merlin server is started..

A refactoring of the code was also done in hopes to provide better clarity, transparency, readability of the code base. Notable changes is the addition of the server_utils.py file which stores classes and functions that are frequently used by other scripts. Constants are also stored in this file, which were previously located in server_config.py. A new server_commands.py script which contains function calls for each of the corresponding merlin server commands has also been created. Lastly a few minor edits and changes to configuration files were made. More detail can be seen in the Changelog below and details within this merge request.

Changelog:

  • Create functional calls for each merlin server command
  • Create server_command.py to store command calls.
  • Added config subcommand to merlin server
  • Added following flags to config subcommand
    • ipaddress (Set the binded ip address of the container)
    • port (Set the binded port of the container)
    • user (Set the main user file for container)
    • password (Set the main user password file for container)
    • add-user (Add a user to the container image [outputs an associated password file for user]) (ONLY CHANGE IN CONFIG FILE)
    • remote-user (Remove user from list of added users) (ONLY CHANGE IN CONFIG FILE)
    • directory (Set the directory of the merlin server container files)
    • snapshot-seconds (Set the number of seconds elapsed before snapshot change condition is checked)
    • snapshot-changes (Set snapshot change condition for a snapshot to be made)
    • snapshot-file (Set the database file that the snapshot will be written to)
    • append-mode (Set the append mode for redis)
    • append-file (Set the name of the append only file for redis)
  • Added user_file to merlin server config
  • Added pass_file to merlin server config
  • add_user function add user to exisiting merlin server instance if one is running
  • remove_user function remove user from merlin server instance if one is running
  • Enable masteruser in redis config
  • Enable requirepass in redis config
  • Moved default constants from server_setup.py to server_config.py
  • Added server_util.py file to store utility functions.
  • Created RedisConfig class to interface with redis.conf file
  • Created RedisUsers class to interface with redis.user file
  • Better interface (ServerConfig, ContainerConfig, ContainerFormatConfig, and ProcessConfig) with getting configuration values from merlin server config file, with classes.
  • Changed "default" user password to be "merlin_password" as default.
  • Merlin server reapply users based on the saved redis.users config file.
  • Default user can use the password stored in redis.pass file in main merlin configuration.

Test functionality:

  • Authentication through redis-cli by providing file with password.
  • Authentication through redis python library.

Things needed to test:

  • Test on LC machines.
  • Test using app.yaml main configuration files
  • Test with merlin workflows and workers.

ryannova added 30 commits May 3, 2022 15:04
…pshot_seconds, snapshot_changes, snapshot_file, append_mode, append_file
@koning
Copy link
Member

koning commented Jun 9, 2022

What is the process to test this on LC?

@koning
Copy link
Member

koning commented Jun 9, 2022

(merlin3_8) [host]:merlin server init  
[2022-06-09 15:02:13: INFO] Unable to find exisiting server configuration.
[2022-06-09 15:02:13: INFO] Creating default configuration in /<path>/.merlin/server/
[2022-06-09 15:02:13: INFO] Copying file singularity.yaml to configuration directory.
[2022-06-09 15:02:13: INFO] Copying file docker.yaml to configuration directory.
[2022-06-09 15:02:13: INFO] Copying file podman.yaml to configuration directory.
[2022-06-09 15:02:13: INFO] Copying file merlin_server.yaml to configuration directory.
[2022-06-09 15:02:13: INFO] Creating merlin server directory.
[2022-06-09 15:02:13: INFO] Creating password file for merlin server container.
[2022-06-09 15:02:13: INFO] User <user> created in user file for merlin server container
[2022-06-09 15:02:13: INFO] Fetching redis image from docker://redis
[2022-06-09 15:02:26: INFO] Copying default redis configuration file.
[2022-06-09 15:02:26: INFO] Merlin server initialization successful.
(merlin3_8) [host]:merlin server start
[2022-06-09 15:02:37: ERROR] cannot unpack non-iterable NoneType object

@ryannova
Copy link
Member Author

ryannova commented Jun 9, 2022

I made some slight changes to the repo when I was testing this on the LC. Try to pull the lastest version and let me know if it works.

As for testing on the LC here are some tests that you can try.

Merlin Server basic functionality test

  1. merlin server init
  2. merlin server start
  3. merlin server info
  4. redis-cli
  5. AUTH merlin_password
  6. ACL list
  7. exit
  8. merlin server stop

Merlin Server restart functionality test

  1. merlin server init
  2. merlin server start
  3. merlin server restart
  4. merlin server info
  5. redis-cli
  6. AUTH merlin_password
  7. ACL list
  8. exit
  9. merlin server stop

Note here that you can AUTH as your current user by using your current username on the machine and the password located in "merlin_server/redis.pass". You will need to open the file can copy the random string and use it in step 6 (AUTH )

Merlin workflow test

  1. merlin server init
  2. merlin server start
  3. merlin server info
  4. merlin example hello_samples
  5. merlin run hello/hello_samples.yaml
  6. merlin server stop

Somethings to note about your merlin config file in "~/.merlin/app.yaml". Make sure that you have either "localhost" or "127.0.0.1" set as the server and the user set to "default" and password set to "merlin_password" (For some reason its not able to read a redis.pass file which contains the password for the current user when placed in the app.yaml file. I'm still looking into it.)

I'm also working on putting something together that I can show working on LC and hopefully in another pull request I can make some changes to the current testing framework to allow for automating some of these tests.

@ryannova ryannova self-assigned this Jun 20, 2022
@ryannova ryannova added the enhancement New feature or request label Jun 20, 2022
@ryannova
Copy link
Member Author

I've updated the changelogs to reflect the changes made in this pull request. @lucpeterson @koning Please take a look at it and if everything looks good, it is ready to be merged into develop.

Copy link
Member

@lucpeterson lucpeterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few pending comments. but otherwise looks good!

@ryannova ryannova merged commit 472d97b into LLNL:develop Jun 22, 2022
ryannova added a commit that referenced this pull request Dec 21, 2022
* Create python-publish.yml (#353)

* Adding GitHub action for publishing to pypi

* Workflows Community Initiative Metadata (#355)

* Added Workflows Community Initiative metadata info; fixed some old links

* Run black

* Add updates for lgtm CI security site (#357)

* Update code to remove LGTM Errors and Warnings and implement Recommendations.

* Change BaseException to Exception.

* Add lgtm config file.

* Changes for flake8.

* Add TypeError yo yam read.

* Add TypeError to yaml read.

* Just return when successful on the yaml read.

* Fix typo.

* Add merlin/examples to lgtm exclude list as well.

* Add ssl comment.

* Fix typo.

* Update version to 1.8.5.

* Update conf.py for new sphinx versions.

* Added Server Command Feature to Merlin (#360)

* Added merlin server capability to initalize, monitor and stop redis containers
* Added configuration for singularity, docker, and podman in merlin/server/
* Created documentation for "merlin server" command
* Added tests to initialize, start and stop a singularity+redis server to the local test suite. (Future: add to the "distributed tests" connecting to that server and running merlin)

Co-authored-by: Ryan Lee <ryannova@users.noreply.github.com> & Joe Koning <koning@users.noreply.github.com>

* Fix lgtm returns (#363)

* Changed script sys.exit commands to use try/catch, per lgtm recommendation

* Allow for flux exec arguments to limit the number of celery workers. (#366)

* Added the flux_exec batch argument to allow for flux exec arguments,
e.g. flux_exec: flux exec -r "0-1" to run celery workers only on
ranks 0 and 1 of a multi-rank allocation.

* Remove period.

* Merlin server configuration through commands (#365)

* Reorganized functions within server_setup and server_config
* Rename server_setup file to server_commands
* Added password generation for redis container in merlin server
* Changed redis configuration to require password authentication
* Added merlin config flags ipaddress, port, password, directory, snapshot_seconds, snapshot_changes, snapshot_file, append_mode, append_file
* Added server_util.py
* Added merlin user file into merlin server config
* Added RedisConfig class to interact and change config values within the redis config file
* Added merlin server restart
* Updated info messages
* Added function to add/remove users and store info to user file
* Update running container with new users and removed users
* Added ServerConfig, ProcessConfig, ContainerConfig, and ContainerFormatConfig classes to interact with configuration files
* Adjusted adding user and password to use values in config files
* Updated host in redis.conf
* Updated pull_server_image step
* Moved creation of local merlin config to create_server_config()
* Added placeholder for documentation of restart and config commands for merlin server

* Bugfix/changelog ci (#370)

* remove deprecated gitlab ci file
* Change CHANGELOG test to work for PRs other than to main

* App.yaml for merlin server (#369)

* Added AppYaml class to pull app.yaml and make changes required for merlin server configuration
* Applied AppYaml class and added log message to inform users to use new app.yaml to use merlin server
* Update LOG messages to inform users regarding local runs and instruct users of how to use app.yaml for local configuration
* Changed type to image type in ContainerConfig
* Shorten CHANGELOG.md for merlin server changes
* Updated read in AppYaml to utilize merlin.util.load_yaml

* Updated merlin server unit testing (#372)

* Added additional tests for merlin server in test definitions
* Fixed directory change to create a new directory if one doesn't exist
* Updated redis version to provide acl user channel support

* Addition of new shortcuts in specification file (#375)

* Added five shortcuts to the specification definition MERLIN_SAMPLE_VECTOR, MERLIN_SAMPLE_NAMES, MERLIN_SPEC_ORIGINAL_TEMPLATE, MERLIN_SPEC_EXECUTED_RUN, MERLIN_SPEC_ARCHIVED_COPY
* Added documentation for the above shortcuts.
Co-authored-by: Jim Gaffney <gaffney3@llnl.gov>

* Remove emoji from issue templates (#377)

* Update bug_report.md

remove "buggy" emoji

* Update feature_request.md

* Update question.md

* Update CHANGELOG.md

* Update CHANGELOG.md

typo fix

Co-authored-by: Ryan Lee <lee1098@llnl.gov>

* Update contribute.rst

Remove more emoji from docs that are breaking pdf builds

* Update cert_req to cert_regs in the docs. (#379)

Co-authored-by: Ryan Lee <44886374+ryannova@users.noreply.github.com>

* Ssl server check fixes (#380)

* Add ssl to the Connection object for checking broker and results server
acess.

* Update CHANGELOG

* Update documentation in tutorial and merlin server (#378)

* Updated installation in instroduction and removed redis requirements
* Removed pip headers and added commands for merlin server into installation
* Removed additional references to old redis way and update description of merlin server
* Remove more emoji from docs that are breaking pdf builds
* Updated CHANGELOG to reflect changes to documentation
Co-authored-by: Luc Peterson <peterson76@llnl.gov>

* Update MANIFEST.in (#381)

* Update MANIFEST.in

Add .temp to examples in MANIFEST, so that they get bundled with pypi releases

* Update CHANGELOG.md

* Add support for non-merlin blocks in specification file (#376)

* Adding support for "user" block in _dict_to_string method
* Updated CHANGELOG
* Updated Merlin Spec docs
* Added user block in feature_demo.yaml example
Co-authored-by: Jim Gaffney <gaffney3@llnl.gov>

* Update Merlin Server (#385)

* Added condition for fatal error from redis server
* Update default value for config_dir
* Updated fix-style target in Makefile to be consistent with other style related targets
* Update default password to use generated password
* Updated run user to be default rather than created user
* Updated singularity command to specify configuration directory as home directory to solve unaccessible directory issue
* Update merlin to use app.yaml configuration rather than its own configuration file

* Docs/install changes (#383)

Many modifications to documentation, including installation instructions and formatting fixes.

* Maestro v 1.1.9dev1 Compatibility (#388)

Maestro up to date compatibility 
Also unpacked maestro DAG to just use what we need, which should help reduce task message size and perhaps allow us to use other serializers in the future.

* Bump certifi from 2022.9.24 to 2022.12.7 in /docs (#387)

Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.9.24 to 2022.12.7.
- [Release notes](https://github.com/certifi/python-certifi/releases)
- [Commits](certifi/python-certifi@2022.09.24...2022.12.07)

---
updated-dependencies:
- dependency-name: certifi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Release 1.9.0 (#390)

* Make CHANGELOG more concise

* Updated Merlin version and added License to files missing it

* Incremented python version for workflow test

* fix merlinspec not being installed with pip and python 3.7 issues with celery

* update changelog and version to 1.9.1

* fix a numpy issue on new numpy version release

* modify changelog to show numpy fix

* add version change to all files

* re-add fix for numpy since it got removed in the last commit by accident

* revert utils.py back to previous implementation

* change dtype to python str type

* Hotfix for merlin server unable to write config files. (#394)

* Hotfix for merlin server unable to write config files. Change files to modules and copy files from new file modules

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Luc Peterson <peterson76@llnl.gov>
Co-authored-by: Joseph M. Koning <koning1@llnl.gov>
Co-authored-by: Joe Koning <koning@users.noreply.github.com>
Co-authored-by: Brian Gunnarson <49216024+bgunnar5@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Gunnarson <brianfunnarson14@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants