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

logging: new mode -l passthrough #11390

Merged
merged 1 commit into from Sep 29, 2021

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented Sep 1, 2021

it allows to pass the current std streams down to the container.

conmon support: containers/conmon#289

[NO TESTS NEEDED] it needs a new conmon.

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 1, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 1, 2021
@giuseppe
Copy link
Member Author

giuseppe commented Sep 1, 2021

@vrothberg what do you think?

This should improve integration with systemd (but some commands won't work)

@TomSweeneyRedHat
Copy link
Member

Changes LGTM
but tests are an ugly red.

@@ -200,7 +200,7 @@ func run(cmd *cobra.Command, args []string) error {
return err
}

if runOpts.Detach {
if runOpts.Detach && cliVals.LogDriver != define.PassthroughLogging {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't these conflict? It doesn't seem particularly sane to log to the terminal's STDOUT and STDERR when the process is no longer attached to the controlling terminal.

Copy link
Member Author

Choose a reason for hiding this comment

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

the fds are passed down to the container that can still use them.

I think the only sane usage of this option is within a systemd service.

Using a tty won't be allowed by conmon as it opens to security issues: https://github.com/containers/conmon/pull/289/files#diff-26c58c117a24670c396f3e8e3e86cd6a6f134b3f02f84f8c894213c16c542d4cR165-R166

Copy link
Member

Choose a reason for hiding this comment

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

Can we get documentation to that effect? I was very confused by what this option was for.

Also, I think conflicting with --tty makes a lot of sense - we won't have split stderr/stdout, and won't have raw mode set so the output will likely be garbage.

Copy link
Member

Choose a reason for hiding this comment

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

I like Matt's suggestion

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the error also to Podman so we don't rely on conmon checking for it

@giuseppe giuseppe marked this pull request as draft September 2, 2021 07:39
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 2, 2021
@giuseppe
Copy link
Member Author

giuseppe commented Sep 2, 2021

converted to draft. Let's wait for the conmon change to be accepted first

@giuseppe giuseppe force-pushed the logging-passthrough branch 3 times, most recently from df7aae1 to bead1cd Compare September 2, 2021 09:45
@alexlarsson
Copy link
Contributor

Ok, I played with this by launching podman with the passthrough log driver from a systemd service, and it works just like I expected. For example, it properly picks up the syslog identifiers set by the systemd unit, and the individual journal entries are tagged with the correct pid, cmdline and exe (i.e. not everything looks like it came from conmon).

The one issue I have is that the systemd journal connection has a system_u:system_r:init_t:s0 selinux context and the container is running in system_u:system_r:container_runtime_t:s0, so I'm getting AVC denied when writing to the journal breaking selinux enforcing mode. I wonder what is the best way to handle this. @rhatdan opinions?

@alexlarsson
Copy link
Contributor

alexlarsson commented Sep 3, 2021

These are the AVCs i get:

   type=AVC msg=audit(1630657057.309:47775): avc:  denied  { ioctl } for  pid=1312362 comm="bash" path="socket:[7069215]" dev="sockfs" ino=7069215 ioctlcmd=0x540f scontext=system_u:system_r:container_t:s0:c139,c179 tcontext=system_u:system_r:init_t:s0 tclass=unix_stream_socket permissive=1
   type=AVC msg=audit(1630657057.319:47776): avc:  denied  { getattr } for  pid=1312362 comm="autobus.py" path="socket:[7069215]" dev="sockfs" ino=7069215 scontext=system_u:system_r:container_t:s0:c139,c179 tcontext=system_u:system_r:init_t:s0 tclass=unix_stream_socket permissive=1

@rhatdan
Copy link
Member

rhatdan commented Sep 4, 2021

This should be fixed in container-selinux.

@rhatdan
Copy link
Member

rhatdan commented Sep 4, 2021

Looks like this is allowed in current container-selinux.

container-selinux-2.167

$ audit2allow -i /tmp/t

#============= container_t ==============

#!!!! This avc is allowed in the current policy
allow container_t init_t:unix_stream_socket getattr;

@alexlarsson
Copy link
Contributor

Ok. I'm only on container-selinux-2.164.2-1.fc34 atm.

@rhatdan
Copy link
Member

rhatdan commented Sep 7, 2021

@alexlarsson Have you updated to the latest container-selinux to the latest version to make sure it works.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 19, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 20, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 23, 2021
it allows to pass the current std streams down to the container.

conmon support: containers/conmon#289

[NO TESTS NEEDED] it needs a new conmon.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2021
@giuseppe giuseppe marked this pull request as ready for review September 29, 2021 15:02
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 29, 2021
@giuseppe
Copy link
Member Author

this is ready

@Luap99
Copy link
Member

Luap99 commented Sep 29, 2021

Can you add a test?

@giuseppe
Copy link
Member Author

the issue is that it needs a new conmon which is not available in the CI

@rhatdan
Copy link
Member

rhatdan commented Sep 29, 2021

Lets get this in, and then add tests when the new conmon is ready. Then the people who need this IE @alexlarsson can start playing with it now, and see if there are any issues.
LGTM

@TomSweeneyRedHat
Copy link
Member

LGTM

@TomSweeneyRedHat
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 29, 2021
@openshift-merge-robot openshift-merge-robot merged commit b187dfe into containers:main Sep 29, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants