Skip to content

Commit

Permalink
Fix inconsistency by updating constant 'MachineControlPlaneLabelName'…
Browse files Browse the repository at this point in the history
… to 'MachineControlPlaneLabel' | Rebase with master

Signed-off-by: Chirayu Kapoor <dev.csociety@gmail.com>
  • Loading branch information
chiukapoor committed Nov 29, 2022
1 parent f9903f8 commit fade95b
Show file tree
Hide file tree
Showing 33 changed files with 288 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/kubernetes_bump.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ changes should be cherry-picked to all release series that will support the new
* Bump the Kubernetes version in:
* `test/*`: search for occurrences of the previous Kubernetes version
* `Tiltfile`
* Ensure the latest available kind version is used as well.
* Ensure the latest available kind version is used (including the latest images for this kind release)
* Verify the quickstart manually
* Prior art: #7156
* [ ] Job configurations:
Expand Down
16 changes: 13 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand All @@ -8,13 +11,20 @@ updates:
prefix: ":seedling:"
labels:
- "ok-to-test"
# Go
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
allow:
- dependency-name: "github.com/coredns/corefile-migration"
ignore:
# Ignore controller-runtime as its upgraded manually.
- dependency-name: "sigs.k8s.io/controller-runtime"
# Ignore k8s and its transitives modules as they are upgraded manually
# together with controller-runtime.
- dependency-name: "k8s.io/*"
- dependency-name: "go.etcd.io/*"
- dependency-name: "google.golang.org/grpc"
commit-message:
prefix: ":seedling:"
labels:
- "ok-to-test"
- "ok-to-test"
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ ifneq ($(strip $(GINKGO_SKIP)),)
_SKIP_ARGS := $(foreach arg,$(strip $(GINKGO_SKIP)),-skip="$(arg)")
endif

# Helper function to get dependency version from go.mod
get_go_version = $(shell go list -m $1 | awk '{print $$2}')

#
# Binaries.
#
Expand Down Expand Up @@ -125,8 +128,8 @@ CONVERSION_GEN_BIN := conversion-gen
CONVERSION_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONVERSION_GEN_BIN))
CONVERSION_GEN_PKG := k8s.io/code-generator/cmd/conversion-gen

ENVSUBST_VER := v2.0.0-20210730161058-179042472c46
ENVSUBST_BIN := envsubst
ENVSUBST_VER := $(call get_go_version,github.com/drone/envsubst/v2)
ENVSUBST := $(abspath $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)-$(ENVSUBST_VER))
ENVSUBST_PKG := github.com/drone/envsubst/v2/cmd/envsubst

Expand All @@ -148,8 +151,8 @@ YQ_BIN := yq
YQ := $(abspath $(TOOLS_BIN_DIR)/$(YQ_BIN)-$(YQ_VER))
YQ_PKG := github.com/mikefarah/yq/v4

