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

feat: Added net.ipv4.tcp_rmem and net.ipv4.tcp_wmem into safe sysctl list #125270

Closed
wants to merge 4 commits into from

Conversation

nikzayn
Copy link
Contributor

@nikzayn nikzayn commented Jun 1, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds the net.ipv4.tcp_rmem and net.ipv4.tcp_wmem into safe sysctl list because to handle thousands of concurrent connections used by Cassandra, DataStax recommends these settings to optimize the Linux network stack.

Which issue(s) this PR fixes:

#125234

Fixes #125234

Special notes for your reviewer:

I have updated the test cases and it's running fine. Meanwhile, you can check and comment on this PR to suggest some other changes which I might need to update. One callout, I think that I also need to update the CheckSysctls function to support checks for the allowed sysctl list.

Does this PR introduce a user-facing change?

NONE

…list kubernetes#125234

Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>
@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/kubelet labels Jun 1, 2024
@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 1, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @nikzayn. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@@ -60,6 +60,12 @@ var safeSysctls = []sysctl{
name: "net.ipv4.tcp_keepalive_probes",
kernel: utilkernel.TCPKeepAliveProbesNamespacedKernelVersion,
},
{
name: "net.ipv4.tcp_rmem",
Copy link
Member

Choose a reason for hiding this comment

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

I believe these sysctls are supported starting from kernel 4.15. Can you add a constant to utilkernel and set the kernel property here, like the other entries above? Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

utilkernel will look something like this

// TCPReceiveMemoryNamespacedKernelVersion is the kernel version in which net.ipv4.tcp_rmem was namespaced(netns).
// (ref: https://github.com/torvalds/linux/commit/356d1833b638bd465672aefeb71def3ab93fc17d)
const TCPReceiveMemoryNamespacedKernelVersion = "4.15"

// TCPTransmitMemoryNamespacedKernelVersion is the kernel version in which net.ipv4.tcp_wmem was namespaced(netns).
// (ref: https://github.com/torvalds/linux/commit/356d1833b638bd465672aefeb71def3ab93fc17d)
const TCPTransmitMemoryNamespacedKernelVersion = "4.15"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will add it. I know that we need to add it just wanted to be confirmed. Thanks!

@mauri870
Copy link
Member

mauri870 commented Jun 1, 2024

Perhaps this also requires changes in staging/src/k8s.io/pod-security-admission/policy/check_sysctls.go?

@nikzayn
Copy link
Contributor Author

nikzayn commented Jun 1, 2024

Perhaps this also requires changes in staging/src/k8s.io/pod-security-admission/policy/check_sysctls.go?

Thanks, I will take a look and possibly make the changes accordingly. Thanks for reviewing.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/auth Categorizes an issue or PR as relevant to SIG Auth. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 1, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nikzayn
Once this PR has been reviewed and has the lgtm label, please assign derekwaynecarr, liggitt for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 1, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 1, 2024
@k8s-ci-robot
Copy link
Contributor

Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

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-sigs/prow repository.

@@ -118,6 +124,10 @@ func sysctlsV1Dot29(podMetadata *metav1.ObjectMeta, podSpec *corev1.PodSpec) Che
return sysctls(podMetadata, podSpec, sysctlsAllowedV1Dot29)
}

func sysctlsV1Dot30(podMetadata *metav1.ObjectMeta, podSpec *corev1.PodSpec) CheckResult {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not 100% sure this is correct/needed, I'd like a more experienced reviewer to confirm it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let's wait for an experienced member. Even I also have doubt for the same.

},
}
registerFixtureGenerator(
fixtureKey{level: api.LevelBaseline, version: api.MajorMinorVersion(1, 29), check: "sysctls"},
Copy link
Member

Choose a reason for hiding this comment

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

Given that you are using the V1Dot30 suffix this should be 1, 30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh okay, thanks my bad!!. Fixing it right away

Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>
@SataQiu
Copy link
Member

SataQiu commented Jun 17, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 17, 2024
@ritazh
Copy link
Member

ritazh commented Jun 17, 2024

/assign @enj

@ritazh
Copy link
Member

ritazh commented Jun 17, 2024

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 17, 2024
@ritazh
Copy link
Member

ritazh commented Jun 17, 2024

/sig network
/cc @thockin

@k8s-ci-robot k8s-ci-robot requested a review from thockin June 17, 2024 16:30
@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Jun 17, 2024
@thockin
Copy link
Member

thockin commented Jun 17, 2024

This seems fine to me, but I don't know this code path, so I really want someone on sig-node to own the approval.

@pacoxu ?

Copy link
Member

@pacoxu pacoxu left a comment

Choose a reason for hiding this comment

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

This is target to v1.31 and like #118846 the test data needs some update.

@@ -104,6 +106,10 @@ var (
"net.ipv4.tcp_keepalive_intvl",
"net.ipv4.tcp_keepalive_probes",
)
sysctlsAllowedV1Dot30 = sets.NewString(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sysctlsAllowedV1Dot30 = sets.NewString(
sysctlsAllowedV1Dot31 = sets.NewString(

Comment on lines +127 to +128
func sysctlsV1Dot30(podMetadata *metav1.ObjectMeta, podSpec *corev1.PodSpec) CheckResult {
return sysctls(podMetadata, podSpec, sysctlsAllowedV1Dot30)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func sysctlsV1Dot30(podMetadata *metav1.ObjectMeta, podSpec *corev1.PodSpec) CheckResult {
return sysctls(podMetadata, podSpec, sysctlsAllowedV1Dot30)
func sysctlsV1Dot31(podMetadata *metav1.ObjectMeta, podSpec *corev1.PodSpec) CheckResult {
return sysctls(podMetadata, podSpec, sysctlsAllowedV1Dot31)


for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
result := sysctlsV1Dot30(&tc.pod.ObjectMeta, &tc.pod.Spec)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
result := sysctlsV1Dot30(&tc.pod.ObjectMeta, &tc.pod.Spec)
result := sysctlsV1Dot31(&tc.pod.ObjectMeta, &tc.pod.Spec)

@@ -156,4 +156,39 @@ func init() {
fixtureKey{level: api.LevelBaseline, version: api.MajorMinorVersion(1, 29), check: "sysctls"},
fixtureDataV1Dot29,
)

fixtureDataV1Dot30 := fixtureGenerator{
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fixtureDataV1Dot30 := fixtureGenerator{
fixtureDataV1Dot31 := fixtureGenerator{

Update other references accordingly.

},
}
registerFixtureGenerator(
fixtureKey{level: api.LevelBaseline, version: api.MajorMinorVersion(1, 30), check: "sysctls"},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fixtureKey{level: api.LevelBaseline, version: api.MajorMinorVersion(1, 30), check: "sysctls"},
fixtureKey{level: api.LevelBaseline, version: api.MajorMinorVersion(1, 31), check: "sysctls"},

@mauri870
Copy link
Member

Thanks for working on this!

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 17, 2024
@thockin
Copy link
Member

thockin commented Sep 18, 2024

Is this PR abandoned? Does it need someone to take it over?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 12, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

@pacoxu
Copy link
Member

pacoxu commented Oct 12, 2024

#127489 is based on @nikzayn's commits here and was merged today.

/close

@k8s-ci-robot
Copy link
Contributor

@pacoxu: Closed this PR.

In response to this:

#127489 is based on @nikzayn's commits here and was merged today.

/close

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-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add net.ipv4.tcp_rmem and net.ipv4.tcp_wmem into safe sysctl list
9 participants