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

Add basic virtual env setup script. #10980

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

todor-ivanov
Copy link
Contributor

@todor-ivanov todor-ivanov commented Feb 4, 2022

Fixes #10979

Status

IN TESTING

Description

With the current script a proper virtual environment is setup for the WMCore central services. Together with satisfying all the package dependencies inside it based on the requirements_py3.txt coming with the WMCore code base.

NOTE: This is still a work in progress and it is meant to also provide a fully configured and properly linked runtime environment .

Is it backward compatible (if not, which system it affects?)

NO

Related PRs

None

External dependencies / deployment changes

In general this should depend on the service configuration repository:
https://gitlab.cern.ch/cmsweb-k8s/services_config/

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 3 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/12758/artifact/artifacts/PullRequestReport.html

deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
### Usage: -v <wmcore_path> WMCore virtual environment target path to be used for this deployment [Default: ./WMCore.venv3]
### Usage: -p <patches> List of PR numbers
### Usage: (in double quotes and space separated e.g. "5906 5934 5922")
### Usage: -s <service_names> List of service names to be patched
Copy link
Contributor

Choose a reason for hiding this comment

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

The above flag is very nice (about patches), but this one is confusing. How will I know which service should be patched? For that I need to know what my patches provide, etc. What if my patch is common for several services and in my list here I'll skip one? I rather prefer to avoid this option and just provide patches which should be applied uniformly to all services.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is a legacy, coming from the time (actually still the case) when because of the RPM based deployment every service was having its own area and branch in the deployed WMCore tree. So when it comes to patching a live service it is every time a single patch needs to be applied on all the deployed components (or at least the set of components you know the patch is affecting). Hence the list of services to be patched. And here is a script which I personally use very often when patching a single component [1]. Of course we are talking here about getting rid of slowly getting rid of this structure and pushing it all to run from a single code base and then the list of services to be patched is going to be a redundant option for sure. I do like the idea of running and patching a single code base for both development and runtime. (Although just as a note here - we may have issues if we want multiple users to be running the different services (as it was with cmsweb before), unless we decide to solve that in the K8 deployment scripts - we still have the option to dedicate a set of pods per service so the privileges and authentication related issues may be addressed there).

[1]
https://github.com/dmwm/WMCore/blob/master/bin/patchComponent.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a note here @vkuznet .
I did remove the list of services to be patched as you suggested and left only the list of patches to be applied, which is indeed much cleaner, but I still need to implement the actual call to the patching script. Yet to be done.

deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
@vkuznet
Copy link
Contributor

vkuznet commented Feb 4, 2022

@todor-ivanov , the realpath can be easily replaced with this:

#!/bin/bash
FULL_SCRIPT_PATH="$(realpath "${0}")"
echo $FULL_SCRIPT_PATH
echo "$0"

both echo outputs produced the same results on Linux and MacOS if I run the full path of the script.

@todor-ivanov
Copy link
Contributor Author

yes,

echo $0

Would definitely work for the Full script path but wont work here:

venvPath=$(realpath $venvPath)

I'll think of something.

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/12760/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/12761/artifact/artifacts/PullRequestReport.html

@vkuznet
Copy link
Contributor

vkuznet commented Feb 16, 2022

@todor-ivanov what is the status of this development and can you provide time estimate when I'll be able to try it out? Another question, assuming that I can use your script to setup virtual environment. How easy to move from it to have working WMAgent, or MS? Do we have any procedure in place that after setup we can test and validate it? Here are few examples I have in mind:

  • setup venv on my laptop (I can setup separately various DBs if necessary)
  • how I run my own WMA or MS service?
  • how I can validate, i.e. run few workflows, different components in my local setup?

If I have all code in place, and running DBs, I would presume that everything can be done through local host communication. How ready configuration files and tests for this?

@vkuznet
Copy link
Contributor

vkuznet commented Mar 22, 2022