GINGKO_VER := v2.5.0
GINKGO_BIN := ginkgo
GINGKO_VER := $(call get_go_version,github.com/onsi/ginkgo/v2)
GINKGO := $(abspath $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINGKO_VER))
GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo

Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const (
// MachineFinalizer is set on PrepareForCreate callback.
MachineFinalizer = "machine.cluster.x-k8s.io"

// MachineControlPlaneLabelName is the label set on machines or related objects that are part of a control plane.
MachineControlPlaneLabelName = "cluster.x-k8s.io/control-plane"
// MachineControlPlaneLabel is the label set on machines or related objects that are part of a control plane.
MachineControlPlaneLabel = "cluster.x-k8s.io/control-plane"

// ExcludeNodeDrainingAnnotation annotation explicitly skips node draining if set.
ExcludeNodeDrainingAnnotation = "machine.cluster.x-k8s.io/exclude-node-draining"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2179,13 +2179,13 @@ func newWorkerMachineForCluster(cluster *clusterv1.Cluster) *clusterv1.Machine {
Build()
}

// newControlPlaneMachine returns a Machine with the passed Cluster information and a MachineControlPlaneLabelName.
// newControlPlaneMachine returns a Machine with the passed Cluster information and a MachineControlPlaneLabel.
func newControlPlaneMachine(cluster *clusterv1.Cluster, name string) *clusterv1.Machine {
m := builder.Machine(cluster.Namespace, name).
WithVersion("v1.19.1").
WithBootstrapTemplate(bootstrapbuilder.KubeadmConfig(metav1.NamespaceDefault, "cfg").Unstructured()).
WithClusterName(cluster.Name).
WithLabels(map[string]string{clusterv1.MachineControlPlaneLabelName: ""}).
WithLabels(map[string]string{clusterv1.MachineControlPlaneLabel: ""}).
Build()
return m
}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/util/configowner.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (co ConfigOwner) IsControlPlaneMachine() bool {
if labels == nil {
return false
}
_, ok := labels[clusterv1.MachineControlPlaneLabelName]
_, ok := labels[clusterv1.MachineControlPlaneLabel]
return ok
}

Expand Down
4 changes: 2 additions & 2 deletions bootstrap/util/configowner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGetConfigOwner(t *testing.T) {
Name: "my-machine",
Namespace: metav1.NamespaceDefault,
Labels: map[string]string{
clusterv1.MachineControlPlaneLabelName: "",
clusterv1.MachineControlPlaneLabel: "",
},
},
Spec: clusterv1.MachineSpec{
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestGetConfigOwner(t *testing.T) {
Name: "my-machine-pool",
Namespace: metav1.NamespaceDefault,
Labels: map[string]string{
clusterv1.MachineControlPlaneLabelName: "",
clusterv1.MachineControlPlaneLabel: "",
},
},
Spec: expv1.MachinePoolSpec{
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/internal/test/fake_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ func (f *FakeMachine) Objs(cluster *clusterv1.Cluster, generateCerts bool, machi
// If this machine belong to a controlPlane, it is controlled by it / ownership set by the controlPlane controller -- ** NOT RECONCILED ?? **
machine.SetOwnerReferences([]metav1.OwnerReference{*metav1.NewControllerRef(controlPlane, controlPlane.GroupVersionKind())})
// Sets the MachineControlPlane Label
machine.Labels[clusterv1.MachineControlPlaneLabelName] = ""
machine.Labels[clusterv1.MachineControlPlaneLabel] = ""
default:
// If this machine does not belong to a machineSet or to a control plane, it is owned by the cluster / ownership set by the machine controller -- RECONCILED
machine.SetOwnerReferences([]metav1.OwnerReference{{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const (
initConfiguration = "initConfiguration"
joinConfiguration = "joinConfiguration"
nodeRegistration = "nodeRegistration"
skipPhases = "skipPhases"
patches = "patches"
directory = "directory"
preKubeadmCommands = "preKubeadmCommands"
Expand Down Expand Up @@ -148,8 +149,10 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
{spec, kubeadmConfigSpec, clusterConfiguration, scheduler, "*"},
{spec, kubeadmConfigSpec, initConfiguration, nodeRegistration, "*"},
{spec, kubeadmConfigSpec, initConfiguration, patches, directory},
{spec, kubeadmConfigSpec, initConfiguration, skipPhases},
{spec, kubeadmConfigSpec, joinConfiguration, nodeRegistration, "*"},
{spec, kubeadmConfigSpec, joinConfiguration, patches, directory},
{spec, kubeadmConfigSpec, joinConfiguration, skipPhases},
{spec, kubeadmConfigSpec, preKubeadmCommands},
{spec, kubeadmConfigSpec, postKubeadmCommands},
{spec, kubeadmConfigSpec, files},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
Directory: "/tmp/patches",
}

updateInitConfigurationSkipPhases := before.DeepCopy()
updateInitConfigurationSkipPhases.Spec.KubeadmConfigSpec.InitConfiguration.SkipPhases = []string{"addon/kube-proxy"}

updateJoinConfigurationSkipPhases := before.DeepCopy()
updateJoinConfigurationSkipPhases.Spec.KubeadmConfigSpec.JoinConfiguration.SkipPhases = []string{"addon/kube-proxy"}

updateDiskSetup := before.DeepCopy()
updateDiskSetup.Spec.KubeadmConfigSpec.DiskSetup = &bootstrapv1.DiskSetup{
Filesystems: []bootstrapv1.Filesystem{
Expand Down Expand Up @@ -985,6 +991,18 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
before: before,
kcp: updateJoinConfigurationPatches,
},
{
name: "should allow changes to initConfiguration.skipPhases",
expectErr: false,
before: before,
kcp: updateInitConfigurationSkipPhases,
},
{
name: "should allow changes to joinConfiguration.skipPhases",
expectErr: false,
before: before,
kcp: updateJoinConfigurationSkipPhases,
},
{
name: "should allow changes to diskSetup",
expectErr: false,
Expand Down
2 changes: 1 addition & 1 deletion controlplane/kubeadm/internal/cluster_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ControlPlaneMachineLabelsForCluster(kcp *controlplanev1.KubeadmControlPlane

// Always force these labels over the ones coming from the spec.
labels[clusterv1.ClusterNameLabel] = clusterName
labels[clusterv1.MachineControlPlaneLabelName] = ""
labels[clusterv1.MachineControlPlaneLabel] = ""
labels[clusterv1.MachineControlPlaneNameLabel] = kcp.Name
return labels
}
2 changes: 1 addition & 1 deletion controlplane/kubeadm/internal/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func machineListForTestGetMachinesForCluster() *clusterv1.MachineList {
}
}
controlPlaneMachine := machine("first-machine")
controlPlaneMachine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = ""
controlPlaneMachine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = ""
controlPlaneMachine.OwnerReferences = ownedRef

return &clusterv1.MachineList{
Expand Down
4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ func TestKubeadmControlPlaneReconciler_reconcileDelete(t *testing.T) {

controlPlaneMachines := clusterv1.MachineList{}
labels := map[string]string{
clusterv1.MachineControlPlaneLabelName: "",
clusterv1.MachineControlPlaneLabel: "",
}
g.Expect(fakeClient.List(ctx, &controlPlaneMachines, client.MatchingLabels(labels))).To(Succeed())
g.Expect(controlPlaneMachines.Items).To(HaveLen(3))
Expand Down Expand Up @@ -1553,7 +1553,7 @@ func TestKubeadmControlPlaneReconciler_reconcileDelete(t *testing.T) {

controlPlaneMachines := clusterv1.MachineList{}
labels := map[string]string{
clusterv1.MachineControlPlaneLabelName: "",
clusterv1.MachineControlPlaneLabel: "",
}
g.Expect(fakeClient.List(ctx, &controlPlaneMachines, client.MatchingLabels(labels))).To(Succeed())
g.Expect(controlPlaneMachines.Items).To(HaveLen(3))
Expand Down
4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/controllers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func TestKubeadmControlPlaneReconciler_generateMachine(t *testing.T) {
g.Expect(machine.Labels[k]).To(Equal(v))
}
g.Expect(machine.Labels[clusterv1.ClusterNameLabel]).To(Equal(cluster.Name))
g.Expect(machine.Labels[clusterv1.MachineControlPlaneLabelName]).To(Equal(""))
g.Expect(machine.Labels[clusterv1.MachineControlPlaneLabel]).To(Equal(""))
g.Expect(machine.Labels[clusterv1.MachineControlPlaneNameLabel]).To(Equal(kcp.Name))

for k, v := range kcpMachineTemplateObjectMeta.Annotations {
Expand All @@ -559,7 +559,7 @@ func TestKubeadmControlPlaneReconciler_generateMachine(t *testing.T) {

// Verify that machineTemplate.ObjectMeta in KCP has not been modified.
g.Expect(kcp.Spec.MachineTemplate.ObjectMeta.Labels).NotTo(HaveKey(clusterv1.ClusterNameLabel))
g.Expect(kcp.Spec.MachineTemplate.ObjectMeta.Labels).NotTo(HaveKey(clusterv1.MachineControlPlaneLabelName))
g.Expect(kcp.Spec.MachineTemplate.ObjectMeta.Labels).NotTo(HaveKey(clusterv1.MachineControlPlaneLabel))
g.Expect(kcp.Spec.MachineTemplate.ObjectMeta.Labels).NotTo(HaveKey(clusterv1.MachineControlPlaneNameLabel))
g.Expect(kcp.Spec.MachineTemplate.ObjectMeta.Annotations).NotTo(HaveKey(controlplanev1.KubeadmClusterConfigurationAnnotation))
}
Expand Down
2 changes: 1 addition & 1 deletion exp/internal/controllers/machinepool_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
Name: "deleted",
Namespace: metav1.NamespaceDefault,
Labels: map[string]string{
clusterv1.MachineControlPlaneLabelName: "",
clusterv1.MachineControlPlaneLabel: "",
},
Finalizers: []string{expv1.MachinePoolFinalizer},
DeletionTimestamp: &time,
Expand Down
27 changes: 14 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ require (
github.com/google/go-github/v45 v45.2.0
github.com/google/gofuzz v1.2.0
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/onsi/ginkgo/v2 v2.5.0
github.com/onsi/ginkgo/v2 v2.5.1
github.com/onsi/gomega v1.24.1
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.13.0
github.com/spf13/viper v1.14.0
github.com/valyala/fastjson v1.6.3
go.etcd.io/etcd/api/v3 v3.5.4
go.etcd.io/etcd/client/v3 v3.5.4
go.etcd.io/etcd/api/v3 v3.5.5
go.etcd.io/etcd/client/v3 v3.5.5
golang.org/x/net v0.2.0 // indirect
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1
google.golang.org/grpc v1.47.0
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
google.golang.org/grpc v1.50.1
k8s.io/api v0.25.0
k8s.io/apiextensions-apiserver v0.25.0
k8s.io/apimachinery v0.25.0
Expand Down Expand Up @@ -109,8 +109,8 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
Expand All @@ -123,10 +123,10 @@ require (
github.com/subosito/gotenv v1.4.1 // indirect
github.com/vincent-petithory/dataurl v1.0.0 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
golang.org/x/crypto v0.1.0 // indirect
Expand All @@ -136,7 +136,7 @@ require (
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand All @@ -151,7 +151,8 @@ require (
)

require (
cloud.google.com/go/compute v1.7.0 // indirect
cloud.google.com/go/compute v1.12.1 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
Expand Down
Loading

0 comments on commit fade95b

Please sign in to comment.