Merge pull request #105465 from marosset/remove-host-process-contianer-kubelet-annotations

Stop passing WindowsHostProcessContainer annotations for CRI calls in kubelet
This commit is contained in:
Kubernetes Prow Robot 2021-10-18 15:50:02 -07:00 committed by GitHub
commit 1af8a8c026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,17 +18,13 @@ package kuberuntime
import (
"encoding/json"
"runtime"
"strconv"
v1 "k8s.io/api/core/v1"
kubetypes "k8s.io/apimachinery/pkg/types"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/features"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/types"
sc "k8s.io/kubernetes/pkg/securitycontext"
)
const (
@ -42,12 +38,6 @@ const (
containerTerminationMessagePolicyLabel = "io.kubernetes.container.terminationMessagePolicy"
containerPreStopHandlerLabel = "io.kubernetes.container.preStopHandler"
containerPortsLabel = "io.kubernetes.container.ports"
// TODO: remove this annotation when moving to beta for Windows hostprocess containers
// xref: https://github.com/kubernetes/kubernetes/pull/99576/commits/42fb66073214eed6fe43fa8b1586f396e30e73e3#r635392090
// Currently, ContainerD on Windows does not yet fully support HostProcess containers
// but will pass annotations to hcsshim which does have support.
windowsHostProcessContainer = "microsoft.com/hostprocess-container"
)
type labeledPodSandboxInfo struct {
@ -99,23 +89,7 @@ func newPodLabels(pod *v1.Pod) map[string]string {
// newPodAnnotations creates pod annotations from v1.Pod.
func newPodAnnotations(pod *v1.Pod) map[string]string {
annotations := map[string]string{}
// Get annotations from v1.Pod
for k, v := range pod.Annotations {
annotations[k] = v
}
if runtime.GOOS == "windows" && utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers) {
if kubecontainer.HasWindowsHostProcessContainer(pod) {
// While WindowsHostProcessContainers is in alpha pass 'microsoft.com/hostprocess-container' annotation
// to pod sandbox creations request. ContainerD on Windows does not yet fully support HostProcess
// containers but will pass annotations to hcsshim which does have support.
annotations[windowsHostProcessContainer] = "true"
}
}
return annotations
return pod.Annotations
}
// newContainerLabels creates container labels from v1.Container and v1.Pod.
@ -169,15 +143,6 @@ func newContainerAnnotations(container *v1.Container, pod *v1.Pod, restartCount
}
}
if runtime.GOOS == "windows" && utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers) {
if sc.HasWindowsHostProcessRequest(pod, container) {
// While WindowsHostProcessContainers is in alpha pass 'microsoft.com/hostprocess-container' annotation
// to create containers request. ContainerD on Windows does not yet fully support HostProcess containers
// but will pass annotations to hcsshim which does have support.
annotations[windowsHostProcessContainer] = "true"
}
}
return annotations
}