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

Refs #32917 - Don't deploy or configure Redis with new tasking system #207

Merged
merged 1 commit into from
Jul 9, 2021

Conversation

wbclark
Copy link
Collaborator

@wbclark wbclark commented Jul 1, 2021

This is a more gradual alternative to #206

In particular, it doesn't include the ability to enable or disable management of Redis, nor does it consider the content caching feature.

it simply includes the redis class and configures Pulpcore for Redis, based on the value of use_rq_tasking_system

@wbclark wbclark marked this pull request as draft July 1, 2021 16:34
@wbclark wbclark force-pushed the 32917_gradual_approach branch from 23950c2 to 760d795 Compare July 7, 2021 20:29
@wbclark
Copy link
Collaborator Author

wbclark commented Jul 7, 2021

rebased and added logic to handle content caching

@ekohl
Copy link
Member

ekohl commented Jul 8, 2021

Please rebase now that #203 is merged.

@wbclark
Copy link
Collaborator Author

wbclark commented Jul 8, 2021

 Failures:

  1) basic installation Command "DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig" stdout is expected to match /^0 workers, /
     Failure/Error: its(:stdout) { is_expected.to match(/^0 workers, /) }
       expected "Error 99 connecting to localhost:6379. Cannot assign requested address.\n" to match /^0 workers, /
       Diff:
       @@ -1 +1 @@
       -/^0 workers, /
       +Error 99 connecting to localhost:6379. Cannot assign requested address.
       
     # ./spec/acceptance/basic_spec.rb:83:in `block (3 levels) in <top (required)>'

  2) basic installation Command "DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig" exit_status is expected to eq 0
     Failure/Error: its(:exit_status) { is_expected.to eq 0 }
       
       expected: 0
            got: 1
       
       (compared using ==)
       
     # ./spec/acceptance/basic_spec.rb:85:in `block (3 levels) in <top (required)>'

Finished in 8 minutes 54 seconds (files took 1 minute 7.13 seconds to load)
176 examples, 2 failures

This I can fix, but what I want to point out is, we only don't see similar results in some of the enable/disable rq tasking tests, because of the order in which those tests are running.... once redis gets installed once, the failure won't occur.

@wbclark wbclark force-pushed the 32917_gradual_approach branch from 760d795 to 274cf1c Compare July 8, 2021 15:37
@wbclark wbclark marked this pull request as ready for review July 8, 2021 15:37
@ekohl
Copy link
Member

ekohl commented Jul 8, 2021

That sounds like Pulp has a hard dependency on Redis and something we should take upstream.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

You can also consider a line in init.pp like $uses_redis = $use_rq_tasking_system or $cache_enabled and use that variable in database.pp and settings.py.

templates/settings.py.erb Outdated Show resolved Hide resolved
@wbclark
Copy link
Collaborator Author

wbclark commented Jul 8, 2021

That sounds like Pulp has a hard dependency on Redis and something we should take upstream.

That isn't how I interpreted it. If you look closely at what happens:

[root@centos8-64-1 ~]# DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig
Error 111 connecting to localhost:6379. Connection refused.

I'll update that test.

