Add container labels to JournalD logs#553
Closed
OZoneGuy wants to merge 4 commits intocontainers:mainfrom
Closed
Conversation
Signed-off-by: OZoneGuy <oalkersh@protonmail.com>
08aa60a to
84675f1
Compare
Signed-off-by: OZoneGuy <oalkersh@protonmail.com>
pass NULL as the first argument for subsequent calls Signed-off-by: OZoneGuy <oalkersh@protonmail.com>
8a1db71 to
53f81bd
Compare
giuseppe
requested changes
Apr 15, 2025
src/ctr_logging.c
Outdated
| } | ||
| container_labels = g_alloca((sizeof(char *)) * container_labels_count); | ||
| container_labels_lengths = g_alloca((sizeof(int *)) * container_labels_count); | ||
| char *pair = strtok(log_labels, ","); |
Member
There was a problem hiding this comment.
strtok modifies the buffer, so log_labels will be modified. The correct way to do it is to g_strdup the string before passing it to strtok.
Comment on lines
+350
to
+352
| if (writev_buffer_append_segment_no_flush(&bufv, container_labels[i], container_labels_lengths[i]) < 0) | ||
| return -1; | ||
| } |
Member
There was a problem hiding this comment.
I suggest to not create the arrays before and then have to worry about cleaning them up.
Just strdup container_labels here and call writev_buffer_append_segment_no_flush while you parse it.
Contributor
Author
There was a problem hiding this comment.
Going back to this. Since the array will live for the entire of the program. Is this needed? Not to challenge, just want to get more familiar with C and this codebase.
Signed-off-by: OZoneGuy <oalkersh@protonmail.com>
0d8bb89 to
723bd0c
Compare
|
Ephemeral COPR build failed. @containers/packit-build please check. |
Contributor
|
This PR can be closed due to #562 being merged |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add the ability to add the container labels to the journald logs as extra parameters.
Relies on the caller to pass the label key and value.
Usage:
The labels and values will be added to the journald entry.
This is my first contribution to a C codebase. Feedback is most
Still need to test the changes locally.