Skip to content

Commit 4c65275

Browse files
committed
pkg/kubelet/userns: Provide stub implementation for windows
Signed-off-by: Rodrigo Campos <[email protected]>
1 parent 156c80a commit 4c65275

File tree

6 files changed

+91
-8
lines changed

6 files changed

+91
-8
lines changed

pkg/kubelet/userns/types.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package userns
18+
19+
import "k8s.io/apimachinery/pkg/types"
20+
21+
// Here go types that are common for all supported OS (windows, linux).
22+
23+
type userNsPodsManager interface {
24+
HandlerSupportsUserNamespaces(runtimeHandler string) (bool, error)
25+
GetPodDir(podUID types.UID) string
26+
ListPodsFromDisk() ([]types.UID, error)
27+
GetKubeletMappings() (uint32, uint32, error)
28+
GetMaxPods() int
29+
}

pkg/kubelet/userns/userns_manager.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build !windows
2+
// +build !windows
3+
14
/*
25
Copyright 2022 The Kubernetes Authors.
36
@@ -43,14 +46,6 @@ const userNsLength = (1 << 16)
4346
// since Go maps never free memory.
4447
const mapReInitializeThreshold = 1000
4548

46-
type userNsPodsManager interface {
47-
HandlerSupportsUserNamespaces(runtimeHandler string) (bool, error)
48-
GetPodDir(podUID types.UID) string
49-
ListPodsFromDisk() ([]types.UID, error)
50-
GetKubeletMappings() (uint32, uint32, error)
51-
GetMaxPods() int
52-
}
53-
5449
type UsernsManager struct {
5550
used *allocator.AllocationBitmap
5651
usedBy map[types.UID]uint32 // Map pod.UID to range used

pkg/kubelet/userns/userns_manager_disabled_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build !windows
2+
// +build !windows
3+
14
/*
25
Copyright 2022 The Kubernetes Authors.
36

pkg/kubelet/userns/userns_manager_switch_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build !windows
2+
// +build !windows
3+
14
/*
25
Copyright 2024 The Kubernetes Authors.
36

pkg/kubelet/userns/userns_manager_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build !windows
2+
// +build !windows
3+
14
/*
25
Copyright 2022 The Kubernetes Authors.
36
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package userns
18+
19+
import (
20+
v1 "k8s.io/api/core/v1"
21+
"k8s.io/apimachinery/pkg/types"
22+
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
23+
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
24+
)
25+
26+
type UsernsManager struct{}
27+
28+
func MakeUserNsManager(kl userNsPodsManager) (*UsernsManager, error) {
29+
return nil, nil
30+
}
31+
32+
// Release releases the user namespace allocated to the specified pod.
33+
func (m *UsernsManager) Release(podUID types.UID) {
34+
return
35+
}
36+
37+
func (m *UsernsManager) GetOrCreateUserNamespaceMappings(pod *v1.Pod, runtimeHandler string) (*runtimeapi.UserNamespace, error) {
38+
return nil, nil
39+
}
40+
41+
// CleanupOrphanedPodUsernsAllocations reconciliates the state of user namespace
42+
// allocations with the pods actually running. It frees any user namespace
43+
// allocation for orphaned pods.
44+
func (m *UsernsManager) CleanupOrphanedPodUsernsAllocations(pods []*v1.Pod, runningPods []*kubecontainer.Pod) error {
45+
return nil
46+
}
47+
48+
func EnabledUserNamespacesSupport() bool {
49+
return false
50+
}

0 commit comments

Comments
 (0)