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

system service: unset listen fds on tcp #19196

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

vrothberg
Copy link
Member

@vrothberg vrothberg commented Jul 11, 2023

Disable leaking the LISTEN_* variables into containers which are
observed to be passed by systemd even without being socket activated as
described in https://access.redhat.com/solutions/6512011.

[NO NEW TESTS NEEDED] - Ultimately, the solution 6512011 should be updated.

Fixes: bugzilla.redhat.com/show_bug.cgi?id=2180483

@Luap99 PTAL. test/e2e/systemd_activate_test.go does not set LISTEN_FDS, so there's no test I can plug into.

Does this PR introduce a user-facing change?

Fix an issue in `system service` when listing on TCP and LISTEN_FDS are set.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 11, 2023
@Luap99
Copy link
Member

Luap99 commented Jul 11, 2023

Why only for tcp? We should unset all three LISTEN_ envs after this block for everything, there is no reason to leak them ever into the container when started via service.

I still would like to understand why tcp misbehaves in that case?

@Luap99
Copy link
Member

Luap99 commented Jul 11, 2023

LISTEN_FDS are usually not passed but I suspect in the BZ it's happening as a systemd.socket with the same name exists; even if not triggered via the socket

This sounds like a systemd bug to me.

@vrothberg
Copy link
Member Author

Why only for tcp? We should unset all three LISTEN_ envs after this block for everything, there is no reason to leak them ever into the container when started via service.

That is a good idea.

I still would like to understand why tcp misbehaves in that case?

I also smell a systemd bug.

@vrothberg
Copy link
Member Author

vrothberg commented Jul 11, 2023

I also smell a systemd bug.

Ah well. I don't think so anymore. It does not happen when socket isn't active. For that to happen, it must 1) be removed from the service dependencies and 2) be stopped.

@Luap99
Copy link
Member

Luap99 commented Jul 11, 2023

Agreed I think systemd is behaving as documented here. The .service unit has a implicit dependency on the socket. So if you start the service it will automatically trigger the socket unit and pass the fds down.

Socket activated services are automatically ordered after their activating .socket units via an automatic After= dependency. Services also pull in all .socket units listed in Sockets= via automatic Wants= and After= dependencies.

I think this patch to unset the env is correct but I still do not understand why that is causing issues with dropping tcp packets.

Disable leaking the LISTEN_* variables into containers which are
observed to be passed by systemd even without being socket activated as
described in https://access.redhat.com/solutions/6512011.

[NO NEW TESTS NEEDED] - Ultimately, the solution 6512011 should be updated.

Fixes: bugzilla.redhat.com/show_bug.cgi?id=2180483
Signed-off-by: Valentin Rothberg <[email protected]>
@vrothberg
Copy link
Member Author

I think this patch to unset the env is correct but I still do not understand why that is causing issues with dropping tcp packets.

That is indeed puzzling.

@vrothberg vrothberg marked this pull request as ready for review July 12, 2023 07:25
@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 Jul 12, 2023
@vrothberg
Copy link
Member Author

Good to go from my end. Apologies, I did not manage to reproduce the issues outside this very specific scenario of manually editing the installed .service.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@vrothberg
Copy link
Member Author

@flouthoc PTAL

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM
/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 12, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, Luap99, vrothberg

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:
  • OWNERS [Luap99,flouthoc,vrothberg]

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

@openshift-merge-robot openshift-merge-robot merged commit d3ac265 into containers:main Jul 12, 2023
@vrothberg vrothberg deleted the bz-2180483 branch July 12, 2023 09:16
@vrothberg
Copy link
Member Author

/cherry-pick v4.6

@openshift-cherrypick-robot
Copy link
Collaborator

@vrothberg: new pull request created: #19205

In response to this:

/cherry-pick v4.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@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 Oct 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants