Skip to content

Commit

Permalink
Merge pull request #416 from gunjan5/kdd-isreadypod
Browse files Browse the repository at this point in the history
Return ErrorResourceDoesNotExist when pod is not ready to be displayed
  • Loading branch information
gunjan5 authored May 9, 2017
2 parents fbc28ba + 00226b7 commit 4c64e80
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/backend/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,15 @@ func (c *KubeClient) listWorkloadEndpoints(l model.WorkloadEndpointListOptions)
WorkloadID: l.WorkloadID,
})
if err != nil {
// Error getting the endpoint.
return nil, err
}
if kvp == nil {
// The workload endpoint doesn't exist.
return nil, nil
switch err.(type) {
// Return empty slice of KVPair if the object doesn't exist, return the error otherwise.
case errors.ErrorResourceDoesNotExist:
return []*model.KVPair{}, nil
default:
return nil, err
}
}

return []*model.KVPair{kvp}, nil
}

Expand Down Expand Up @@ -547,7 +549,7 @@ func (c *KubeClient) getWorkloadEndpoint(k model.WorkloadEndpointKey) (*model.KV

// Decide if this pod should be displayed.
if !c.converter.isReadyCalicoPod(pod) {
return nil, nil
return nil, errors.ErrorResourceDoesNotExist{Identifier: k}
}
return c.converter.podToWorkloadEndpoint(pod)
}
Expand All @@ -558,8 +560,15 @@ func (c *KubeClient) listPolicies(l model.PolicyListOptions) ([]*model.KVPair, e
// Exact lookup on a NetworkPolicy.
kvp, err := c.getPolicy(model.PolicyKey{Name: l.Name})
if err != nil {
return []*model.KVPair{}, nil
switch err.(type) {
// Return empty slice of KVPair if the object doesn't exist, return the error otherwise.
case errors.ErrorResourceDoesNotExist:
return []*model.KVPair{}, nil
default:
return nil, err
}
}

return []*model.KVPair{kvp}, nil
}

Expand Down

0 comments on commit 4c64e80

Please sign in to comment.