-
Notifications
You must be signed in to change notification settings - Fork 112
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 support for correlation_id to pulp #1017
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add support for logging messages with a correlation id that can either be autogenerated or passed in | ||
with a ``Correlation-ID`` header. This feature is provided as a tech preview in pulpcore 3.9. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.2.16 on 2020-09-25 22:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0051_timeoutfields'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='task', | ||
name='logging_cid', | ||
field=models.CharField(db_index=True, default='', max_length=256), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
import uuid | ||
|
||
from pulp_smash import api, cli, config | ||
from pulp_smash.pulp3.bindings import monitor_task | ||
|
||
from pulpcore.client.pulpcore import ApiClient, OrphansApi, TasksApi | ||
|
||
|
||
class CorrelationIdTestCase(unittest.TestCase): | ||
"""Test correlation id functionality.""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Set up class variables.""" | ||
cls.cid = str(uuid.uuid4()) | ||
cls.cfg = config.get_config() | ||
cls.client = api.Client(cls.cfg, api.json_handler) | ||
cls.client = ApiClient( | ||
configuration=cls.cfg.get_bindings_config(), | ||
header_name="Correlation-ID", | ||
header_value=cls.cid, | ||
) | ||
cls.cli_client = cli.Client(cls.cfg) | ||
|
||
cls.orphan_api = OrphansApi(cls.client) | ||
cls.task_api = TasksApi(cls.client) | ||
|
||
def test_correlation_id(self): | ||
"""Test that a correlation can be passed as a header and logged.""" | ||
response, status, headers = self.orphan_api.delete_with_http_info() | ||
monitor_task(response.task) | ||
task = self.task_api.read(response.task) | ||
self.assertEqual(headers["Correlation-ID"], self.cid) | ||
self.assertEqual(task.logging_cid, self.cid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Dec 04 16:01:39 pulp3-source-fedora32.fluffy.example.com gunicorn[44116]: pulp [None]: django_guid:INFO: Header
Correlation-ID
was not found in the incoming request. Generated new GUID: b9c98a1029fd4dca8be4b5725dc5236ewas it intentional to log this at the info level?
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.
Unfortunately yes. I'm not thrilled by it but it's what django-guid does.
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.
oic
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.
It also logs the same if I provide a correlation ID in the wrong format (not UUID). I think it's very confusing. Maybe we should file an issue/rfe about all that.
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.
Not sure I follow. When I submit an invalid uuid, I get:
What's confusing?
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
http :/pulp/api/v3/repositories/rpm/rpm/ Corellation-ID:tadaaaaaa
or POST to this, I get:pulp [None]: django_guid:INFO: Header `Correlation-ID` was not found in the incoming request. Generated new GUID: 306940d3dad043c78992f3ac70e98ab2
I wonder if it's because it's a synchronous call and not with a task.
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.
/me can't spell
Correlation
correctly. Problem solved.