Skip to content

Commit fc3abda

Browse files
authored
Merge pull request kubernetes#125470 from everpeace/kep-3619-SupplementalGroupsPolicy-e2e
KEP-3619: Add NodeStatus.Features.SupplementalGroupsPolicy API and e2e
2 parents 9c763a9 + 1663223 commit fc3abda

File tree

30 files changed

+2568
-1611
lines changed

30 files changed

+2568
-1611
lines changed

api/openapi-spec/swagger.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/api__v1_openapi.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3741,6 +3741,16 @@
37413741
},
37423742
"type": "object"
37433743
},
3744+
"io.k8s.api.core.v1.NodeFeatures": {
3745+
"description": "NodeFeatures describes the set of features implemented by the CRI implementation. The features contained in the NodeFeatures should depend only on the cri implementation independent of runtime handlers.",
3746+
"properties": {
3747+
"supplementalGroupsPolicy": {
3748+
"description": "SupplementalGroupsPolicy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.",
3749+
"type": "boolean"
3750+
}
3751+
},
3752+
"type": "object"
3753+
},
37443754
"io.k8s.api.core.v1.NodeList": {
37453755
"description": "NodeList is the whole list of all Nodes which have been registered with master.",
37463756
"properties": {
@@ -3806,7 +3816,7 @@
38063816
"type": "object"
38073817
},
38083818
"io.k8s.api.core.v1.NodeRuntimeHandlerFeatures": {
3809-
"description": "NodeRuntimeHandlerFeatures is a set of runtime features.",
3819+
"description": "NodeRuntimeHandlerFeatures is a set of features implemented by the runtime handler.",
38103820
"properties": {
38113821
"recursiveReadOnlyMounts": {
38123822
"description": "RecursiveReadOnlyMounts is set to true if the runtime handler supports RecursiveReadOnlyMounts.",
@@ -4027,6 +4037,14 @@
40274037
"default": {},
40284038
"description": "Endpoints of daemons running on the Node."
40294039
},
4040+
"features": {
4041+
"allOf": [
4042+
{
4043+
"$ref": "#/components/schemas/io.k8s.api.core.v1.NodeFeatures"
4044+
}
4045+
],
4046+
"description": "Features describes the set of features implemented by the CRI implementation."
4047+
},
40304048
"images": {
40314049
"description": "List of container images on this node",
40324050
"items": {

pkg/apis/core/types.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4892,7 +4892,7 @@ type NodeDaemonEndpoints struct {
48924892
KubeletEndpoint DaemonEndpoint
48934893
}
48944894

4895-
// NodeRuntimeHandlerFeatures is a set of runtime features.
4895+
// NodeRuntimeHandlerFeatures is a set of features implemented by the runtime handler.
48964896
type NodeRuntimeHandlerFeatures struct {
48974897
// RecursiveReadOnlyMounts is set to true if the runtime handler supports RecursiveReadOnlyMounts.
48984898
// +featureGate=RecursiveReadOnlyMounts
@@ -4915,6 +4915,15 @@ type NodeRuntimeHandler struct {
49154915
Features *NodeRuntimeHandlerFeatures
49164916
}
49174917

4918+
// NodeFeatures describes the set of features implemented by the CRI implementation.
4919+
// The features contained in the NodeFeatures should depend only on the cri implementation
4920+
// independent of runtime handlers.
4921+
type NodeFeatures struct {
4922+
// SupplementalGroupsPolicy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.
4923+
// +optional
4924+
SupplementalGroupsPolicy *bool
4925+
}
4926+
49184927
// NodeSystemInfo is a set of ids/uuids to uniquely identify the node.
49194928
type NodeSystemInfo struct {
49204929
// MachineID reported by the node. For unique machine identification
@@ -5030,6 +5039,10 @@ type NodeStatus struct {
50305039
// +featureGate=UserNamespacesSupport
50315040
// +optional
50325041
RuntimeHandlers []NodeRuntimeHandler
5042+
// Features describes the set of features implemented by the CRI implementation.
5043+
// +featureGate=SupplementalGroupsPolicy
5044+
// +optional
5045+
Features *NodeFeatures
50335046
}
50345047

50355048
// UniqueVolumeName defines the name of attached volume

pkg/apis/core/v1/zz_generated.conversion.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/core/zz_generated.deepcopy.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/kubelet/container/runtime.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ type RuntimeStatus struct {
556556
Conditions []RuntimeCondition
557557
// Handlers is an array of current available handlers
558558
Handlers []RuntimeHandler
559+
// Features is the set of features implemented by the runtime
560+
Features *RuntimeFeatures
559561
}
560562

561563
// GetRuntimeCondition gets a specified runtime condition from the runtime status.
@@ -579,7 +581,7 @@ func (r *RuntimeStatus) String() string {
579581
for _, h := range r.Handlers {
580582
sh = append(sh, h.String())
581583
}
582-
return fmt.Sprintf("Runtime Conditions: %s; Handlers: %s", strings.Join(ss, ", "), strings.Join(sh, ", "))
584+
return fmt.Sprintf("Runtime Conditions: %s; Handlers: %s, Features: %s", strings.Join(ss, ", "), strings.Join(sh, ", "), r.Features.String())
583585
}
584586

585587
// RuntimeHandler contains condition information for the runtime handler.
@@ -617,6 +619,19 @@ func (c *RuntimeCondition) String() string {
617619
return fmt.Sprintf("%s=%t reason:%s message:%s", c.Type, c.Status, c.Reason, c.Message)
618620
}
619621

622+
// RuntimeFeatures contains the set of features implemented by the runtime
623+
type RuntimeFeatures struct {
624+
SupplementalGroupsPolicy bool
625+
}
626+
627+
// String formats the runtime condition into a human readable string.
628+
func (f *RuntimeFeatures) String() string {
629+
if f == nil {
630+
return "nil"
631+
}
632+
return fmt.Sprintf("SupplementalGroupsPolicy: %v", f.SupplementalGroupsPolicy)
633+
}
634+
620635
// Pods represents the list of pods
621636
type Pods []*Pod
622637

pkg/kubelet/kubelet.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,6 +2892,7 @@ func (kl *Kubelet) updateRuntimeUp() {
28922892

28932893
kl.runtimeState.setRuntimeState(nil)
28942894
kl.runtimeState.setRuntimeHandlers(s.Handlers)
2895+
kl.runtimeState.setRuntimeFeatures(s.Features)
28952896
kl.oneTimeInitializer.Do(kl.initializeRuntimeDependentModules)
28962897
kl.runtimeState.setRuntimeSync(kl.clock.Now())
28972898
}

pkg/kubelet/kubelet_node_status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(context.Context, *v1.Node) er
737737
nodestatus.Images(kl.nodeStatusMaxImages, kl.imageManager.GetImageList),
738738
nodestatus.GoRuntime(),
739739
nodestatus.RuntimeHandlers(kl.runtimeState.runtimeHandlers),
740+
nodestatus.NodeFeatures(kl.runtimeState.runtimeFeatures),
740741
)
741742

742743
setters = append(setters,

pkg/kubelet/kuberuntime/helpers.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func parsePodUIDFromLogsDirectory(name string) types.UID {
208208
}
209209

210210
// toKubeRuntimeStatus converts the runtimeapi.RuntimeStatus to kubecontainer.RuntimeStatus.
211-
func toKubeRuntimeStatus(status *runtimeapi.RuntimeStatus, handlers []*runtimeapi.RuntimeHandler) *kubecontainer.RuntimeStatus {
211+
func toKubeRuntimeStatus(status *runtimeapi.RuntimeStatus, handlers []*runtimeapi.RuntimeHandler, features *runtimeapi.RuntimeFeatures) *kubecontainer.RuntimeStatus {
212212
conditions := []kubecontainer.RuntimeCondition{}
213213
for _, c := range status.GetConditions() {
214214
conditions = append(conditions, kubecontainer.RuntimeCondition{
@@ -232,7 +232,13 @@ func toKubeRuntimeStatus(status *runtimeapi.RuntimeStatus, handlers []*runtimeap
232232
SupportsUserNamespaces: supportsUserns,
233233
}
234234
}
235-
return &kubecontainer.RuntimeStatus{Conditions: conditions, Handlers: retHandlers}
235+
var retFeatures *kubecontainer.RuntimeFeatures
236+
if features != nil {
237+
retFeatures = &kubecontainer.RuntimeFeatures{
238+
SupplementalGroupsPolicy: features.SupplementalGroupsPolicy,
239+
}
240+
}
241+
return &kubecontainer.RuntimeStatus{Conditions: conditions, Handlers: retHandlers, Features: retFeatures}
236242
}
237243

238244
func fieldSeccompProfile(scmp *v1.SeccompProfile, profileRootPath string, fallbackToRuntimeDefault bool) (*runtimeapi.SecurityProfile, error) {

0 commit comments

Comments
 (0)