Skip to content

Commit

Permalink
Fix[LocalStorage]: fix scheduler no enough nodes bug
Browse files Browse the repository at this point in the history
Signed-off-by: jie.li <jie.li@daocloud.io>
  • Loading branch information
angel0507 committed Aug 11, 2022
1 parent 90b5abd commit b14e3f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 15 additions & 0 deletions pkg/local-storage/member/controller/scheduler/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ func (r *resources) init(apiClient client.Client, informerCache runtimecache.Cac
})
}

func (r *resources) initilizeTotalStorage() {
nodeList := &apisv1alpha1.LocalStorageNodeList{}
if err := r.apiClient.List(context.TODO(), nodeList); err != nil {
r.logger.WithError(err).Fatal("Failed to list LocalStorageNodes")
}
// initialize total capacity
for i := range nodeList.Items {
if nodeList.Items[i].Status.State == apisv1alpha1.NodeStateReady {
r.addTotalStorage(&nodeList.Items[i])
} else {
r.delTotalStorage(&nodeList.Items[i])
}
}
}

func (r *resources) initilizeResources() {
r.logger.Debug("Initializing resources ...")
volList := &apisv1alpha1.LocalVolumeList{}
Expand Down
5 changes: 1 addition & 4 deletions pkg/local-storage/member/controller/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ func (s *scheduler) Init() {
}

func (s *scheduler) initResources() {

s.once.Do(func() {
s.resourceCollections.apiClient = s.apiClient
})

s.resourceCollections.initilizeResources()

s.resourceCollections.initilizeTotalStorage()
}

// GetNodeCandidates gets available nodes for the volume, used by K8s scheduler
Expand Down

0 comments on commit b14e3f1

Please sign in to comment.