Skip to content
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

update_kubernetes_version: standalone script v2 #9384

Merged
merged 4 commits into from
Oct 12, 2020

Conversation

prezha
Copy link
Contributor

@prezha prezha commented Oct 3, 2020

fixes #4392 (iteration 1 & 2)

notes:

  • UPDATE_TARGET env var controlles what will be updated - options:
    = unset/absent, fs, or all: local filesystem repo will be updated - similarly to the old behaviour
    = gh or all: a pr against origin (kubernetes/minikube) github repo would be automatically created, but only if the same one does not exist already, and will also 'mention' the issue Write a script to automatically propose PR's due to a new Kubernetes release #4392

  • GITHUB_TOKEN is required for gh or all UPDATE_TARGET

  • desired changes are defined as plan, which is flexible (ie, supports regex and go text templates) and placed at the top of the script - easy to amend and extend; parseability checks in place

  • aob:
    = used github.com/google/go-github/v32/github: pure go code ;) - no need to call git or gh cli from the script
    = used k8s.io/klog/v2 instead of glog
    = go.mod & go.sum amended accordingly (for klog/v2 and github/v32)
    = cron job script could contain something like: rm -rf ~/minikube && git clone https://github.com/kubernetes/minikube.git ~/minikube && cd ~/minikube/hack/kubernetes_version && go run update_kubernetes_version.go

  • all make test passed

  • testing & example output:

for unset UPDATE_TARGET:

1st run:

I1003 00:52:44.696940    1777 update_kubernetes_version.go:161] Kubernetes versions: 'stable' is v1.23.456 and 'latest' is v2.34.457-rc.89
I1003 00:52:44.697055    1777 update_kubernetes_version.go:163] The Plan:
{
  "pkg/minikube/constants/constants.go": {
    "replace": {
      "DefaultKubernetesVersion = \\\".*": "DefaultKubernetesVersion = \"v1.23.456\"",
      "NewestKubernetesVersion = \\\".*": "NewestKubernetesVersion = \"v2.34.457-rc.89\""
    }
  },
  "site/content/en/docs/commands/start.md": {
    "replace": {
      "'latest' for .*\\)": "'latest' for v2.34.457-rc.89)",
      "'stable' for .*,": "'stable' for v1.23.456,"
    }
  }
}
I1003 00:52:44.697581    1777 update_kubernetes_version.go:172] Local repo updated

git diff:

diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go
index fd330a96d..a533e0e09 100644
--- a/pkg/minikube/constants/constants.go
+++ b/pkg/minikube/constants/constants.go
@@ -27,10 +27,10 @@ import (

 const (
        // DefaultKubernetesVersion is the default Kubernetes version
-       DefaultKubernetesVersion = "v1.19.2"
+       DefaultKubernetesVersion = "v1.23.456"
        // NewestKubernetesVersion is the newest Kubernetes version to test against
        // NOTE: You may need to update coreDNS & etcd versions in pkg/minikube/bootstrapper/images/images.go
-       NewestKubernetesVersion = "v1.19.2"
+       NewestKubernetesVersion = "v2.34.457-rc.89"
        // OldestKubernetesVersion is the oldest Kubernetes version to test against
        OldestKubernetesVersion = "v1.13.0"
        // DefaultClusterName is the default nane for the k8s cluster
diff --git a/site/content/en/docs/commands/start.md b/site/content/en/docs/commands/start.md
index 87538fb59..b1f036128 100644
--- a/site/content/en/docs/commands/start.md
+++ b/site/content/en/docs/commands/start.md
@@ -67,7 +67,7 @@ minikube start [flags]
       --interactive                       Allow user prompts for more information (default true)
       --iso-url strings                   Locations to fetch the minikube ISO from. (default [https://storage.googleapis.com/minikube/iso/minikube-v1.13.1.iso,https://github.com/kubernetes/minikube/releases/download/v1.13.1/minikube-v1.13.1.iso,https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.13.1.iso])
       --keep-context                      This will keep the existing kubectl context and will create a minikube context.
-      --kubernetes-version string         The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.19.2, 'latest' for v1.19.2). Defaults to 'stable'.
+      --kubernetes-version string         The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.23.456, 'latest' for v2.34.457-rc.89). Defaults to 'stable'.
       --kvm-gpu                           Enable experimental NVIDIA GPU support in minikube
       --kvm-hidden                        Hide the hypervisor signature from the guest in minikube (kvm2 driver only)
       --kvm-network string                The KVM network name. (kvm2 driver only) (default "default")

2nd run:

I1003 00:53:30.207909    3317 update_kubernetes_version.go:161] Kubernetes versions: 'stable' is v1.23.456 and 'latest' is v2.34.457-rc.89
I1003 00:53:30.208360    3317 update_kubernetes_version.go:163] The Plan:
{
  "pkg/minikube/constants/constants.go": {
    "replace": {
      "DefaultKubernetesVersion = \\\".*": "DefaultKubernetesVersion = \"v1.23.456\"",
      "NewestKubernetesVersion = \\\".*": "NewestKubernetesVersion = \"v2.34.457-rc.89\""
    }
  },
  "site/content/en/docs/commands/start.md": {
    "replace": {
      "'latest' for .*\\)": "'latest' for v2.34.457-rc.89)",
      "'stable' for .*,": "'stable' for v1.23.456,"
    }
  }
}
I1003 00:53:30.209539    3317 update_kubernetes_version.go:170] Local repo update skipped: nothing changed