one month forward (!), @todor-ivanov can we move with this? What is the status? What else should be done here?

@todor-ivanov
Copy link
Contributor Author

Hi @vkuznet I only need to create the proper runtime environment for the services. Which needs little bit of digging [1]. The rest is simply putting it here, which shouldn't be a problem. As we said this was not a planned development, and I am fighting to finalize what was in the the plans for Q1, so I work on this one only when I have some extra time, hence the issue is floating between waiting and work in progress. I will return to this soon.

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 2 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13010/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13011/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 tests no longer failing
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13013/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13031/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13034/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13037/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 tests no longer failing
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13044/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 1 new failures
    • 7 tests added
    • 2 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13170/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13172/artifact/artifacts/PullRequestReport.html

@todor-ivanov
Copy link
Contributor Author

todor-ivanov commented May 9, 2022

Thanks @vkuznet for making another review and all your comments. I think I have addressed more of them. Few of them with some new commits other by comments. If you do not mind, let me also try to shed some more light and clarify few things here as well.

As a start let me express my view on the need of this script, which may help. We are in the process of phasing out the RPM based deployments and shifting more or less towards substituting this with another packaging/software distribution system, which as I can see should be pypi. (Need to stress - this process I do see as complementary to the containerization process rather than a substitution). This puts us in a very beneficial position in which we can use a well defined virtual environment with solidly set configuration and deployment tree inside it, with good isolation of our packages deployment area from the rest of the general purpose pypi deployed packages or OS dependent and general purpose libraries. This script is meant to provide also the sign of equality between the production runtime environment deployed inside a container running in production and the developers working environment. While at the same time does not tie developers' hands to not explore new concepts and ideas...., hence the ability to also run from source. All that said is simply leading to my vision about what our next step should be. Once we adopt it properly, and we are ready to get rid of the RPM based system we need to provide this script during the container building process with the proper set of options for the container at hand. That way we can have the same construction at runtime and during development, while at the same time the developers are not restricted to using a concrete version of the packages or configuration (!!! provided they take care of NOT messing up with the currently running production environment !!!! ).

you made it monolithic, i.e. it does everything.

I tend to disagree here. None of the steps, besides the ones related to the virtual environment and deployment tree creation, are mandatory and can easily be skipped during manual deployment.

For instance, as developer I can easily can do git actions, like checkout WMCore, and I don't know how it will coincide with this script. Can I point this script to use my git checkouts?

Yes you can. I did put some extra protections with my last two commits to be 100% sure this script does not touch developer's working area. Upon initial deployment and configuration to run from source you can easily create a soft link at $wmSrcPath (by default it should be ${VIRTUAL_ENV}/srv/WMCore) pointing to WMCore source code to somewhere else outside your virtual environment and upon that during any subsequent deployments you just provide the -n flag to the script so that you preserve your previous configuration and deployment area (and in case you forget to, you are supposed to lose only the soft link)

On another hand, this is virtual env and it should contain everything we need.

This I see as supportive to what I have tried to achieve.

But you start embeding configs into this approach which I dislike and commented in a code. Please discard from script configs,

This, as I already said in the comments inline, is:

  • First, not a mandatory step
  • Second, users config can be used instead of the mainstream configurations, provided they are properly uploaded in a repository accessible by git tools.

make jemalloc optional,

I already did

and provide ability to co-exists with existing git checkouts. I think the script will be much simpler if we'll allow users to do/use their own git actions. To give a reason about my preference to use own git actions is this. I have so many branches in my local git that if I'll use this venv script I'll need to port every single branch (which is not only extra work, extra space, etc. but it will force me to work only within venv area).

The ability is already in place. I have added few extra protections on top of that, and mentioned that, as long as the source code is mounted at the place where the deployment is happening, it can be made accessible from inside the venv through a symlink.

What if I want to move to another node (CERN or FNAL) to continue my work. Then, I'll need to redo this again and again, i.e. I need to install venv, then I need to re-port my branches, etc.

