mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-03 13:01:16 +02:00
fix(osd): Use correct context in stats endpoint (#644)
Without this we never set the namespace for the context which prevents it from functioning at all Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
This commit is contained in:
parent
967e547d87
commit
a6989db1d1
@ -98,14 +98,14 @@ func (r *Registrator) Processes(ctx context.Context, in *proto.ProcessesRequest)
|
|||||||
// Stats implements the proto.OSDServer interface.
|
// Stats implements the proto.OSDServer interface.
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func (r *Registrator) Stats(ctx context.Context, in *proto.StatsRequest) (reply *proto.StatsReply, err error) {
|
func (r *Registrator) Stats(ctx context.Context, in *proto.StatsRequest) (reply *proto.StatsReply, err error) {
|
||||||
client, _, err := connect(in.Namespace)
|
client, nsctx, err := connect(in.Namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// nolint: errcheck
|
// nolint: errcheck
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
containers, err := client.Containers(ctx)
|
containers, err := client.Containers(nsctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -113,20 +113,20 @@ func (r *Registrator) Stats(ctx context.Context, in *proto.StatsRequest) (reply
|
|||||||
stats := []*proto.Stat{}
|
stats := []*proto.Stat{}
|
||||||
|
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
task, err := container.Task(ctx, nil)
|
task, err := container.Task(nsctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
status, err := task.Status(ctx)
|
status, err := task.Status(nsctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Status == containerd.Running {
|
if status.Status == containerd.Running {
|
||||||
metrics, err := task.Metrics(ctx)
|
metrics, err := task.Metrics(nsctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user