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

Fixing issue in generatePodSandboxWindowsConfig for hostProcess containers #110140

Merged
merged 1 commit into from Jun 28, 2022

Conversation

marosset
Copy link
Contributor

@marosset marosset commented May 19, 2022

Signed-off-by: Mark Rossetti marosset@microsoft.com

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fixing issue in generatePodSandboxWindowsConfig for hostProcess containers by
where pod sandbox won't have HostProcess bit set if pod does not have a
security context but containers specify HostProcess.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixing issue on Windows nodes where HostProcess containers may not be created as expected.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

KEP: https://github.com/kubernetes/enhancements/tree/master/keps/sig-windows/1981-windows-privileged-container-support

/sig windows node

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/windows Categorizes an issue or PR as relevant to SIG Windows. sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. area/kubelet labels May 19, 2022
@marosset
Copy link
Contributor Author

marosset commented May 19, 2022

Prior to this change the following podSpec is expected have containers run as host-process containers but instead fails because the pod sandbox wasn't configured to support running HostProcess containers.

apiVersion: v1
kind: Pod
metadata:
  name: container-sc
spec:
  hostNetwork: true
  containers:
    - name: ping-test
      securityContext:
        windowsOptions:
          hostProcess: true
          runAsUserName: "NT AUTHORITY\\SYSTEM"
      image: mcr.microsoft.com/windows/nanoserver:1809
      command:
        - "ping"
        - "-t"
        - "127.0.0.1"
  nodeSelector:
    "kubernetes.io/os": windows

This is called out in the KEP https://github.com/kubernetes/enhancements/tree/master/keps/sig-windows/1981-windows-privileged-container-support#example-deployment-spec

@marosset
Copy link
Contributor Author

/assign @dcantah @jsturtevant for windows review

@marosset
Copy link
Contributor Author

/triage accepted
/priority important-soon

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed 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. labels May 20, 2022
@marosset marosset added this to In Review (v1.25) in SIG-Windows May 20, 2022
@dcantah
Copy link
Member

dcantah commented May 26, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2022
Copy link
Contributor

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

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

couple minor comments. Having the check if kubecontainer.HasWindowsHostProcessContainer(pod) twice in the same function is a bit confusing though I see why it is done and how it was missed initially. Seems there could be clean up to make that easier to read but that shouldn't be done in this.

Can you add a release note? This seems like something that should be called out a bug fix in the release notes

pkg/kubelet/container/helpers_test.go Outdated Show resolved Hide resolved
pkg/kubelet/container/helpers_test.go Show resolved Hide resolved
@jsturtevant
Copy link
Contributor

/test pull-kubernetes-e2e-capz-windows-containerd

…iners by

where pod sandbox won't have HostProcess bit set if pod does not have a
security context but containers specify HostProcess.

Signed-off-by: Mark Rossetti <marosset@microsoft.com>
@marosset
Copy link
Contributor Author

marosset commented Jun 2, 2022

/retest

@jsturtevant
Copy link
Contributor

/test pull-kubernetes-e2e-capz-windows-containerd
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 8, 2022
@jsturtevant
Copy link
Contributor

/test pull-kubernetes-e2e-capz-windows-containerd

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jun 8, 2022
@marosset
Copy link
Contributor Author

marosset commented Jun 8, 2022

/assign @sjenning @mrunalp

@marosset marosset moved this from In Review (v1.25) to Reviewed - Needs Approval From Other SIGs in SIG-Windows Jun 13, 2022
@marosset
Copy link
Contributor Author

/milestone v1.25

@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Jun 13, 2022
@SergeyKanzhelev SergeyKanzhelev moved this from Triage to Needs Approver in SIG Node PR Triage Jun 14, 2022
// Pods containing HostProcess containers should fail to schedule if feature is not
// enabled instead of trying to schedule containers as regular containers as stated in
// PRR review.
if !utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers) {
Copy link
Member

Choose a reason for hiding this comment

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

since it's breaking the previous behavior, this may break some customers on upgrade. Is there a possibility customer marked container as hostprocess and forgot to clean it up after?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The situation where behavior should be changing is when users set hostProcess=true for only the containers,
before this change the containers will start as normal containers, after the changes the containers will be started as hostProcess containers.

The expected behavior and behavior outlined in the KEP is that the container should be started as a hostProcess container.

We've had several people report this issue recently (including https://kubernetes.slack.com/archives/C0SJ4AFB7/p1652916420701559?thread_ts=1652890944.995179&cid=C0SJ4AFB7)

Copy link
Member

Choose a reason for hiding this comment

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

talked offline. Seems like an edge case when things may break for users. Unless Im'm missing something this is not blocking the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

If a customer thinks they are running in a Hostprocess pod but aren't, due to the limitations of process isolated containers, this will likely lead to functionality in the pod to not work in other ways leading them to see this as a bug. We have seen folks come to the sig-windows slack when this occurs.

An an example the promtheus windows_exporter, it technically runs inside a process isolated windows container but all the stats it collects are wildly off and in some cases like querying for containers just don't work.

I would anticipate this would be the same for most of the use cases we envisioned where customers are modifing the host registry or interacting with host services.

@jsturtevant
Copy link
Contributor

/assign @dchen1107

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marosset, mrunalp

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 27, 2022
@mrunalp mrunalp moved this from Needs Approver to Done in SIG Node PR Triage Jun 27, 2022
@k8s-triage-robot
Copy link

The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass.

This bot retests PRs for certain kubernetes repos according to the following rules:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@k8s-ci-robot k8s-ci-robot merged commit 10bea49 into kubernetes:master Jun 28, 2022
SIG-Windows automation moved this from Reviewed - Needs Approval From Other SIGs to Done (v1.25) Jun 28, 2022
@marosset marosset deleted the hpc-sandbox-config-fixes branch July 6, 2022 16:38
k8s-ci-robot added a commit that referenced this pull request Aug 10, 2022
…0140-upstream-release-1.24

Automated cherry pick of #110140: Fixing issue in generatePodSandboxWindowsConfig for
k8s-ci-robot added a commit that referenced this pull request Aug 10, 2022
…0140-upstream-release-1.23

Automated cherry pick of #110140: Fixing issue in generatePodSandboxWindowsConfig for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/windows Categorizes an issue or PR as relevant to SIG Windows. 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
SIG-Windows
  
Done (v1.25)
Development

Successfully merging this pull request may close these issues.

None yet

9 participants