Additionally, I'm going to move the 'enable content caching' test out of basic_spec.rb where we have multiple top-level describe blocks. I'd like to move the reducing worker count test out into its own test as well, but there is already a PR open for it (#209 )

@wbclark
Copy link
Collaborator Author

wbclark commented Jul 8, 2021

You can also consider a line in init.pp like $uses_redis = $use_rq_tasking_system or $cache_enabled and use that variable in database.pp and settings.py.

Probably a good idea to consolidate the logic in this way. Thanks

I was actually taking a similar approach with #206 and I'm not sure the reason I didn't follow it here. Probably a simple oversight

spec/classes/redis_spec.rb Outdated Show resolved Hide resolved
@wbclark wbclark force-pushed the 32917_gradual_approach branch 2 times, most recently from 6612b0f to 0933244 Compare July 8, 2021 19:17
is_expected.to contain_concat__fragment('base')
.without_content(/CACHE_ENABLED = True/)
.without_content(%r{CACHE_SETTINGS = \{\n 'EXPIRES_TTL': 60,\n\}})
end
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch, thank you.

is_expected.to contain_concat__fragment('base')
.with_content(/USE_NEW_WORKER_TYPE = True/)
is_expected.to contain_systemd__unit_file('pulpcore-resource-manager.service').with_ensure('absent')
end
Copy link
Member

Choose a reason for hiding this comment

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

This are OK here, but they feel better up here https://github.com/theforeman/puppet-pulpcore/pull/207/files#diff-257fe3136ecfdbfcb123b6445ff2de6c21d1fe08b0d6af54c08dde40637d2594R19 for me as it connects all of the configuration file together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I started to think that it makes sense to structure the tests around the real world use case rather than the specific object being tested..

So instead of having all tests for the configuration file in the same place, have a test for 'content caching is disabled', 'postgresql tasking system is used', and so on.

I see two primary benefits: 1. This feels more maintainable in the longer term (when we make modifications to a specific feature, the tests for that feature are all located in that block, rather than spread out across different components the feature touches). 2. This should lead to more readable test output, and particularly failures. So instead of getting a failure like default parameters - it configures pulpcore - it is expected to contain a file with (lots of stuff, including all kinds of things that aren't relevant to the specific thing you broke) you would instead see something more like default parameters - it uses new tasking system - it is expected to contain a configuration file with specific things that are relevant to the tasking system

I want to pursue this idea more consistently in my planned refactoring. For this PR I thought, it makes sense to write the net-new tests using this style, to minimize the amount of re-writing I have to do later.

@wbclark wbclark force-pushed the 32917_gradual_approach branch from 0933244 to 1d948d3 Compare July 8, 2021 23:37
@wbclark
Copy link
Collaborator Author

wbclark commented Jul 8, 2021

Thanks for feedback @ehelms !

I pushed an update to address these items. In particular I use %r{} consistently throughout spec/classes/pulpcore_spec.rb (I thought we were already mixing // often but I was mistaken -- there was only a single, very small instance of that before the code I introduced here)

Regarding the overall structure of the tests, I did opt to keep for now the change of moving some tests of the configuration file contents out of the it 'configures pulpcore' block and into feature-specific blocks. Arguably that should be handled in my other test refactoring PR, but I'm balancing that fact vs. the fact that I already need to add these feature-specific blocks here now, and it's less work for me overall to not write it one way now, knowing that I'm planning to re-write it a different way soon.

With that said, if any of those changes are really controversial, I can revert them and tackle them later. The goal in not writing the same code twice is to save time. If it's not actually saving me (rather us, since review time is part of the equation too) time in the end, I'll go ahead and do what is asked of me here, and re-write it the way I think it really should be in the other PR.

@ehelms
Copy link
Member

ehelms commented Jul 9, 2021

If you are curious where I got the using %r{} everywhere, this comes from some initial work @ekohl did to add Rubocop. You can see what that looks like for example here, https://github.com/theforeman/puppet-qpid/pull/167/files. This uses an inherited Rubocop configuration from voxpupuli-test which has:

https://github.com/voxpupuli/voxpupuli-test/blob/master/rubocop.yml#L467-L470

Thus, they have chosen to enforce the use of %r{} as the way to define regex.

@ehelms ehelms merged commit 7a5543b into theforeman:master Jul 9, 2021
@ehelms ehelms added the Enhancement New feature or request label Jul 12, 2021
@ekohl
Copy link
Member

ekohl commented Jul 13, 2021

That sounds like Pulp has a hard dependency on Redis and something we should take upstream.

Looks like we're running into this now: https://community.theforeman.org/t/katello-nightly-rpm-pipeline-1027-failed/24403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants