Skip to content

Commit

Permalink
feat: load empty return false in persistentcache (#3697)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Dec 10, 2024
1 parent 50cbd6f commit 79a845e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scheduler/resource/persistentcache/host_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (h *hostManager) Load(ctx context.Context, hostID string) (*Host, bool) {
return nil, false
}

if len(rawHost) == 0 {
return nil, false
}

// Set integer fields from raw host.
port, err := strconv.ParseInt(rawHost["port"], 10, 32)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions scheduler/resource/persistentcache/peer_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (p *peerManager) Load(ctx context.Context, peerID string) (*Peer, bool) {
return nil, false
}

if len(rawPeer) == 0 {
return nil, false
}

persistent, err := strconv.ParseBool(rawPeer["persistent"])
if err != nil {
log.Errorf("parsing persistent failed: %v", err)
Expand Down
4 changes: 4 additions & 0 deletions scheduler/resource/persistentcache/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (t *taskManager) Load(ctx context.Context, taskID string) (*Task, bool) {
return nil, false
}

if len(rawTask) == 0 {
return nil, false
}

// Set integer fields from raw task.
persistentReplicaCount, err := strconv.ParseUint(rawTask["persistent_replica_count"], 10, 64)
if err != nil {
Expand Down

0 comments on commit 79a845e

Please sign in to comment.