for UPDATE_TARGET set to gh and w/ GITHUB_TOKEN set:

1st run:

I1003 01:06:26.158314   21354 update_kubernetes_version.go:161] Kubernetes versions: 'stable' is v1.23.456 and 'latest' is v2.34.457-rc.89
I1003 01:06:26.158472   21354 update_kubernetes_version.go:163] The Plan:
{
  "pkg/minikube/constants/constants.go": {
    "replace": {
      "DefaultKubernetesVersion = \\\".*": "DefaultKubernetesVersion = \"v1.23.456\"",
      "NewestKubernetesVersion = \\\".*": "NewestKubernetesVersion = \"v2.34.457-rc.89\""
    }
  },
  "site/content/en/docs/commands/start.md": {
    "replace": {
      "'latest' for .*\\)": "'latest' for v2.34.457-rc.89)",
      "'stable' for .*,": "'stable' for v1.23.456,"
    }
  }
}
I1003 01:06:34.204164   21354 update_kubernetes_version.go:289] PR commit '0d49507f0f4d6fb8c6f8cf646a65a737371da2e8' created: https://github.com/prezha/minikube/commit/0d49507f0f4d6fb8c6f8cf646a65a737371da2e8
I1003 01:06:34.921082   21354 update_kubernetes_version.go:303] PR branch 'update-kubernetes-version_0d49507' created: https://api.github.com/repos/prezha/minikube/git/refs/heads/update-kubernetes-version_0d49507
I1003 01:06:36.615138   21354 update_kubernetes_version.go:199] PR created: https://github.com/triplepoint-tech/minikube/pull/3

2nd run:

I1003 01:06:52.070881   22035 update_kubernetes_version.go:161] Kubernetes versions: 'stable' is v1.23.456 and 'latest' is v2.34.457-rc.89
I1003 01:06:52.071322   22035 update_kubernetes_version.go:163] The Plan:
{
  "pkg/minikube/constants/constants.go": {
    "replace": {
      "DefaultKubernetesVersion = \\\".*": "DefaultKubernetesVersion = \"v1.23.456\"",
      "NewestKubernetesVersion = \\\".*": "NewestKubernetesVersion = \"v2.34.457-rc.89\""
    }
  },
  "site/content/en/docs/commands/start.md": {
    "replace": {
      "'latest' for .*\\)": "'latest' for v2.34.457-rc.89)",
      "'stable' for .*,": "'stable' for v1.23.456,"
    }
  }
}
I1003 01:06:52.434969   22035 update_kubernetes_version.go:190] PR create skipped: already exists (https://github.com/triplepoint-tech/minikube/pull/3)

polls GitHub for the current Kubernetes Stable release and latest RC or Beta pre-release, then automatically updates local repo and/or creates a unique PR in kubernetes/minikube repo
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 3, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @prezha. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 3, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: prezha
To complete the pull request process, please assign priyawadhwa after the PR has been reviewed.
You can assign the PR to them by writing /assign @priyawadhwa in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

when there are changes that has been made in the local filesystem repo
and make the issue mentioned in the PR message ("fixes: ") a parameter
"github.com/golang/glog"
"golang.org/x/oauth2"

"k8s.io/klog/v2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend keep using glog till we deprecate glog (that is a WIP PR it is better to let that PR handle migration from glog to klog)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks @medyagh for your review and comment - i've switched back from using klog to glog

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@38da8de). Click here to learn what that means.
The diff coverage is 9.05%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #9384   +/-   ##
=========================================
  Coverage          ?   29.20%           
=========================================
  Files             ?      171           
  Lines             ?    10447           
  Branches          ?        0           
=========================================
  Hits              ?     3051           
  Misses            ?     6972           
  Partials          ?      424           
Impacted Files Coverage Δ
cmd/minikube/cmd/completion.go 0.00% <ø> (ø)
cmd/minikube/cmd/config/configure.go 0.74% <ø> (ø)
cmd/minikube/cmd/config/profile_list.go 2.56% <0.00%> (ø)
cmd/minikube/cmd/delete.go 19.06% <0.00%> (ø)
cmd/minikube/cmd/mount.go 8.33% <0.00%> (ø)
cmd/minikube/cmd/stop.go 4.00% <ø> (ø)
cmd/minikube/cmd/update-context.go 0.00% <0.00%> (ø)
pkg/drivers/common.go 8.00% <0.00%> (ø)
pkg/drivers/kic/oci/cli_runner.go 0.00% <0.00%> (ø)
pkg/drivers/kic/oci/errors.go 0.00% <ø> (ø)
... and 18 more

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@medyagh medyagh merged commit 7f4e7ee into kubernetes:master Oct 12, 2020
@prezha
Copy link
Contributor Author

prezha commented Oct 12, 2020

@medyagh you are most welcome, thank you for your review!
please let me know if there are any issues running this script (scheduled)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write a script to automatically propose PR's due to a new Kubernetes release
5 participants