Skip to content

Commit

Permalink
fix: update kubernetes library to support 1.29 upgrades
Browse files Browse the repository at this point in the history
Also add a unit-test to prevent issues like that (I upgraded to 1.29 but
forgot to update go-kubernetes).

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Sep 27, 2023
1 parent 52caf07 commit 62dcfe8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ require (
github.com/siderolabs/go-debug v0.2.3
github.com/siderolabs/go-kmsg v0.1.3
github.com/siderolabs/go-kubeconfig v0.1.0
github.com/siderolabs/go-kubernetes v0.2.3
github.com/siderolabs/go-kubernetes v0.2.5
github.com/siderolabs/go-loadbalancer v0.3.2
github.com/siderolabs/go-pcidb v0.2.0
github.com/siderolabs/go-pointer v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,8 @@ github.com/siderolabs/go-kmsg v0.1.3 h1:rYxuDCN52Y6XdTNnEe52f0NZa4F6GHDEAQoVMHME
github.com/siderolabs/go-kmsg v0.1.3/go.mod h1:MrxoGwR6WNC7knaMlIKbQM3DFKqJ/flTQH9OtW7M3c8=
github.com/siderolabs/go-kubeconfig v0.1.0 h1:t/2oMWkLSdWHXglKPMz8ySXnx6ZjHckeGY79NaDcBTo=
github.com/siderolabs/go-kubeconfig v0.1.0/go.mod h1:eM3mO02Td6wYDvdi9zTbMrj1Q4WqEFN8XQ6pNjCUWkI=
github.com/siderolabs/go-kubernetes v0.2.3 h1:/s3ncGbgc2D/B0U/saCK+NkOxEogXj/vmkjBXSDlXVc=
github.com/siderolabs/go-kubernetes v0.2.3/go.mod h1:iwv35xZkJrdQBjYxWiBL14YcSXVIPwFy/M6E8X/oF4Q=
github.com/siderolabs/go-kubernetes v0.2.5 h1:XSFS3jS5Cy9SJSXlTbHotu/TtfcD5LxyyoMqGotSDno=
github.com/siderolabs/go-kubernetes v0.2.5/go.mod h1:FKbze1yi8it4bCR/xNnT2CGkfKaYPyYwIouIHa9c9jM=
github.com/siderolabs/go-loadbalancer v0.3.2 h1:R2jKq8ifWOARxJ5blXwOOkiWCA5/46stGxUR8+qV8GE=
github.com/siderolabs/go-loadbalancer v0.3.2/go.mod h1:sKP/xSN4R+1fifcqIjnk1FtM5sSW20d+pi+0FV6CpVo=
github.com/siderolabs/go-pcidb v0.2.0 h1:ZCkF1cz6UjoEIHpP7+aeTI5BwmSxE627Jl1Wy2VZAwU=
Expand Down
41 changes: 41 additions & 0 deletions pkg/cluster/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package kubernetes_test

import (
"fmt"
"testing"

"github.com/blang/semver/v4"
"github.com/siderolabs/go-kubernetes/kubernetes/upgrade"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/siderolabs/talos/pkg/machinery/constants"
)

func TestUpgradePath(t *testing.T) {
// ensure that upgrade path is available for n-5 supported Kubernetes versions
latestVersion, err := semver.ParseTolerant(constants.DefaultKubernetesVersion)
require.NoError(t, err)

for minorVersion := latestVersion.Minor - constants.SupportedKubernetesVersions + 1; minorVersion <= latestVersion.Minor; minorVersion++ {
thisVersion := fmt.Sprintf("%d.%d", latestVersion.Major, minorVersion)

path, err := upgrade.NewPath(thisVersion, thisVersion)
require.NoError(t, err)

assert.True(t, path.IsSupported(), "upgrade path %s is not supported", path.String())

if minorVersion != latestVersion.Minor {
nextVersion := fmt.Sprintf("%d.%d", latestVersion.Major, minorVersion+1)

path, err = upgrade.NewPath(thisVersion, nextVersion)
require.NoError(t, err)

assert.True(t, path.IsSupported(), "upgrade path %s is not supported", path.String())
}
}
}
3 changes: 3 additions & 0 deletions pkg/machinery/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ const (
// renovate: datasource=github-releases depName=kubernetes/kubernetes
DefaultKubernetesVersion = "1.29.0-alpha.1"

// SupportedKubernetesVersions is the number of Kubernetes versions supported by Talos starting from DefaultKubernesVersion going backwards.
SupportedKubernetesVersions = 6

// DefaultControlPlanePort is the default port to use for the control plane.
DefaultControlPlanePort = 6443

Expand Down

0 comments on commit 62dcfe8

Please sign in to comment.