Skip to content

OCPBUGS-57887: Update to Kubernetes v1.31.10 #2348

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

Open
wants to merge 20 commits into
base: release-4.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
16dd861
Update CHANGELOG/CHANGELOG-1.31.md for v1.31.9
k8s-release-robot May 15, 2025
e983d3f
userns: Use len to handle empty non-nil slices
rata May 6, 2025
c0eb9e3
userns: Improve error returned if userns is not supported
rata May 6, 2025
e885986
userns: Wrap more errors
rata May 6, 2025
c88aef2
Revert "Switch hard error to a WARNING for kernel version check"
rata Feb 18, 2025
1e53e59
Revert "Enforce the Minimum Kernel Version 6.3 for UserNamespacesSupp…
rata Feb 18, 2025
156c80a
pkg/kubelet: Fix userns tests on Windows
rata Mar 13, 2025
4c65275
pkg/kubelet/userns: Provide stub implementation for windows
rata Mar 13, 2025
2e0622b
pkg/kubelet/userns: Wrap error to get mappings
rata Mar 13, 2025
c9dbae7
pkg/kubelet/userns: Remove skip on windows
rata Mar 13, 2025
d67d7ed
Bump images, dependencies and versions to go 1.23.9 and distroless ip…
cpanato May 23, 2025
ec21688
Merge pull request #131937 from cpanato/update-go-1.31
k8s-ci-robot May 26, 2025
a44b0a3
Merge pull request #131787 from rata/automated-cherry-pick-of-#130800…
k8s-ci-robot Jun 4, 2025
b62290a
Merge pull request #131783 from rata/automated-cherry-pick-of-#131623…
k8s-ci-robot Jun 5, 2025
756c2db
Merge pull request #131785 from rata/automated-cherry-pick-of-#130243…
k8s-ci-robot Jun 5, 2025
262df1a
Bump images, dependencies and versions to go 1.23.10 and distroless i…
cpanato Jun 11, 2025
7ae3874
Merge pull request #132224 from cpanato/update-go-1-31
k8s-ci-robot Jun 13, 2025
6118358
Release commit for Kubernetes v1.31.10
k8s-release-robot Jun 17, 2025
7d545b2
Merge tag 'v1.31.10' into bump-1.31.10
atiratree Jun 26, 2025
c0e6777
UPSTREAM: <drop>: hack/update-vendor.sh, make update and update image
atiratree Jun 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.23.8
1.23.10
279 changes: 192 additions & 87 deletions CHANGELOG/CHANGELOG-1.31.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/build-image/cross/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.31.0-go1.23.8-bullseye.0
v1.31.0-go1.23.10-bullseye.0
4 changes: 2 additions & 2 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ readonly KUBE_RSYNC_PORT="${KUBE_RSYNC_PORT:-}"
readonly KUBE_CONTAINER_RSYNC_PORT=8730

# These are the default versions (image tags) for their respective base images.
readonly __default_distroless_iptables_version=v0.5.13
readonly __default_go_runner_version=v2.4.0-go1.23.8-bookworm.0
readonly __default_distroless_iptables_version=v0.6.11
readonly __default_go_runner_version=v2.4.0-go1.23.10-bookworm.0
readonly __default_setcap_version=bookworm-v1.0.3

# These are the base images for the Docker-wrapped binaries.
Expand Down
8 changes: 4 additions & 4 deletions build/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dependencies:

# Golang
- name: "golang: upstream version"
version: 1.23.8
version: 1.23.10
refPaths:
- path: .go-version
- path: build/build-image/cross/VERSION
Expand All @@ -139,7 +139,7 @@ dependencies:
# match: minimum_go_version=go([0-9]+\.[0-9]+)

- name: "registry.k8s.io/kube-cross: dependents"
version: v1.31.0-go1.23.8-bullseye.0
version: v1.31.0-go1.23.10-bullseye.0
refPaths:
- path: build/build-image/cross/VERSION

Expand Down Expand Up @@ -177,15 +177,15 @@ dependencies:
match: registry\.k8s\.io\/build-image\/debian-base:[a-zA-Z]+\-v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)

- name: "registry.k8s.io/distroless-iptables: dependents"
version: v0.5.13
version: v0.6.11
refPaths:
- path: build/common.sh
match: __default_distroless_iptables_version=
- path: test/utils/image/manifest.go
match: configs\[DistrolessIptables\] = Config{list\.BuildImageRegistry, "distroless-iptables", "v([0-9]+)\.([0-9]+)\.([0-9]+)"}

- name: "registry.k8s.io/go-runner: dependents"
version: v2.4.0-go1.23.8-bookworm.0
version: v2.4.0-go1.23.10-bookworm.0
refPaths:
- path: build/common.sh
match: __default_go_runner_version=
Expand Down
2 changes: 1 addition & 1 deletion openshift-hack/images/hyperkube/Dockerfile.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ COPY --from=builder /tmp/build/* /usr/bin/
LABEL io.k8s.display-name="OpenShift Kubernetes Server Commands" \
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \
io.openshift.tags="openshift,hyperkube" \
io.openshift.build.versions="kubernetes=1.31.9"
io.openshift.build.versions="kubernetes=1.31.10"
5 changes: 3 additions & 2 deletions pkg/kubelet/kubelet_getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ func (kl *Kubelet) ListPodsFromDisk() ([]types.UID, error) {
// user namespaces.
func (kl *Kubelet) HandlerSupportsUserNamespaces(rtHandler string) (bool, error) {
rtHandlers := kl.runtimeState.runtimeHandlers()
if rtHandlers == nil {
return false, fmt.Errorf("runtime handlers are not set")
if len(rtHandlers) == 0 {
// The slice is empty if the runtime is old and doesn't support this message.
return false, nil
}
for _, h := range rtHandlers {
if h.Name == rtHandler {
Expand Down
17 changes: 5 additions & 12 deletions pkg/kubelet/kubelet_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/version"
utilfeature "k8s.io/apiserver/pkg/util/feature"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
"k8s.io/klog/v2"
Expand All @@ -62,7 +61,6 @@ import (
"k8s.io/kubernetes/pkg/kubelet/status"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
utilfs "k8s.io/kubernetes/pkg/util/filesystem"
utilkernel "k8s.io/kubernetes/pkg/util/kernel"
utilpod "k8s.io/kubernetes/pkg/util/pod"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/hostutil"
Expand Down Expand Up @@ -131,16 +129,11 @@ func (kl *Kubelet) getKubeletMappings() (uint32, uint32, error) {

if !utilfeature.DefaultFeatureGate.Enabled(features.UserNamespacesSupport) {
return defaultFirstID, defaultLen, nil
} else {
kernelVersion, err := utilkernel.GetVersion()
if err != nil {
return 0, 0, fmt.Errorf("failed to get kernel version, unable to determine if feature %s can be supported : %w",
features.UserNamespacesSupport, err)
}
if kernelVersion != nil && !kernelVersion.AtLeast(version.MustParseGeneric(utilkernel.UserNamespacesSupportKernelVersion)) {
klog.InfoS("WARNING: the kernel version is incompatible with the feature gate, which needs as a minimum kernel version",
"kernelVersion", kernelVersion, "feature", features.UserNamespacesSupport, "minKernelVersion", utilkernel.UserNamespacesSupportKernelVersion)
}
}

// Windows doesn't support user namespaces, let's return the default mappings.
if runtime.GOOS == "windows" {
return defaultFirstID, defaultLen, nil
}

_, err := user.Lookup(kubeletUser)
Expand Down
29 changes: 29 additions & 0 deletions pkg/kubelet/userns/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package userns

import "k8s.io/apimachinery/pkg/types"

// Here go types that are common for all supported OS (windows, linux).

type userNsPodsManager interface {
HandlerSupportsUserNamespaces(runtimeHandler string) (bool, error)
GetPodDir(podUID types.UID) string
ListPodsFromDisk() ([]types.UID, error)
GetKubeletMappings() (uint32, uint32, error)
GetMaxPods() int
}
32 changes: 16 additions & 16 deletions pkg/kubelet/userns/userns_manager.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

/*
Copyright 2022 The Kubernetes Authors.

Expand Down Expand Up @@ -43,14 +46,6 @@ const userNsLength = (1 << 16)
// since Go maps never free memory.
const mapReInitializeThreshold = 1000

type userNsPodsManager interface {
HandlerSupportsUserNamespaces(runtimeHandler string) (bool, error)
GetPodDir(podUID types.UID) string
ListPodsFromDisk() ([]types.UID, error)
GetKubeletMappings() (uint32, uint32, error)
GetMaxPods() int
}

type UsernsManager struct {
used *allocator.AllocationBitmap
usedBy map[types.UID]uint32 // Map pod.UID to range used
Expand Down Expand Up @@ -132,7 +127,7 @@ func (m *UsernsManager) readMappingsFromFile(pod types.UID) ([]byte, error) {
func MakeUserNsManager(kl userNsPodsManager) (*UsernsManager, error) {
kubeletMappingID, kubeletMappingLen, err := kl.GetKubeletMappings()
if err != nil {
return nil, err
return nil, fmt.Errorf("kubelet mappings: %w", err)
}

if kubeletMappingID%userNsLength != 0 {
Expand Down Expand Up @@ -411,10 +406,15 @@ func (m *UsernsManager) GetOrCreateUserNamespaceMappings(pod *v1.Pod, runtimeHan
// From here onwards, hostUsers=false and the feature gate is enabled.

// if the pod requested a user namespace and the runtime doesn't support user namespaces then return an error.
if handlerSupportsUserns, err := m.kl.HandlerSupportsUserNamespaces(runtimeHandler); err != nil {
return nil, err
} else if !handlerSupportsUserns {
return nil, fmt.Errorf("RuntimeClass handler %q does not support user namespaces", runtimeHandler)
if handlerSupportsUserns, err := m.kl.HandlerSupportsUserNamespaces(runtimeHandler); err != nil || !handlerSupportsUserns {
msg := "can't set `spec.hostUsers: false`, runtime does not support user namespaces"
if runtimeHandler != "" {
msg = fmt.Sprintf("can't set `spec.hostUsers: false`, RuntimeClass handler %q does not support user namespaces", runtimeHandler)
}
if err != nil {
return nil, fmt.Errorf("%v: %w", msg, err)
}
return nil, fmt.Errorf("%v", msg)
}

m.lock.Lock()
Expand All @@ -429,12 +429,12 @@ func (m *UsernsManager) GetOrCreateUserNamespaceMappings(pod *v1.Pod, runtimeHan
if string(content) != "" {
userNs, err = m.parseUserNsFileAndRecord(pod.UID, content)
if err != nil {
return nil, err
return nil, fmt.Errorf("user namespace: %w", err)
}
} else {
userNs, err = m.createUserNs(pod)
if err != nil {
return nil, err
return nil, fmt.Errorf("create user namespace: %w", err)
}
}

Expand Down Expand Up @@ -485,7 +485,7 @@ func (m *UsernsManager) CleanupOrphanedPodUsernsAllocations(pods []*v1.Pod, runn
allFound := sets.New[string]()
found, err := m.kl.ListPodsFromDisk()
if err != nil {
return err
return fmt.Errorf("user namespace: read pods from disk: %w", err)
}

for _, podUID := range found {
Expand Down
3 changes: 3 additions & 0 deletions pkg/kubelet/userns/userns_manager_disabled_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

/*
Copyright 2022 The Kubernetes Authors.

Expand Down
3 changes: 3 additions & 0 deletions pkg/kubelet/userns/userns_manager_switch_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

/*
Copyright 2024 The Kubernetes Authors.

Expand Down
10 changes: 3 additions & 7 deletions pkg/kubelet/userns/userns_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

/*
Copyright 2022 The Kubernetes Authors.

Expand All @@ -20,7 +23,6 @@ import (
"errors"
"fmt"
"os"
goruntime "runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -289,7 +291,6 @@ func TestGetOrCreateUserNamespaceMappings(t *testing.T) {
runtimeUserns bool
runtimeHandler string
success bool
skipOnWindows bool
}{
{
name: "no user namespace",
Expand Down Expand Up @@ -323,7 +324,6 @@ func TestGetOrCreateUserNamespaceMappings(t *testing.T) {
expMode: runtimeapi.NamespaceMode_POD,
runtimeUserns: true,
success: true,
skipOnWindows: true,
},
{
name: "user namespace, but no runtime support",
Expand All @@ -348,10 +348,6 @@ func TestGetOrCreateUserNamespaceMappings(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if tc.skipOnWindows && goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
// These tests will create the userns file, so use an existing podDir.
testUserNsPodsManager := &testUserNsPodsManager{
podDir: t.TempDir(),
Expand Down
50 changes: 50 additions & 0 deletions pkg/kubelet/userns/userns_manager_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package userns

import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
)

type UsernsManager struct{}

func MakeUserNsManager(kl userNsPodsManager) (*UsernsManager, error) {
return nil, nil
}

// Release releases the user namespace allocated to the specified pod.
func (m *UsernsManager) Release(podUID types.UID) {
return
}

func (m *UsernsManager) GetOrCreateUserNamespaceMappings(pod *v1.Pod, runtimeHandler string) (*runtimeapi.UserNamespace, error) {
return nil, nil
}

// CleanupOrphanedPodUsernsAllocations reconciliates the state of user namespace
// allocations with the pods actually running. It frees any user namespace
// allocation for orphaned pods.
func (m *UsernsManager) CleanupOrphanedPodUsernsAllocations(pods []*v1.Pod, runningPods []*kubecontainer.Pod) error {
return nil
}

func EnabledUserNamespacesSupport() bool {
return false
}
4 changes: 0 additions & 4 deletions pkg/util/kernel/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ const TCPFinTimeoutNamespacedKernelVersion = "4.6"
// (ref: https://github.com/torvalds/linux/commit/35dfb013149f74c2be1ff9c78f14e6a3cd1539d1)
const IPVSConnReuseModeFixedKernelVersion = "5.9"

// UserNamespacesSupportKernelVersion is the kernel version where idmap for tmpfs support was added
// (ref: https://github.com/torvalds/linux/commit/05e6295f7b5e05f09e369a3eb2882ec5b40fff20)
const UserNamespacesSupportKernelVersion = "6.3"

const TmpfsNoswapSupportKernelVersion = "6.4"

// NFTablesKubeProxyKernelVersion is the lowest kernel version kube-proxy supports using
Expand Down
2 changes: 1 addition & 1 deletion staging/publishing/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2898,4 +2898,4 @@ rules:
- staging/src/k8s.io/endpointslice
recursive-delete-patterns:
- '*/.gitattributes'
default-go-version: 1.23.8
default-go-version: 1.23.10
2 changes: 1 addition & 1 deletion test/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REGISTRY ?= registry.k8s.io/e2e-test-images
GOARM ?= 7
DOCKER_CERT_BASE_PATH ?=
QEMUVERSION=v5.1.0-2
GOLANG_VERSION=1.23.8
GOLANG_VERSION=1.23.10
export

ifndef WHAT
Expand Down
2 changes: 1 addition & 1 deletion test/utils/image/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func initImageConfigs(list RegistryList) (map[ImageID]Config, map[ImageID]Config
configs[BusyBox] = Config{list.PromoterE2eRegistry, "busybox", "1.36.1-1"}
configs[CudaVectorAdd] = Config{list.PromoterE2eRegistry, "cuda-vector-add", "1.0"}
configs[CudaVectorAdd2] = Config{list.PromoterE2eRegistry, "cuda-vector-add", "2.3"}
configs[DistrolessIptables] = Config{list.BuildImageRegistry, "distroless-iptables", "v0.5.13"}
configs[DistrolessIptables] = Config{list.BuildImageRegistry, "distroless-iptables", "v0.6.11"}
configs[Etcd] = Config{list.GcEtcdRegistry, "etcd", "3.5.15-0"}
configs[Httpd] = Config{list.PromoterE2eRegistry, "httpd", "2.4.38-4"}
configs[HttpdNew] = Config{list.PromoterE2eRegistry, "httpd", "2.4.39-4"}
Expand Down