Skip to content

Commit

Permalink
kubeadm: get k8s CI version markers from k8s infra bucket
Browse files Browse the repository at this point in the history
Updates kubeadm version resolution to use kubernetes community infra
bucket to fetch appropriate k8s ci versions. The images are already
being pulled from the kubernetes community infra bucket meaning that a
mismatch can occur when the ci version is fetched from the google infra
bucket and the image is not yet present on k8s infra.

Follow-up to kubernetes#97087

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Feb 6, 2021
1 parent af0ce4d commit 1619e81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions cmd/kubeadm/app/util/version.go
Expand Up @@ -39,6 +39,7 @@ const (

var (
kubeReleaseBucketURL = "https://dl.k8s.io"
kubeCIBucketURL = "https://storage.googleapis.com/k8s-release-dev"
kubeReleaseRegex = regexp.MustCompile(`^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-0-9a-zA-Z_\.+]*)?$`)
kubeReleaseLabelRegex = regexp.MustCompile(`^((latest|stable)+(-[1-9](\.[1-9]([0-9])?)?)?)\z`)
kubeBucketPrefixes = regexp.MustCompile(`^((release|ci|ci-cross)/)?([-\w_\.+]+)$`)
Expand Down Expand Up @@ -160,7 +161,7 @@ func normalizedBuildVersion(version string) string {
// Internal helper: split version parts,
// Return base URL and cleaned-up version
func splitVersion(version string) (string, string, error) {
var urlSuffix string
var bucketURL, urlSuffix string
subs := kubeBucketPrefixes.FindAllStringSubmatch(version, 1)
if len(subs) != 1 || len(subs[0]) != 4 {
return "", "", errors.Errorf("invalid version %q", version)
Expand All @@ -170,10 +171,12 @@ func splitVersion(version string) (string, string, error) {
case strings.HasPrefix(subs[0][2], "ci"):
// Just use whichever the user specified
urlSuffix = subs[0][2]
bucketURL = kubeCIBucketURL
default:
urlSuffix = "release"
bucketURL = kubeReleaseBucketURL
}
url := fmt.Sprintf("%s/%s", kubeReleaseBucketURL, urlSuffix)
url := fmt.Sprintf("%s/%s", bucketURL, urlSuffix)
return url, subs[0][3], nil
}

Expand Down
7 changes: 4 additions & 3 deletions cmd/kubeadm/app/util/version_test.go
Expand Up @@ -19,11 +19,12 @@ package util
import (
"errors"
"fmt"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"path"
"strings"
"testing"
"time"

"k8s.io/kubernetes/cmd/kubeadm/app/constants"
)

func TestEmptyVersion(t *testing.T) {
Expand Down Expand Up @@ -195,8 +196,8 @@ func TestSplitVersion(t *testing.T) {
{"release/v1.7.0", "https://dl.k8s.io/release", "v1.7.0", true},
{"release/latest-1.7", "https://dl.k8s.io/release", "latest-1.7", true},
// CI builds area
{"ci/latest", "https://dl.k8s.io/ci", "latest", true},
{"ci/latest-1.7", "https://dl.k8s.io/ci", "latest-1.7", true},
{"ci/latest", "https://storage.googleapis.com/k8s-release-dev/ci", "latest", true},
{"ci/latest-1.7", "https://storage.googleapis.com/k8s-release-dev/ci", "latest-1.7", true},
// unknown label in default (release) area: splitVersion validate only areas.
{"unknown-1", "https://dl.k8s.io/release", "unknown-1", true},
// unknown area, not valid input.
Expand Down

0 comments on commit 1619e81

Please sign in to comment.