Skip to content

Commit

Permalink
Merge pull request kosmos-io#452 from qiuming520/release-0.3.0
Browse files Browse the repository at this point in the history
fix: status synchronization error of virtual node in one2one model mode
  • Loading branch information
duanmengkk authored Mar 27, 2024
2 parents 76288a6 + c171683 commit f241775
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/clustertree/cluster-manager/utils/leaf_model_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/util/retry"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -104,6 +105,7 @@ func (h ClassificationHandler) GetLeafPods(ctx context.Context, rootNode *corev1

// UpdateRootNodeStatus updates the node's status in root cluster
func (h ClassificationHandler) UpdateRootNodeStatus(ctx context.Context, nodesInRoot []*corev1.Node, leafNodeSelector map[string]kosmosv1alpha1.NodeSelector) error {
errors := []error{}
for _, node := range nodesInRoot {
nodeNameInRoot := node.Name
listOptions := metav1.ListOptions{}
Expand All @@ -114,6 +116,8 @@ func (h ClassificationHandler) UpdateRootNodeStatus(ctx context.Context, nodesIn
continue
}
listOptions.LabelSelector = metav1.FormatLabelSelector(selector.LabelSelector)
} else if h.leafMode == Node {
listOptions.FieldSelector = fmt.Sprintf("metadata.name=%s", nodeNameInRoot)
}

err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
Expand Down Expand Up @@ -162,10 +166,10 @@ func (h ClassificationHandler) UpdateRootNodeStatus(ctx context.Context, nodesIn
return nil
})
if err != nil {
return err
errors = append(errors, err)
}
}
return nil
return utilerrors.NewAggregate(errors)
}

func createNode(ctx context.Context, clientset kubernetes.Interface, clusterName, nodeName, gitVersion string, listenPort int32) (*corev1.Node, error) {
Expand Down

0 comments on commit f241775

Please sign in to comment.