Skip to content

Commit

Permalink
Removed Deprecated labels from cloud-node-manager
Browse files Browse the repository at this point in the history
removing deprecated labels from nodemanager.go

removed tests surrounding the deprecated labels

chore(deps): bump k8s.io/api from 0.25.2 to 0.25.3

Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/kubernetes/api/releases)
- [Commits](kubernetes/api@v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: k8s.io/api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump k8s.io/client-go from 0.25.2 to 0.25.3

Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/kubernetes/client-go/releases)
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](kubernetes/client-go@v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: k8s.io/client-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump k8s.io/component-base from 0.25.2 to 0.25.3

Bumps [k8s.io/component-base](https://github.com/kubernetes/component-base) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/kubernetes/component-base/releases)
- [Commits](kubernetes/component-base@v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: k8s.io/component-base
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Verify and update vendor licenses
* Add verify-azure-vendor-licenses.sh update-azure-vendor-licenses.sh
* Add Makefile targets
* Add verify-vendor-licenses to check job
* Add vendor licenses

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>

test: add codespell github action

doc: fix spelling issues

fix

doc: fix code spelling

fix

chore(deps): bump k8s.io/controller-manager from 0.25.2 to 0.25.3

Bumps [k8s.io/controller-manager](https://github.com/kubernetes/controller-manager) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/kubernetes/controller-manager/releases)
- [Commits](kubernetes/controller-manager@v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: k8s.io/controller-manager
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump k8s.io/cloud-provider from 0.25.2 to 0.25.3

Bumps [k8s.io/cloud-provider](https://github.com/kubernetes/cloud-provider) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/kubernetes/cloud-provider/releases)
- [Commits](kubernetes/cloud-provider@v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: k8s.io/cloud-provider
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump github.com/fsnotify/fsnotify from 1.5.4 to 1.6.0

Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.5.4 to 1.6.0.
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](fsnotify/fsnotify@v1.5.4...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsnotify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

[e2e] Should clean up pip in azure-load-balancer-ip annotation test

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>

chore(deps): bump k8s.io/kubelet from 0.25.2 to 0.25.3

Bumps [k8s.io/kubelet](https://github.com/kubernetes/kubelet) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/kubernetes/kubelet/releases)
- [Commits](kubernetes/kubelet@v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: k8s.io/kubelet
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump golang.org/x/text from 0.3.8 to 0.4.0

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.8 to 0.4.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](golang/text@v0.3.8...v0.4.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Adjust e2e tests
* Can avoid printing stdout and stderr when run kubectl
* Service CIDR is hardcoded to IPv4 for AKS pipeline

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>

update go version params of github action

Signed-off-by: MartinForReal <fanshangxiang@gmail.com>

Update release notes for v1.24.9

Update release notes for v1.25.3

add label for release notes pr

Update release notes for v1.23.22

Update release notes for v1.1.25

VMSS Flex Support: Add a new vmType for pure VMSS Flex cluster to bypass the node type check

added back stable labels

removing apostrophe

chore(deps): bump golang.org/x/text from 0.3.8 to 0.4.0

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.8 to 0.4.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](golang/text@v0.3.8...v0.4.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Adjust e2e tests
* Can avoid printing stdout and stderr when run kubectl
* Service CIDR is hardcoded to IPv4 for AKS pipeline

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>

update go version params of github action

Signed-off-by: MartinForReal <fanshangxiang@gmail.com>

Update release notes for v1.24.9

Update release notes for v1.25.3

add label for release notes pr

Update release notes for v1.23.22

Update release notes for v1.1.25

VMSS Flex Support: Add a new vmType for pure VMSS Flex cluster to bypass the node type check

fix: avoid recreate vmss cache in race condition

feat: use singleflight.Group instead of lock to fix race condition

doc: fix spelling error

chore(deps): bump actions/checkout from 2 to 3

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](stretchr/testify@v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

chore(deps): bump github.com/onsi/ginkgo/v2 from 2.3.0 to 2.4.0

Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/onsi/ginkgo/releases)
- [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md)
- [Commits](onsi/ginkgo@v2.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: github.com/onsi/ginkgo/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

switch azurefile snanshot to management api

return FileShare in CreateSnapshot

use fileshare instead of snapshot

fix unittest

add ListFileShare function

 add comment

change ListFileShare function

chore: describe and get pod log when it is failed

Refactor e2e and print more Pod info if unexpected error

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>

VMSS Flex Support: add VMSS Flex related contents to Cloud-Provider-Azure Docs

VMSS Flex Support: add VMSS Flex related contents to Cloud-Provider-Azure Docs

VMSS Flex Support: add VMSS Flex related contents to Cloud-Provider-Azure Docs

VMSS Flex Support: add VMSS Flex related contents to Cloud-Provider-Azure Docs

VMSS Flex Support: add VMSS Flex related contents to Cloud-Provider-Azure Docs

VMSS Flex Support: add VMSS Flex related contents to Cloud-Provider-Azure Docs

add more explanation docs

chore(deps): bump github.com/spf13/cobra from 1.6.0 to 1.6.1

Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](spf13/cobra@v1.6.0...v1.6.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

bump compute version to 2022-03-01

update helm chart to 1.25.3

remove kubeversion because semver doesn't recognise v1.24.8-rc.0.15+310b6ffb01918a

chore(deps): bump github.com/onsi/gomega from 1.22.1 to 1.23.0

Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.22.1 to 1.23.0.
- [Release notes](https://github.com/onsi/gomega/releases)
- [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md)
- [Commits](onsi/gomega@v1.22.1...v1.23.0)

---
updated-dependencies:
- dependency-name: github.com/onsi/gomega
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

modified license

removed thing
  • Loading branch information
bsoghigian committed Oct 28, 2022
1 parent b6bdfb1 commit 67c2407
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 163 deletions.
35 changes: 1 addition & 34 deletions pkg/nodemanager/nodemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,7 @@ var labelReconcileInfo = []struct {
primaryKey string
secondaryKey string
ensureSecondaryExists bool
}{
{
// Reconcile the beta and the GA zone label using the beta label as
// the source of truth
// TODO: switch the primary key to GA labels in v1.21
primaryKey: v1.LabelZoneFailureDomain,
secondaryKey: v1.LabelZoneFailureDomainStable,
ensureSecondaryExists: true,
},
{
// Reconcile the beta and the stable region label using the beta label as
// the source of truth
// TODO: switch the primary key to GA labels in v1.21
primaryKey: v1.LabelZoneRegion,
secondaryKey: v1.LabelZoneRegionStable,
ensureSecondaryExists: true,
},
{
// Reconcile the beta and the stable instance-type label using the beta label as
// the source of truth
// TODO: switch the primary key to GA labels in v1.21
primaryKey: v1.LabelInstanceType,
secondaryKey: v1.LabelInstanceTypeStable,
ensureSecondaryExists: true,
},
}
}{}

// UpdateNodeSpecBackoff is the back configure for node update.
var UpdateNodeSpecBackoff = wait.Backoff{
Expand Down Expand Up @@ -464,44 +439,36 @@ func (cnc *CloudNodeController) getNodeModifiersFromCloudProvider(ctx context.Co
if instanceType, err := cnc.getInstanceTypeByName(ctx, node); err != nil {
return nil, err
} else if instanceType != "" {
klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelInstanceType, instanceType)
klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelInstanceTypeStable, instanceType)
nodeModifiers = append(nodeModifiers, func(n *v1.Node) {
if n.Labels == nil {
n.Labels = map[string]string{}
}
n.Labels[v1.LabelInstanceType] = instanceType
n.Labels[v1.LabelInstanceTypeStable] = instanceType
})
}

zone, err := cnc.getZoneByName(ctx, node)
if err != nil {
return nil, fmt.Errorf("failed to get zone from cloud provider: %w", err)
}
if zone.FailureDomain != "" {
klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelZoneFailureDomain, zone.FailureDomain)
klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelZoneFailureDomainStable, zone.FailureDomain)
nodeModifiers = append(nodeModifiers, func(n *v1.Node) {
if n.Labels == nil {
n.Labels = map[string]string{}
}
n.Labels[v1.LabelZoneFailureDomain] = zone.FailureDomain
n.Labels[v1.LabelZoneFailureDomainStable] = zone.FailureDomain
})
}
if zone.Region != "" {
klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelZoneRegion, zone.Region)
klog.V(2).Infof("Adding node label from cloud provider: %s=%s", v1.LabelZoneRegionStable, zone.Region)
nodeModifiers = append(nodeModifiers, func(n *v1.Node) {
if n.Labels == nil {
n.Labels = map[string]string{}
}
n.Labels[v1.LabelZoneRegion] = zone.Region
n.Labels[v1.LabelZoneRegionStable] = zone.Region
})
}

platformSubFaultDomain, err := cnc.getPlatformSubFaultDomain()
if err != nil {
return nil, fmt.Errorf("failed to get platformSubFaultDomain: %w", err)
Expand Down
139 changes: 10 additions & 129 deletions pkg/nodemanager/nodemanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package nodemanager
import (
"context"
"errors"
"reflect"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -404,17 +404,12 @@ func TestZoneInitialized(t *testing.T) {
cloudNodeController.AddCloudNode(context.TODO(), fnh.Existing[0])

assert.Equal(t, 1, len(fnh.UpdatedNodes), "Node was not updated")
fmt.Println(fnh.UpdatedNodes[0].ObjectMeta.Labels)
assert.Equal(t, "eastus", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneRegionStable])
assert.Equal(t, "eastus-1", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneFailureDomainStable])
assert.Equal(t, "node0", fnh.UpdatedNodes[0].Name, "Node was not updated")
assert.Equal(t, 6, len(fnh.UpdatedNodes[0].ObjectMeta.Labels),
assert.Equal(t, 3, len(fnh.UpdatedNodes[0].ObjectMeta.Labels),
"Node label for Region and Zone were not set")
assert.Equal(t, "eastus", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneRegionStable],
"Node Region not correctly updated")
assert.Equal(t, "eastus-1", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneFailureDomainStable],
"Node FailureDomain not correctly updated")
assert.Equal(t, "eastus", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneRegion],
"Node Region not correctly updated")
assert.Equal(t, "eastus-1", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneFailureDomain],
"Node FailureDomain not correctly updated")
}

// This test checks that a node with the external cloud provider taint is cloudprovider initialized and
Expand Down Expand Up @@ -466,10 +461,7 @@ func TestAddCloudNode(t *testing.T) {
mockNP := mocknodeprovider.NewMockNodeProvider(ctrl)
mockNP.EXPECT().InstanceID(gomock.Any(), types.NodeName("node0")).Return("node0", nil)
mockNP.EXPECT().InstanceType(gomock.Any(), types.NodeName("node0")).Return("Standard_D2_v3", nil)
mockNP.EXPECT().GetZone(gomock.Any(), gomock.Any()).Return(cloudprovider.Zone{
Region: "eastus",
FailureDomain: "eastus-1",
}, nil)

mockNP.EXPECT().NodeAddresses(gomock.Any(), types.NodeName("node0")).Return([]v1.NodeAddress{
{
Type: v1.NodeHostName,
Expand All @@ -484,6 +476,10 @@ func TestAddCloudNode(t *testing.T) {
Address: "132.143.154.163",
},
}, nil).AnyTimes()
mockNP.EXPECT().GetZone(gomock.Any(), gomock.Any()).Return(cloudprovider.Zone{
Region: "eastus",
FailureDomain: "eastus-1",
}, nil)
mockNP.EXPECT().GetPlatformSubFaultDomain().Return("", nil)

factory := informers.NewSharedInformerFactory(fnh, 0)
Expand Down Expand Up @@ -669,121 +665,6 @@ func TestNodeProvidedIPAddresses(t *testing.T) {
assert.Equal(t, "10.0.0.1", updatedNodes[0].Status.Addresses[0].Address, "Node Addresses not correctly updated")
}

func Test_reconcileNodeLabels(t *testing.T) {
testcases := []struct {
name string
labels map[string]string
expectedLabels map[string]string
expectedErr error
}{
{
name: "no labels",
labels: map[string]string{},
expectedLabels: map[string]string{},
expectedErr: nil,
},
{
name: "requires reconcile",
labels: map[string]string{
v1.LabelZoneFailureDomain: "foo",
v1.LabelZoneRegion: "bar",
v1.LabelInstanceType: "the-best-type",
},
expectedLabels: map[string]string{
v1.LabelZoneFailureDomain: "foo",
v1.LabelZoneRegion: "bar",
v1.LabelZoneFailureDomainStable: "foo",
v1.LabelZoneRegionStable: "bar",
v1.LabelInstanceType: "the-best-type",
v1.LabelInstanceTypeStable: "the-best-type",
},
expectedErr: nil,
},
{
name: "doesn't require reconcile",
labels: map[string]string{
v1.LabelZoneFailureDomain: "foo",
v1.LabelZoneRegion: "bar",
v1.LabelZoneFailureDomainStable: "foo",
v1.LabelZoneRegionStable: "bar",
v1.LabelInstanceType: "the-best-type",
v1.LabelInstanceTypeStable: "the-best-type",
},
expectedLabels: map[string]string{
v1.LabelZoneFailureDomain: "foo",
v1.LabelZoneRegion: "bar",
v1.LabelZoneFailureDomainStable: "foo",
v1.LabelZoneRegionStable: "bar",
v1.LabelInstanceType: "the-best-type",
v1.LabelInstanceTypeStable: "the-best-type",
},
expectedErr: nil,
},
{
name: "require reconcile -- secondary labels are different from primary",
labels: map[string]string{
v1.LabelZoneFailureDomain: "foo",
v1.LabelZoneRegion: "bar",
v1.LabelZoneFailureDomainStable: "wrongfoo",
v1.LabelZoneRegionStable: "wrongbar",
v1.LabelInstanceType: "the-best-type",
v1.LabelInstanceTypeStable: "the-wrong-type",
},
expectedLabels: map[string]string{
v1.LabelZoneFailureDomain: "foo",
v1.LabelZoneRegion: "bar",
v1.LabelZoneFailureDomainStable: "foo",
v1.LabelZoneRegionStable: "bar",
v1.LabelInstanceType: "the-best-type",
v1.LabelInstanceTypeStable: "the-best-type",
},
expectedErr: nil,
},
}

for _, test := range testcases {
t.Run(test.name, func(t *testing.T) {
testNode := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node01",
Labels: test.labels,
},
}

clientset := fake.NewSimpleClientset(testNode)
factory := informers.NewSharedInformerFactory(clientset, 0)

cnc := &CloudNodeController{
kubeClient: clientset,
nodeInformer: factory.Core().V1().Nodes(),
}

// activate node informer
factory.Core().V1().Nodes().Informer()
factory.Start(nil)
factory.WaitForCacheSync(nil)

err := cnc.reconcileNodeLabels(testNode)
if !errors.Is(err, test.expectedErr) {
t.Logf("actual err: %v", err)
t.Logf("expected err: %v", test.expectedErr)
t.Errorf("unexpected error")
}

actualNode, err := clientset.CoreV1().Nodes().Get(context.TODO(), "node01", metav1.GetOptions{})
if err != nil {
t.Fatalf("error getting updated node: %v", err)
}

if !reflect.DeepEqual(actualNode.Labels, test.expectedLabels) {
t.Logf("actual node labels: %v", actualNode.Labels)
t.Logf("expected node labels: %v", test.expectedLabels)
t.Errorf("updated node did not match expected node")
}
})
}
}

// Tests that node address changes are detected correctly
func TestNodeAddressesChangeDetected(t *testing.T) {
addressSet1 := []v1.NodeAddress{
Expand Down

0 comments on commit 67c2407

Please sign in to comment.