Skip to content

Conversation

@winem
Copy link
Contributor

@winem winem commented Feb 25, 2021

This PR adds support for --register-setup-virtualenvs-force-recreation to st2ctl. Use-case is, like we have it now with the upgrade to st2 v3.4, an upgrade of the Python version inside the virtual environments for example.

I'll run some tests now but wanted to provide the PR already so that others who ran into this issue can give it a try, too.

@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Feb 25, 2021
@winem winem added this to the 3.4.0 milestone Feb 25, 2021
echo " --register-policies Register all policies."
echo " --register-configs Register all configuration files."
echo " --register-setup-virtualenvs Create Python virtual environments for all the registered packs."
echo " --register-setup-virtualenvs-force-recreation (Delete and re-)create Python virtual environments for all the registered packs."
Copy link
Member

@arm4b arm4b Feb 25, 2021

Choose a reason for hiding this comment

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

Thinking about the shorter version, how this would sound instead?

-  --register-setup-virtualenvs-force-recreation
+  --register-setup-recreate-virtualenvs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it especially because it's more readable. Done & pushed.

I'll have to go to sleep now and will proceed with the testing tomorrow as well as looking into failing tests (if any).

Copy link
Member

Choose a reason for hiding this comment

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

OOH! The bike shed needs another coat of paint :trollface:

Let's shorten that even farther:

-  --register-setup-virtualenvs-force-recreation
+  --register-recreate-virtualenvs

Copy link
Member

@cognifloyd cognifloyd Feb 25, 2021

Choose a reason for hiding this comment

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

I'm resisting the recommendation to drop "register", even though re/creating virtualenvs doesn't actually "register" anything. Alas, keeping "register" keeps the args consistent.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I like --register-recreate-virtualenvs since it's the shortest :D

IIRC, register prefix was added at some point in the past due to some oslo config limitations or similar, but I forget the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there seems to be a limitation that requires the --register-xxx prefix. I can dig deeper into if needed but will focus on the failing tests and actual issues for now.

@m4dcoder
Copy link
Contributor

m4dcoder commented Feb 25, 2021

Can we rename options to --setup-venvs (replaces --register-setup-virtualenvs) and --reset-venvs (replaces --register-setup-virtualenvs-force-recreation)? Does venvs need registering, is that why we have to prefix it with register?

Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

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

Thanks for PR.

The tests are failing, because I think of a missing code change to register the new BoolOpt on the cfg, I've highlighted where I think it needs to go.

I also failed to run the command on upgrade using the artifact from this PR, which I thnk is same problem.

Also we probably should add a new test into ./st2common/tests/integration/test_register_content_script.py for the new parameter, similar to some of the ones already there for the current setup virtualenv.


function register_content() {
ALLOWED_REGISTER_FLAGS='--register-all --register-actions --register-aliases --register-runners --register-policies --register-rules --register-sensors --register-triggers --register-configs --register-setup-virtualenvs --register-fail-on-failure --register-no-fail-on-failure --verbose'
ALLOWED_REGISTER_FLAGS='--register-all --register-actions --register-aliases --register-runners --register-policies --register-rules --register-sensors --register-triggers --register-configs --register-setup-virtualenvs --register-setup-recreate-virtualenvs --register-fail-on-failure --register-no-fail-on-failure --verbose'
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the new option need to get added to the sudo flags?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it does need to run using sudo.

@arm4b
Copy link
Member

arm4b commented Feb 26, 2021

The context is that a new flag is a nice to have addition that just mimicks the following construction, required for 3.4 upgrade only:

sudo rm -rf /opt/stackstorm/virtualenvs/*
sudo st2ctl reload --register-setup-virtualenvs

@m4dcoder I think at this point refactoring existing params is undesired as a last-minute release enhancement and would be an overkill breaking change.

@winem
Copy link
Contributor Author

winem commented Feb 26, 2021

The context is that a new flag is a nice to have addition that just mimicks the following construction, required for 3.4 upgrade only:

sudo rm -rf /opt/stackstorm/virtualenvs/*
sudo st2ctl reload --register-setup-virtualenvs

@m4dcoder I think at this point refactoring existing params is undesired as a last-minute release enhancement and would be an overkill breaking change.

@armab we don't change any defaults so I don't see how this is could be a breaking change. Do I miss something?

@cognifloyd
Copy link
Member

@winem I think @armab was referring to @m4dcoder's request to rename the options:

Can we rename options to --setup-venvs (replaces --register-setup-virtualenvs) and --reset-venvs (replaces --register-setup-virtualenvs-force-recreation)? Does venvs need registering, is that why we have to prefix it with register?

Renaming the options would be a breaking change. Merely adding a new option as this PR does, is not a breaking change, IMO.

@Kami
Copy link
Member

Kami commented Feb 26, 2021

Yeah, I agree with @cognifloyd.

In the future, I maybe be OK with renaming it (if we can work around oslo.config limitations), but for this last minute change I'm for --register-recreate-virtualenvs since it's the shortest and consistent with the current naming scheme.

@blag
Copy link
Contributor

blag commented Feb 26, 2021

Try pinning mail-parser to >=3.9.1,<3.10.0 in contrib/core/requirements-tests.txt and see if that fixes it.

That package just had a release like 4 hours ago:
https://pypi.org/project/mail-parser/#history

And they might have broken something we were relying on, or fixed a bug that we were relying on.

@winem
Copy link
Contributor Author

winem commented Feb 26, 2021

Oh saw that you just pinned it. So let's see if that fixes the issue.

@cognifloyd thanks for clarifying it. Now it makes sense.

@amanda11
Copy link
Contributor

amanda11 commented Feb 26, 2021

Signed off my review comments, I've not had chance to try on an upgrade to check command works - but didn't want my comments to be a blocker for merging. But if it's been tested on an upgrade, then I'm happy.

@blag
Copy link
Contributor

blag commented Feb 26, 2021

Travis needs payment. I'll be out for an hour and fix it after that.

@winem
Copy link
Contributor Author

winem commented Feb 26, 2021

@amanda11 your input was actually very helpful and is always appreciated. And I added an integration test. :)

@blag
Copy link
Contributor

blag commented Feb 27, 2021

Paid off Travis-CI, adding a commit to kick CI again.

@blag blag merged commit d2e1860 into StackStorm:master Feb 27, 2021
@arm4b
Copy link
Member

arm4b commented Feb 27, 2021

🎉

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

Labels

feature size/M PR that changes 30-99 lines. Good size to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants