Skip to content

Commit

Permalink
resolve merge conflicts and revendor
Browse files Browse the repository at this point in the history
  • Loading branch information
rkjakeer committed Jul 16, 2021
2 parents e1d498a + 3b4b4d6 commit 24d6f52
Show file tree
Hide file tree
Showing 915 changed files with 173,481 additions and 110,956 deletions.
6 changes: 3 additions & 3 deletions .ci/integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function run_controller() {
--machine-safety-apiserver-statuscheck-timeout=30s \
--machine-safety-apiserver-statuscheck-period=1m \
--machine-safety-orphan-vms-period=30m \
--machine-safety-overshooting-period=300ms \
--machine-safety-overshooting-period=100ms \
--leader-elect-lease-duration=1m \
--leader-elect-renew-deadline=30s \
--leader-elect-retry-period=15s \
Expand Down Expand Up @@ -366,7 +366,7 @@ function tc_machine_deployment() {
printf "\n\tWaiting 1800s for 3 machines to join the cluster"
hf_wait_on "hf_num_of_ready_nodes" nodes 3 1800

# Scale up the number of nodes to 6 and rapidly scale back to 2
# # Scale up the number of nodes to 6 and rapidly scale back to 2
hf_object_configure $provider/md-scale-up.yaml
printf "\n\tScale up the number of nodes to 6 and rapidly scale back to 2 leading to a freezing and unfreezing"
sleep 20
Expand All @@ -386,7 +386,7 @@ function tc_machine_deployment() {
printf "\n\tWaiting 1800s for machine to be deleted"
hf_wait_on "hf_num_of_objects" machdeploy 0 1800

# Scaling from 6 to 2 should lead to freezing and unfreezing of machine-set
# # Scaling from 6 to 2 should lead to freezing and unfreezing of machine-set
printf "\n\tCheck for freezing and unfreezing of machine-set due to rapid scaleUp and scaleDown"
hf_check_ms_freeze
printf "\n\tFreezing and unfreezing of machineSet was observed"
Expand Down
25 changes: 23 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
---
name: Bug Report
about: Report a bug
about: Report a bug encountered while operating Gardener
labels: kind/bug

---

**How to categorize this issue?**
<!--
Please select area, kind, and priority for this issue. This helps the community categorizing it.
Replace below TODOs or exchange the existing identifiers with those that fit best in your opinion.
If multiple identifiers make sense you can also state the commands multiple times, e.g.
/area control-plane
/area auto-scaling
...
"/area" identifiers: audit-logging|auto-scaling|backup|certification|control-plane-migration|control-plane|cost|delivery|dev-productivity|disaster-recovery|documentation|high-availability|logging|metering|monitoring|networking|open-source|ops-productivity|os|performance|quality|robustness|scalability|security|storage|testing|usability|user-management
"/kind" identifiers: api-change|bug|cleanup|discussion|enhancement|epic|impediment|poc|post-mortem|question|regression|task|technical-debt|test
"/priority" identifiers: 1|2|3|4|5 (ordered from greatest to least)
-->
/area TODO
/kind bug
/priority 3

**What happened**:

**What you expected to happen**:

**How to reproduce it (as minimally and precisely as possible)**:

**Anything else we need to know**:
**Anything else we need to know?**:

**Environment**:

- Kubernetes version (use `kubectl version`):
- Cloud provider or hardware configuration:
- Others:
19 changes: 18 additions & 1 deletion .github/ISSUE_TEMPLATE/enhancement_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
---
name: Enhancement Request
about: Suggest an enhancement
about: Suggest an enhancement to the Gardener/MCM project
labels: kind/enhancement

---

**How to categorize this issue?**
<!--
Please select area, kind, and priority for this issue. This helps the community categorizing it.
Replace below TODOs or exchange the existing identifiers with those that fit best in your opinion.
If multiple identifiers make sense you can also state the commands multiple times, e.g.
/area control-plane
/area auto-scaling
...
"/area" identifiers: audit-logging|auto-scaling|backup|certification|control-plane-migration|control-plane|cost|delivery|dev-productivity|disaster-recovery|documentation|high-availability|logging|metering|monitoring|networking|open-source|ops-productivity|os|performance|quality|robustness|scalability|security|storage|testing|usability|user-management
"/kind" identifiers: api-change|bug|cleanup|discussion|enhancement|epic|impediment|poc|post-mortem|question|regression|task|technical-debt|test
"/priority" identifiers: 1|2|3|4|5 (ordered from greatest to least)
-->
/area TODO
/kind enhancement
/priority 3

**What would you like to be added**:

**Why is this needed**:
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.40.0-dev
v0.41.0-dev
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Each `machine` object has an annotation `machinepriority.machine.sapcloud.io` se

### How to force delete a machine?

A machine can be force deleted by adding the label `force-deletion: "True"` on the `machine` object if it's already being deleted. During force deletion, MCM skips the drain function and simply triggers the deletion of the machine. This label should be used with caution as it can violate the PDBs for pods running on the machine.
A machine can be force deleted by adding the label `force-deletion: "True"` on the `machine` object before executing the actual delete command. During force deletion, MCM skips the drain function and simply triggers the deletion of the machine. This label should be used with caution as it can violate the PDBs for pods running on the machine.

### How to pause the ongoing rolling-update of the machinedeployment?

Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@ require (
github.com/cenkalti/backoff/v4 v4.1.0
github.com/davecgh/go-spew v1.1.1
github.com/emicklei/go-restful v2.9.6+incompatible // indirect
github.com/go-git/go-git/v5 v5.3.0
github.com/go-openapi/spec v0.19.2
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gophercloud/gophercloud v0.7.0
github.com/gophercloud/utils v0.0.0-20200204043447-9864b6f1f12f
github.com/json-iterator/go v1.1.9 // indirect
github.com/onsi/ginkgo v1.15.2
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.11.0
github.com/packethost/packngo v0.0.0-20181217122008-b3b45f1b4979
github.com/prometheus/client_golang v0.9.2
github.com/satori/go.uuid v1.2.0 // indirect
github.com/spf13/pflag v1.0.3
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
google.golang.org/api v0.4.0
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.0.0-20190918155943-95b840bb6a1f
k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655
k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad
k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90
Expand All @@ -42,9 +45,11 @@ require (
)

replace (
github.com/go-git/go-git/v5 => github.com/go-git/go-git/v5 v5.3.0
github.com/onsi/ginkgo => github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega => github.com/onsi/gomega v1.5.0
k8s.io/api => k8s.io/api v0.0.0-20190918155943-95b840bb6a1f // kubernetes-1.16.0
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783 // kubernetes-1.16.0
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655 // kubernetes-1.16.0
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad // kubernetes-1.16.0
k8s.io/client-go => k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90 // kubernetes-1.16.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
3 changes: 0 additions & 3 deletions kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ spec:
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
description: Standard object metadata.
type: object
spec:
description: Specification of the desired behavior of the MachineDeployment.
properties:
Expand Down
8 changes: 8 additions & 0 deletions kubernetes/deployment/out-of-tree/target-cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ rules:
verbs:
- watch
- list
- apiGroups:
- storage.k8s.io
resources:
- volumeattachments
verbs:
- get
- list
- watch
6 changes: 3 additions & 3 deletions pkg/controller/deployment_rolling.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (dc *controller) annotateNodesBackingMachineSets(MachineSets []*v1alpha1.Ma

for _, machineSet := range MachineSets {

klog.V(3).Infof("Trying to annotate nodes under the MachineSet object %q with %s", machineSet.Name, annotations)
klog.V(4).Infof("Trying to annotate nodes under the MachineSet object %q with %s", machineSet.Name, annotations)
selector, err := metav1.LabelSelectorAsSelector(machineSet.Spec.Selector)
if err != nil {
return err
Expand Down Expand Up @@ -409,7 +409,7 @@ func (dc *controller) annotateNodesBackingMachineSets(MachineSets []*v1alpha1.Ma
}
}
}
klog.V(2).Infof("Annotated the nodes backed by MachineSet %q with %s", machineSet.Name, annotations)
klog.V(4).Infof("Annotated the nodes backed by MachineSet %q with %s", machineSet.Name, annotations)
}

return nil
Expand Down Expand Up @@ -472,7 +472,7 @@ func (dc *controller) removeAutoscalerAnnotationsIfRequired(MachineSets []*v1alp
klog.Warningf("Removing annotation failed for node: %s, %s", machine.Status.Node, err)
return err
}
klog.V(3).Infof("De-annotated the node %q backed by MachineSet %q with %s", machine.Status.Node, machineSet.Name, annotations)
klog.V(4).Infof("De-annotated the node %q backed by MachineSet %q with %s", machine.Status.Node, machineSet.Name, annotations)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/deployment_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ func NewISNewReplicas(deployment *v1alpha1.MachineDeployment, allISs []*v1alpha1
return 0, err
}
// Find the total number of machines
currentMachineCount := GetReplicaCountForMachineSets(allISs)
currentMachineCount := GetActualReplicaCountForMachineSets(allISs)
maxTotalMachines := (deployment.Spec.Replicas) + int32(maxSurge)
if currentMachineCount >= maxTotalMachines {
// Cannot scale up.
Expand Down
67 changes: 67 additions & 0 deletions pkg/controller/machine_safety_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,70 @@ import (

var _ = Describe("#machine_safety", func() {

DescribeTable("##checkAndFreezeORUnfreezeMachineSets",
func(
machineSet *v1alpha1.MachineSet,
machineCount int,
FreezeMachineSet bool,
) {
stop := make(chan struct{})
defer close(stop)

controlMachineObjects := []runtime.Object{}
if machineSet != nil {
controlMachineObjects = append(controlMachineObjects, machineSet)
}

machines := newMachinesFromMachineSet(machineCount, machineSet, nil, nil, nil)
for _, machine := range machines {
controlMachineObjects = append(controlMachineObjects, machine)
}

c, trackers := createController(stop, testNamespace, controlMachineObjects, nil, nil)
waitForCacheSync(stop, c)
defer trackers.Stop()

err := c.checkAndFreezeORUnfreezeMachineSets()
Expect(err).To(BeNil())
ms, err := c.controlMachineClient.MachineSets(testNamespace).Get(machineSet.Name, metav1.GetOptions{})
Expect(err).To(BeNil())

if FreezeMachineSet {
Expect(ms.Labels["freeze"]).Should(Equal("True"))
} else {
Expect(ms.Labels["freeze"]).To(Equal(""))
}
},

// When there is 1 machineSet with 1 replica and corresponding 1 machine Object
// MachineSet is not frozen
Entry("MachineSet with 1 replica & 1 machine object", newMachineSet(&v1alpha1.MachineTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: "machine",
Namespace: testNamespace,
},
}, 1, 10, nil, nil, nil, nil), 1, false),

// When there is 1 machineSet with 1 replica and corresponding 5 machine Object
// MachineSet is frozen by adding a label on MachineSet
Entry("MachineSet with 1 replica & 5 machine object", newMachineSet(&v1alpha1.MachineTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: "machine",
Namespace: testNamespace,
},
}, 1, 10, nil, nil, nil, nil), 5, true),

// When there is 1 machineSet with 5 replica and corresponding 2 machine Object
// with a {"Freeze": "True"} label set on the MachineSe, the MachineSet is unfrozen
// by removing a label on MachineSet
Entry("MachineSet with 5 replica & 2 machine object", newMachineSet(&v1alpha1.MachineTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: "machine",
Namespace: testNamespace,
},
}, 5, 10, nil, nil, nil, map[string]string{"Freeze": "True"}), 2, false),
)

DescribeTable("##freezeMachineSetsAndDeployments",
func(machineSet *v1alpha1.MachineSet) {
stop := make(chan struct{})
Expand All @@ -57,6 +121,9 @@ var _ = Describe("#machine_safety", func() {
}

c.freezeMachineSetAndDeployment(&ms, freezeReason, freezeMessage)
ms, err := c.controlMachineClient.MachineSets(testNamespace).Get(ms.Name, metav1.GetOptions{})
Expect(err).To(BeNil())
Expect(ms.Labels["freeze"]).To(Equal("True"))
}
},
Entry("one machineset", newMachineSet(&v1alpha1.MachineTemplateSpec{
Expand Down
3 changes: 0 additions & 3 deletions pkg/util/backoff/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"k8s.io/klog"
)

var (
Expand Down Expand Up @@ -132,8 +131,6 @@ var _ = Describe("#wait", func() {
action: action{
operation: func() error {
invokationCount += 1
klog.Error(invokationCount)

if invokationCount > 4 {
return nil
}
Expand Down
74 changes: 74 additions & 0 deletions pkg/util/k8sutils/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
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 k8sutils is used to provider helper consts and functions for k8s operations
package k8sutils

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
"k8s.io/klog"
)

const (
// VolumeAttachmentGroupName group name
VolumeAttachmentGroupName = "storage.k8s.io"
// VolumeAttachmentResourceName is the kind used for VolumeAttachment
VolumeAttachmentResourceName = "volumeattachments"
)

// IsResourceSupported uses Discovery API to find out if the server supports
// the given GroupResource.
// If supported, it will return its groupVersion; Otherwise, it will return ""
func IsResourceSupported(
clientset kubernetes.Interface,
gr schema.GroupResource,
) bool {
var (
foundDesiredGroup bool
desiredGroupVersion string
)

discoveryClient := clientset.Discovery()
groupList, err := discoveryClient.ServerGroups()
if err != nil {
return false
}

for _, group := range groupList.Groups {
if group.Name == gr.Group {
foundDesiredGroup = true
desiredGroupVersion = group.PreferredVersion.GroupVersion
break
}
}
if !foundDesiredGroup {
return false
}

resourceList, err := discoveryClient.ServerResourcesForGroupVersion(desiredGroupVersion)
if err != nil {
return false
}

for _, resource := range resourceList.APIResources {
if resource.Name == gr.Resource {
klog.V(3).Infof("Found Resource: %s/%s", gr.Group, gr.Resource)
return true
}
}
return false
}
Loading

0 comments on commit 24d6f52

Please sign in to comment.