Again this is not the case. As long as your git working tree is physically accessible from the place where the deployment has taken place, it is going to work.

On the other hand, I can share a hint on what I am doing in my case (hope this can help someone). I am deploying somewhere remote (at any place where my central services will be able to access all external services they depend on - like MongoDB etc.) and then I never login to the machine I have deployed at for code editing. Instead, I work from my development environment at my local machine through emacs like:

user@localMachine $ emacs /ssh:lxplus.cern.ch:~/WMCoreDev.d/WMCore/src/python

While at the same time I do have this same source code linked from inside the virtual environment as:

user@VMorContainer $ ls -la /data/tmp/WMCore.venv3/srv/
d... auth
d... current -> /data/tmp/WMCore.venv3/srv/master
d... enabled
d... logs
d... master
d... state
l... WMCore -> ~/WMCoreDev.d/WMCore

This way I do not have delays from ssh lags for remote code development, while using the IDE from my own laptop. And I do have my source wherever I need it, provided the area is physically mountable inside the container or VM.

@todor-ivanov todor-ivanov requested a review from vkuznet May 10, 2022 10:29
Copy link
Contributor

@vkuznet vkuznet left a comment

Choose a reason for hiding this comment

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

@todor-ivanov instead of reviewing changes I tried to use it. Here is my findings using macOS:

./deploy-centralvenv.sh
./deploy-centralvenv.sh: line 219: md5sum: command not found
./deploy-centralvenv.sh: line 280: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
=======================================================
Deployment parameters:
-------------------------------------------------------
serviceList          : wmcore
enabledList          :  reqmgr2 reqmgr2-tasks reqmgr2ms-transferor reqmgr2ms-monitor reqmgr2ms-output reqmgr2ms-rulecleaner reqmgr2ms-unmerged workqueue reqmon reqmon-tasks t0_reqmon t0_reqmon-tasks
venvPath             : ./WMCore.venv3
wmCfgRepo            : https://:@gitlab.cern.ch:8443/cmsweb-k8s/services_config.git
wmCfgBranch          : test
wmSrcRepo            : https://github.com/dmwm/WMCore.git
wmSrcBranch          : master
wmTag                :
serPatch             :
pypi Index           : prod
runFromSource        : false
Cleanup Virtual Env  : true
verboseMode          : false
assumeYes            : false
central services host:
secSring             :
=======================================================
Continue? [y]:
...
You still have 5 sec. to cancel before we proceed.

=======================================================
Creating minimal virtual environment:
Continue? [y]:
...

=======================================================
Activate WMCore virtual env:
Continue? [y]:
...
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
Requirement already satisfied: pip in ./lib/python3.9/site-packages (22.0.4)

=======================================================
Setup WMCore paths inside the virtual env:
Continue? [y]:
...
./deploy-centralvenv.sh: line 289: /Users/vk/tmp/WMCore/WMCore.venv3/bin:/opt/anaconda3/bin:/Users/vk/.cargo/bin:/opt/local/bin:/opt/local/sbin:/Users/vk/bin:/Users/vk/perl5/bin:/Users/vk/bin/OSX/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/vk/Work/Languages/Go/gopath/bin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/share/java/hadoop-1.1.1/bin:/Users/vk/.fzf/bin: syntax error: operand expected (error token is "/Users/vk/tmp/WMCore/WMCore.venv3/bin:/opt/anaconda3/bin:/Users/vk/.cargo/bin:/opt/local/bin:/opt/local/sbin:/Users/vk/bin:/Users/vk/perl5/bin:/Users/vk/bin/OSX/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/vk/Work/Languages/Go/gopath/bin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/share/java/hadoop-1.1.1/bin:/Users/vk/.fzf/bin")

Even though it fails with something here is my attempt to use it

# and now if I list my local area I see the following
ls
WMCore.venv3          deploy-centralvenv.sh

ls WMCore.venv3
WMCore.venv3 bin          include      lib          pyvenv.cfg

# and it seems to be non-active
type python
python is /opt/local/bin/python

# env | grep PYTHON returns nothing too

Since I know python venv I tried the following

ls WMCore.venv3/bin
Activate.ps1  activate.csh  pip           pip3.9        python3       wheel
activate      activate.fish pip3          python        python3.9

# let's activate it
source WMCore.venv3/bin/activate

and I see that env | grep PYTHON is still empty but python location has changed:

type python
python is /Users/vk/tmp/WMCore/WMCore.venv3/bin/python

and since there is not PYTHONPATH I can't load WMCore

python
Python 3.9.12 (main, Mar 25 2022, 04:56:27)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import WMCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'WMCore'

From this trial I think you should do the following:

  • fix installation issues with md5sum and declare
  • provide summary after installation of what is installed and where
  • setup proper environment or print instructions how to do that
  • provide dump of examples, and either abort if user didn't provide required flags or dump example of what user can do when installation is completed with specific flags.

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 3 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13189/artifact/artifacts/PullRequestReport.html

@todor-ivanov
Copy link
Contributor Author

todor-ivanov commented May 11, 2022

Thank you very much @vkuznet for testing it. This is all indeed useful info.

ix installation issues with md5sum and declare

The problem with the declare -A command is not from the script, but simply you are running a too old bash version - prior to 4.*, which makes the use of associative arrays impossible. And since this is a major bash functionality that the script relies on, the rest of your run was simply doomed to failure.

This old bash version seems to be a common issue for OS X systems. See a proposed fix discussed at stackoverflow here[1], this comment in particular explains exactly what one can expect for MacOS and a solution proposed in this one. I am adding a required minimal bash version for the script to run with my latest commit.

As of md5sum, well this is my mistake - I forgot to add it to the list of required tools. Adding it now. The tool for linux based systems is provided I believe by coreutils package (naming may change depending on the distribution).

provide summary after installation of what is installed and where

It is already there. If your run was not to fail so dramatically you were supposed to see the following output as a summary of what has been set and where:

=======================================================
Setup the WMCore hooks at the virtual environment activate script
Continue? [y]: 
...
WMCoreVenvVars[WMCORE_SERVICE_ENABLED]	:	/data/tmp/WMCore.venv3/srv/enabled
WMCoreVenvVars[WMCORE_SERVICE_ROOT]	:	/data/tmp/WMCore.venv3/srv
WMCoreVenvVars[WMCORE_SERVICE_LOGS]	:	/data/tmp/WMCore.venv3/srv/logs
WMCoreVenvVars[PATH]	:	/data/tmp/WMCore.venv3/srv/WMCore/bin/:/data/tmp/WMCore.venv3/srv/current/bin/:/data/tmp/WMCore.venv3/bin:/afs/cern.ch/cms/caf/scripts:/afs/cern.ch/cms/common:/afs/cern.ch/cms/bin:/usr/sue/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/afs/cern.ch/user/.../bin
WMCoreVenvVars[WMCORE_SERVICE_CONFIG]	:	/data/tmp/WMCore.venv3/srv/current/config
WMCoreVenvVars[X509_USER_CERT]	:	/data/tmp/WMCore.venv3/srv/auth/dmwm-service-cert.pem
WMCoreVenvVars[WMCORE_SERVICE_STATE]	:	/data/tmp/WMCore.venv3/srv/state
WMCoreVenvVars[WMCORE_SERVICE_SRC]	:	/data/tmp/WMCore.venv3/srv/WMCore
WMCoreVenvVars[WMCORE_SERVICE_TMP]	:	/data/tmp/WMCore.venv3/srv/current/tmp
WMCoreVenvVars[PYTHONPATH]	:	/data/tmp/WMCore.venv3/srv/WMCore/src/python/:/data/tmp/WMCore.venv3/srv/current/auth/t0_reqmon-tasks:/data/tmp/WMCore.venv3/srv/current/auth/t0_reqmon:/data/tmp/WMCore.venv3/srv/current/auth/reqmon-tasks:/data/tmp/WMCore.venv3/srv/current/auth/reqmon:/data/tmp/WMCore.venv3/srv/current/auth/workqueue:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-unmerged:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-rulecleaner:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-output:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-monitor:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-transferor:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2-tasks:/data/tmp/WMCore.venv3/srv/current/auth/reqmgr2:/data/tmp/WMCore.venv3/srv/current/lib/python3.6/site-packages:/data/tmp/WMCore.venv3/lib/python3.6/site-packages
WMCoreVenvVars[WMCORE_SERVICE_AUTH]	:	/data/tmp/WMCore.venv3/srv/auth
WMCoreVenvVars[X509_USER_KEY]	:	/data/tmp/WMCore.venv3/srv/auth/dmwm-service-key.pem

I will work on making it more readable, though.

Valentin Thanks for testing it. Please give it a try again and write back your findings. I am also interested to see what the outcome will be. Since I am not able to run it under MacOS I will rely on your feedback in order to fix issues related to porting it to MacOS.

[1]
https://stackoverflow.com/questions/6047648/associative-arrays-error-declare-a-invalid-option

@vkuznet
Copy link
Contributor

vkuznet commented May 11, 2022

@todor-ivanov , you are wrong about my shell:

echo $SHELL
/bin/zsh

So, take this into account. I'm using zsh and it is up to date (aligned with master HEAD :) Since your script uses #!/bin/bash it is also wrong since my bash (again which is up to date) is located at

type bash
bash is /opt/local/bin/bash

is also up to date:

bash --version
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)

So, don't blame me :) You should change

#!/bin/bash

to

#!/usr/bin/env bash

to fix the issue.

deploy/deploy-centralvenv.sh Outdated Show resolved Hide resolved
@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 1 new failures
    • 7 tests added
    • 2 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13191/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 7 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13193/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 2 new failures
    • 1 tests deleted
    • 11 tests added
    • 2 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13200/artifact/artifacts/PullRequestReport.html

@todor-ivanov
Copy link
Contributor Author

todor-ivanov commented May 11, 2022

Hi @vkuznet with the latest commit I did fix the printout of the final environment variables to be more human readable. Here is an example of what it looks like in one of my setups. I hope this is good enough. Please give it a try and let me know.

=======================================================
Printing the final WMCore virtual environment parameters and tree:
-------------------------------------------------------

/data/tmp/WMCore.venv3
├── bin
├── include
├── lib
│   └── python3.6
│       └── site-packages
├── lib64 -> lib
├── share
│   ├── doc
│   └── man
│       └── man1
└── srv
    ├── auth
    ├── current -> /data/tmp/WMCore.venv3/srv/master
    ├── enabled
    ├── logs
    │   ├── reqmgr2
    │   ├── reqmgr2ms-monitor
    │   ├── reqmgr2ms-output
    │   ├── reqmgr2ms-rulecleaner
    │   ├── reqmgr2ms-transferor
    │   ├── reqmgr2ms-unmerged
    │   ├── reqmgr2-tasks
    │   ├── reqmon
    │   ├── reqmon-tasks
    │   ├── t0_reqmon
    │   ├── t0_reqmon-tasks
    │   └── workqueue
    ├── master
    │   ├── auth
    │   ├── bin
    │   ├── config
    │   ├── couchapp
    │   ├── cx_Oracle-doc
    │   ├── data
    │   ├── etc
    │   ├── lib
    │   ├── lib64
    │   ├── man
    │   ├── share
    │   └── tmp
    ├── state
    │   ├── reqmgr2
    │   ├── reqmgr2ms-monitor
    │   ├── reqmgr2ms-output
    │   ├── reqmgr2ms-rulecleaner
    │   ├── reqmgr2ms-transferor
    │   ├── reqmgr2ms-unmerged
    │   ├── reqmgr2-tasks
    │   ├── reqmon
    │   ├── reqmon-tasks
    │   ├── t0_reqmon
    │   ├── t0_reqmon-tasks
    │   └── workqueue
    └── WMCore -> /afs/cern.ch/user/.../WMCoreDev.d/WMCore
 

63 directories

-------------------------------------------------------
WMCoreVenvVars[PATH]                   : /data/tmp/WMCore.venv3/srv/WMCore/bin/
                                         /data/tmp/WMCore.venv3/srv/current/bin/
                                         /data/tmp/WMCore.venv3/bin
                                         /afs/cern.ch/cms/caf/scripts
                                         /afs/cern.ch/cms/common
                                         /afs/cern.ch/cms/bin
                                         /usr/sue/bin
                                         /usr/local/bin
                                         /usr/bin
                                         /usr/local/sbin
                                         /usr/sbin
                                         /opt/puppetlabs/bin
                                         /afs/cern.ch/user/.../bin
WMCoreVenvVars[PYTHONPATH]             : /data/tmp/WMCore.venv3/srv/WMCore/src/python/
                                         /data/tmp/WMCore.venv3/srv/current/auth/t0_reqmon-tasks
                                         /data/tmp/WMCore.venv3/srv/current/auth/t0_reqmon
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmon-tasks
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmon
                                         /data/tmp/WMCore.venv3/srv/current/auth/workqueue
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-unmerged
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-rulecleaner
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-output
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-monitor
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2ms-transferor
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2-tasks
                                         /data/tmp/WMCore.venv3/srv/current/auth/reqmgr2
                                         /data/tmp/WMCore.venv3/srv/current/lib/python3.6/site-packages
                                         /data/tmp/WMCore.venv3/lib/python3.6/site-packages
WMCoreVenvVars[RUCIO_HOME]             : /data/tmp/WMCore.venv3/srv/current
WMCoreVenvVars[WMCORE_SERVICE_AUTH]    : /data/tmp/WMCore.venv3/srv/auth
WMCoreVenvVars[WMCORE_SERVICE_CONFIG]  : /data/tmp/WMCore.venv3/srv/current/config
WMCoreVenvVars[WMCORE_SERVICE_ENABLED] : /data/tmp/WMCore.venv3/srv/enabled
WMCoreVenvVars[WMCORE_SERVICE_LOGS]    : /data/tmp/WMCore.venv3/srv/logs
WMCoreVenvVars[WMCORE_SERVICE_ROOT]    : /data/tmp/WMCore.venv3/srv
WMCoreVenvVars[WMCORE_SERVICE_SRC]     : /data/tmp/WMCore.venv3/srv/WMCore
WMCoreVenvVars[WMCORE_SERVICE_STATE]   : /data/tmp/WMCore.venv3/srv/state
WMCoreVenvVars[WMCORE_SERVICE_TMP]     : /data/tmp/WMCore.venv3/srv/current/tmp
WMCoreVenvVars[X509_USER_CERT]         : /data/tmp/WMCore.venv3/srv/auth/dmwm-service-cert.pem
WMCoreVenvVars[X509_USER_KEY]          : /data/tmp/WMCore.venv3/srv/auth/dmwm-service-key.pem

@todor-ivanov todor-ivanov requested a review from vkuznet May 11, 2022 21:11
Copy link
Contributor

@vkuznet vkuznet left a comment

Choose a reason for hiding this comment

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

Todor, macOS does not have md5sum tool, therefore you need to adjust your script to manage md5 in a different way. Quick google search reveals that on maxOS we have md5 tool which seems to me equivalent.

Bottom line, here is what I got:

./deploy-centralvenv.sh
./deploy-centralvenv.sh: line 219: md5sum: command not found
The current setup script requires: md5sum in order to continue. Please install it and rerun.
Interrupt execution due to step failure:
ERRORNO: 1

Now, regarding compatibility:

  • On Linux we have
echo "Todor" | md5sum
91e53b1970dc62a271b70d24ab3c66e5  -
  • on macOS we have
echo "Todor" | md5
91e53b1970dc62a271b70d24ab3c66e5

Copy link
Contributor

@amaltaro amaltaro left a comment

Choose a reason for hiding this comment

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

Todor, I finally managed to have a first look at this script, sorry for the delay.

It was hard to "parse" everything and closer to the end I didn't pay too much attention. Some general comments are:

  • maybe we don't need to ask for input confirmation for actions that are not really changing something in someone's machine (like git clones).
  • I think Valentin mentioned it in the past, but I do think it would be extremely helpful (and more sustainable) to have a small set of scripts. For instance, for CMSWEB, we have prep, sw and post, each in charge of different things. Here, we could easily have a script that does the initial virtual environment setup + python package requirements; separated from the actual WMCore services deployment; and maybe even separated from the WMCore service execution.
  • I also see you integrated some service "manage" actions in this script, replacing the standard manage scripts we already have in the services_config/deployment repositories. Is this really necessary or is it worth it the extra complexity on our side?

$verboseMode && set -x

# Swap noVenvCleanup flag with venvCleanup to avoid double negation and confusion:
venvCleanup=true && $noVenvCleanup && venvCleanup=false
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe refactor it to venvCleanup from the very beginning (as a command line arg)?

# so the `pythonCmd' variable shouldn't be needed any more.

pythonCmd=python
[[ $(python -V 2>&1) =~ Python\ *2.* ]] && pythonCmd=python3
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to print which python version we are using for the initial virtual env setup.

enabledList=""
for service in $_enabledListTmp
do
# First cut all pypi packaging version suffixes
Copy link
Contributor

Choose a reason for hiding this comment

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

At this stage, didn't we only provide the service name? Reading the code, I understand it parses it as if it was a line from the requirements.txt file (thus service + logical operator + version in pypi).


pipOpt="--no-cache-dir"
[[ $pipIndex == "test" ]] && {
pipOpt="$pipOpt --index-url $pipIndexTestUrl --extra-index $pipIndexProdUrl" ;}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the effect of the --extra-index option here? Can't it use only what is defined in the --index-url?

-d <wmcore_path> WMCore virtual environment target path to be used for this deployment [Default: ./WMCore.venv3]
-p <patches> List of PR numbers [Default: None]
(in double quotes and space separated e.g. "5906 5934 5922")
-m <security string> The security string to be used during deployment. Will be needed at startup [Default: ""]
Copy link
Contributor

Choose a reason for hiding this comment

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

I sort of have an idea of what this security string is, but what is the goal here?
We do have it in CMSWEB services (legacy implementation from +10 years ago) and the result is that people simply copy/paste the "I did read ..." security message. In other words, to me it's more like a complication than a security step.

# 100 - Success - skip step, consider it recoverable
# 101 - Success - skip step based on user choice
# 102 - Failure - interrupt execution based on user choice
# 1-255 - Failure - interrupt all posix return codes
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume it to be a range, right? In that case, this range also cover the exit codes above, which you define as being success :-D

echo -n "Should we try to reinstall them while releasing version constraint? [y]: "
$assumeYes || read x && [[ $x =~ (n|no|nO|N|No|NO) ]] && return 101
echo "..."
echo "Retrying to satisfy dependency releasing version constraint:"
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I failed to understand the logic for resolving dependencies issues. Could you please clarify it?

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 2 new failures
    • 3 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13573/artifact/artifacts/PullRequestReport.html

… full pkg dependencies only when running from source.
@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14215/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deployment: Create a single script to create universal virtual environment for all WMCore services.
4 participants