-
Notifications
You must be signed in to change notification settings - Fork 116
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
Conditionally include Redis connection information #1484
Conditionally include Redis connection information #1484
Conversation
Attached issue: https://pulp.plan.io/issues/9070 |
@dralley I saw you're assigned to https://pulp.plan.io/issues/8997 and I think this can be considered a blocker to that effort. We're now running into this. Please have a look. |
A few concerns:
|
This is indeed something I also thought about. However, I think the output format should clarify that it's optional then. Right now the output is (simplified): {
"redis_connection": {
"connected": false
}
} So what should it then become if it's optional? {
"redis_connection": false
} Or: {
"redis_connection": {
"connected": false,
"used": false
}
}
Foreman does indeed have Redis (but we support an external Redis as well) but on content proxies there is no Foreman so no Redis. That means we'll reduce resources if we don't install it. Fewer services is generally also appreciated by security folks.
Our install can handle conditional inclusion, but doesn't handle clean up. I like to socket activation suggestion but I'm not sure if Redis supports that today. I'm looking into unix sockets anyway (theforeman/puppet-pulpcore#220) but it appears that now results in internal server errors. I'll need to dive into that. |
I agree that we want to avoid having conditional keys in our response. I have no objection to the two proposals you mention (just setting connection to false or adding a Another option is to return |
I'm in favor of this approach |
aa92697
to
e4bc10a
Compare
I like |
@@ -74,6 +74,9 @@ class StatusSerializer(serializers.Serializer): | |||
help_text=_("Database connection information") | |||
) | |||
|
|||
redis_connection = RedisConnectionSerializer(help_text=_("Redis connection information")) | |||
redis_connection = RedisConnectionSerializer( | |||
required=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming you can't return null unless required=False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought required
was only used for creating resources. It usually allows the non-presence of the entire key rather than affecting null
ability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must admit I didn't even check it and assumed it. Note that storage also already is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness, from a current Pulp 3.14 without this patch. When I go to /pulp/api/v3
using a browser (text/html):
StatusResponse:
type: object
description: Serializer for the status information of the app
properties:
versions:
type: array
items:
$ref: '#/components/schemas/VersionResponse'
description: Version information of Pulp components
online_workers:
type: array
items:
$ref: '#/components/schemas/WorkerResponse'
description: List of online workers known to the application. An online
worker is actively heartbeating and can respond to new work
online_content_apps:
type: array
items:
$ref: '#/components/schemas/ContentAppStatusResponse'
description: List of online content apps known to the application. An online
content app is actively heartbeating and can serve data to clients
database_connection:
allOf:
- $ref: '#/components/schemas/DatabaseConnectionResponse'
description: Database connection information
redis_connection:
allOf:
- $ref: '#/components/schemas/RedisConnectionResponse'
description: Redis connection information
storage:
allOf:
- $ref: '#/components/schemas/StorageResponse'
description: Storage information
required:
- database_connection
- online_content_apps
- online_workers
- redis_connection
- versions
Note storage
is not in required
. While it may describe inputs, it is the closest thing there is to also describe the output. That's why I think it still makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing to check, IMHO is whether the bindings can parse the result without error.
CHANGES/9070.bugfix
Outdated
@@ -0,0 +1,2 @@ | |||
Remove Redis connection information from status unless it's used, either by RQ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is perhaps still valid? Maybe better to say "Return null for redis connection key..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated it but this morning I couldn't think of a better text. Technically it sort of still removes it but I agree explicitly saying that it's null is clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Let me know what you think of it now.
Redis is only used when cache is enabled or RQ tasking is used. In other cases, the connection is not needed. We've changed the Foreman installer to only install Redis if needed, just to stop wasting resources[1]. However, this leads to warnings. This PR changes the status view to only include Redis if it's used. [1]: theforeman/puppet-pulpcore@7a5543b closes #9070 https://pulp.plan.io/issues/9070
e4bc10a
to
c3db975
Compare
self.assertTrue(status["redis_connection"]["connected"]) | ||
self.assertNotEqual(status["online_workers"], []) | ||
self.assertNotEqual(status["versions"], []) | ||
if self.storage == "pulpcore.app.models.storage.FileSystem": | ||
self.assertIsNotNone(status["storage"]) | ||
else: | ||
self.assertIsNone(status["storage"]) | ||
|
||
@override_settings(CACHE_ENABLED=False, USE_NEW_WORKER_TYPE=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had no idea this was a thing, neat!
I should probably create an issue for this, but before I do: this changes the API. Does that disqualify it for a cherry pick to 3.14? The reasoning is that with that we can avoid ever installing Redis in some scenarios. |
This is a good question and I'm a bit torn. I'll add it to Tuesday's pulpcore meeting agenda for us to discuss and report back. |
I'm also slightly conflicted, it's probably not something we would normally do - but on the other hand, it's not a particularly meaningful change but it is something that I assume Katello would probably want to add to their backport list. And a lot of our users, most of them even, are using the Katello RPMs, so we don't necessarily want a divergence between the Katello 3.14 and the upstream 3.14 either. So that would be a reason in favor of merging it anyways. |
Thanks! I completely understand being torn because I'd be the same. Perhaps a good question is what @mdellweg said: will the bindings change? If it needs updated bindings, I can see the barrier being much higher. Let me know if I need to do anything. |
Redis is only used when cache is enabled or RQ tasking is used. In other cases, the connection is not needed. We've changed the Foreman installer to only install Redis if needed, just to stop wasting resources. However, this leads to warnings.
This PR changes the status view to only include Redis if it's used.
Right now there are no tests since I first want to discuss if this is even the right direction. That's also why this PR is a draft.
https://pulp.plan.io/issues/9070