Commit 4b7787c0 authored by Bill Maxwell's avatar Bill Maxwell Committed by Alena Prokharchyk
Browse files

Update isEqual method to handle nil empty maps as the same

The node objects were constantly being updated when one of the objects
had a an empty map {} vs a nil map. This comparison takes that into account
and treats them the same. Also, if the objects are not equal a debug
statement was added to see which comparison test was false.
parent 0c846501
master 2.4 2.4-head 2.5-head Tejeev-patch-1 add-tiller aecdb0589 alpha ansilh-cs-status-logging apr102 bump_machine_version cert-manager-caps cfbd0d3 cloudnautique-patch-1 clusterapi-controller codyrancher-patch-1 cwarren/automate_private_registry_1 dev dnoland1-cores-metric-patch dnoland1-patch-1 dnoland1-patch-2 dnoland1-patch-3 dnoland1-patch-4 fixmonitoringtime kinarashah-patch-1 mrajashree-patch-1 not-release/v2.5.11 paynejacob-patch-1 paynejacob-patch-1-1 rc-19 release/v1.1 release/v2.0 release/v2.0.8 release/v2.1 release/v2.2 release/v2.2.2-patch release/v2.3 release/v2.4 release/v2.4.12 release/v2.4.15 release/v2.4.4 release/v2.5 release/v2.5.11 release/v2.5.11-alt release/v2.5.11-patch1 release/v2.5.3 release/v2.5.5 release/v2.5.7 release/v2.5.7-patch1 release/v2.5.8 release/v2.5.8-patch1 release/v2.5.8-patch2 release/v2.5.8-patch3 release/v2.5.8-rc1 release/v2.5.9 release/v2.5.9-debug1 release/v2.6 release/v2.6.2 revert-14707-updateGolang revert-15750-samlLogin revert-26455-dev-system-charts-v2.3 revert-26644-lasso revert-26947-skiep-tests-2.3 revert-26948-skip-tests-2.4 revert-27219-bp_uiissues revert-27223-bp_ghEmail revert-28602-back-to-dev revert-28691-revert-28602-back-to-dev revert-29888-revert-ingress-version-fwd revert-29936-fleet-gitjob-proxy-support revert-30122-moveauth2.4 revert-30671-release/v2.5 revert-30698-revert-30671-release/v2.5 revert-31102-restrictedadminrancher revert-31118-fwd_restrictedadmin revert-31446-add-gke-transport-proxy-2.4 revert-35793-temporarily-disable-fossa snyk-fix-0564176c790784e319dbf499a8a4b2b8 update-issue-templates update_to_k8s_112 v2.1.0 v2.1.6 Tags unavailable
No related merge requests found
Showing with 9 additions and 7 deletions
+9 -7
......@@ -236,11 +236,7 @@ func deleteNode(nodeDir string, node *v3.Node) error {
return err
}
if err := command.Wait(); err != nil {
return err
}
return nil
return command.Wait()
}
func getSSHPrivateKey(nodeDir string, node *v3.Node) (string, error) {
......
......@@ -5,6 +5,7 @@ import (
"reflect"
"github.com/pkg/errors"
"github.com/rancher/norman/types/convert"
nodehelper "github.com/rancher/rancher/pkg/node"
"github.com/rancher/types/apis/core/v1"
"github.com/rancher/types/apis/management.cattle.io/v3"
......@@ -344,7 +345,12 @@ func objectsAreEqual(existing *v3.Node, toUpdate *v3.Node) bool {
nodeNameEqual := toUpdateToCompare.Status.NodeName == existingToCompare.Status.NodeName
requestsEqual := isEqual(toUpdateToCompare.Status.Requested, existingToCompare.Status.Requested)
limitsEqual := isEqual(toUpdateToCompare.Status.Limits, existingToCompare.Status.Limits)
return statusEqual && specEqual && nodeNameEqual && labelsEqual && annotationsEqual && requestsEqual && limitsEqual
retVal := statusEqual && specEqual && nodeNameEqual && labelsEqual && annotationsEqual && requestsEqual && limitsEqual
if !retVal {
logrus.Debugf("ObjectsAreEqualResults for %s: statusEqual: %t specEqual: %t nodeNameEqual: %t labelsEqual: %t annotationsEqual: %t requestsEqual: %t limitsEqual: %t", toUpdate.Name, statusEqual, specEqual, nodeNameEqual, labelsEqual, annotationsEqual, requestsEqual, limitsEqual)
}
return retVal
}
func (m *NodesSyncer) convertNodeToNode(node *corev1.Node, existing *v3.Node, pods map[string][]*corev1.Pod) (*v3.Node, error) {
......@@ -456,7 +462,7 @@ func aggregateRequestAndLimitsForNode(pods []*corev1.Pod) (map[corev1.ResourceNa
}
func isEqual(data1 map[corev1.ResourceName]resource.Quantity, data2 map[corev1.ResourceName]resource.Quantity) bool {
if data1 == nil && data2 == nil {
if convert.IsEmpty(data1) && convert.IsEmpty(data2) {
return true
}
if data1 == nil || data2 == nil {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment