mirror of
https://github.com/lingble/talos.git
synced 2026-01-09 16:11:39 +00:00
fix: prevent panic on nil pointer in ServiceInfo method
Fixes #2138 `FilterMessages` might return `nil` resp if it extracts errors into `err` from `resp`. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
committed by
talos-bot
parent
87793d737c
commit
9ddbf95bb1
@@ -592,13 +592,19 @@ func (c *Client) ServiceInfo(ctx context.Context, id string, callOptions ...grpc
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
return services, err
|
||||
}
|
||||
|
||||
var filtered interface{}
|
||||
filtered, err = FilterMessages(resp, err)
|
||||
resp, _ = filtered.(*machineapi.ServiceListResponse) //nolint: errcheck
|
||||
|
||||
// FilterMessages might remove responses if they actually contain errors,
|
||||
// errors will be merged into `resp`.
|
||||
if resp == nil {
|
||||
return services, err
|
||||
}
|
||||
|
||||
for _, resp := range resp.Messages {
|
||||
for _, svc := range resp.Services {
|
||||
if svc.Id == id {
|
||||
@@ -610,7 +616,7 @@ func (c *Client) ServiceInfo(ctx context.Context, id string, callOptions ...grpc
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
return services, err
|
||||
}
|
||||
|
||||
// ServiceStart starts a service.
|
||||
|
||||
Reference in New Issue
Block a user