Skip to content

Fix: update node labels failed #942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/job/runtime_v2/client/kube_runtime_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func NewNodeHandler(q workqueue.RateLimitingInterface, cluster string) *NodeHand
}
resourceFilters := strings.TrimSpace(os.Getenv(pfschema.EnvPFResourceFilter))
if len(resourceFilters) > 0 {
filters := strings.Split(nodeLabels, ",")
filters := strings.Split(resourceFilters, ",")
rFilter = append(rFilter, filters...)
}
return &NodeHandler{
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type NodeInfo struct {
Status string `gorm:"column:status" json:"nodeStatus"`
CapacityJSON string `gorm:"column:capacity" json:"-"`
Capacity map[string]string `gorm:"-" json:"nodeCapacity"`
LabelsJSON string `gorm:"labels" json:"-"`
LabelsJSON string `gorm:"column:labels" json:"-"`
Labels map[string]string `gorm:"-" json:"nodeLabels"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/cache_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (nc *ClusterNodeCache) UpdateNode(nodeID string, nodeInfo *model.NodeInfo)
log.Debugf("begin to update node. node id:%s", nodeID)

return WithTransaction(nc.dbCache, func(tx *gorm.DB) error {
err := tx.Model(&model.NodeInfo{}).Where("id = ?", nodeID).Updates(nodeInfo).Error
err := tx.Model(nodeInfo).Where("id = ?", nodeID).Updates(nodeInfo).Error
if err != nil {
log.Errorf("update node failed. node id:%s, error:%s", nodeID, err)
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/cache_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestNodeCache(t *testing.T) {
assert.Equal(t, nil, err)

updatedNode := &model.NodeInfo{
ID: mockNodeID,
Status: "NotReady",
Labels: map[string]string{
"xxx/queue-name": "test-queue",
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/cache_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (cpc *ClusterPodCache) DeletePod(podID string) error {
func (cpc *ClusterPodCache) UpdatePod(podID string, podInfo *model.PodInfo) error {
log.Debugf("begin to update pod. pod id:%s", podID)
return WithTransaction(cpc.dbCache, func(tx *gorm.DB) error {
err := tx.Model(&model.PodInfo{}).Where("id = ?", podID).Updates(podInfo).Error
err := tx.Model(podInfo).Where("id = ?", podID).Updates(podInfo).Error
if err != nil {
log.Errorf("update pod failed. pod id:%s, error:%s", podID, err)
return err
Expand Down