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

ctr_logs: use container name or ID as SYSLOG_IDENTIFIER for journald #294

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

haircommander
Copy link
Collaborator

now, when journald is used for the log driver, the logs will appear as:
ctrName[PID]:...
or
partialID[PID]:... (if using a sufficiently old podman)

instead of
conmon[PID]

Signed-off-by: Peter Hunt pehunt@redhat.com

@haircommander
Copy link
Collaborator Author

fixes #293

@rhatdan
Copy link
Member

rhatdan commented Sep 17, 2021

LGTM

@rhatdan
Copy link
Member

rhatdan commented Sep 17, 2021

@giuseppe @flouthoc PTAL

@@ -257,6 +274,9 @@ int write_journald(int pipe, char *buf, ssize_t buflen)
if (name && writev_buffer_append_segment(dev_null, &bufv, container_name, name_len + NAME_EQ_LEN) < 0)
return -1;

if (writev_buffer_append_segment(dev_null, &bufv, syslog_identifier, syslog_identifier_len) < 0)
Copy link

@flouthoc flouthoc Sep 17, 2021

Choose a reason for hiding this comment

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

Not sure but i think we must check if syslog_identifier is valid before flushing. Maybe

-               if (writev_buffer_append_segment(dev_null, &bufv, syslog_identifier, syslog_identifier_len) < 0)
+               if (syslog_identifier && writev_buffer_append_segment(dev_null, &bufv, syslog_identifier, syslog_identifier_len) < 0)

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 suppose we could but I intentionally made it so that syslog_identifier was always defined (either container name or ID). if it'd make you more comfortable I can update

Choose a reason for hiding this comment

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

@haircommander oh it is completely fine then :) . Thanks for confirming.

src/ctr_logging.c Show resolved Hide resolved
syslog_identifier_len = name_len + SYSLOG_IDENTIFIER_EQ_LEN;
} else {
syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", short_cuuid);
syslog_identifier_len = TRUNC_ID_LEN + SYSLOG_IDENTIFIER_EQ_LEN;
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the one thing I am concerned about is the null byte here, but in other uses we use TRUNC_ID_LEN + CID_EQ_LEN which doesn't seem to count null

@flouthoc
Copy link

LGTM

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe
Copy link
Member

@haircommander are these CI failures expected? If so, please merge

@haircommander
Copy link
Collaborator Author

I was able to reproduce the test failure, we want cri-o/cri-o#5334 first

now, when journald is used for the log driver, the logs will appear as:
ctrName[PID]:...
or
partialID[PID]:... (if using a sufficiently old podman)

instead of
conmon[PID]

Signed-off-by: Peter Hunt <pehunt@redhat.com>
@haircommander
Copy link
Collaborator Author

hold for #297

@rhatdan
Copy link
Member

rhatdan commented Sep 29, 2021

Since #297 was merged, I am going to merge this.

@rhatdan rhatdan merged commit 15a42cf into containers:main Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants