@@ -19,10 +19,11 @@ import (
1919 "strings"
2020 "sync"
2121
22- "github.com/nginx/agent/v3/internal/datasource/host/exec"
23-
22+ "github.com/nginx/agent/v3/pkg/host/exec"
2423 "github.com/nginx/agent/v3/pkg/nginxprocess"
2524
25+ "github.com/nginx/agent/v3/pkg/host"
26+
2627 parser "github.com/nginx/agent/v3/internal/datasource/config"
2728 datasource "github.com/nginx/agent/v3/internal/datasource/proto"
2829 "github.com/nginx/agent/v3/internal/model"
@@ -34,8 +35,6 @@ import (
3435
3536 "github.com/nginx/agent/v3/internal/config"
3637
37- "github.com/nginx/agent/v3/internal/datasource/host"
38-
3938 mpi "github.com/nginx/agent/v3/api/grpc/mpi/v1"
4039)
4140
@@ -398,12 +397,25 @@ func (r *ResourceService) updateResourceInfo(ctx context.Context) {
398397 r .resourceMutex .Lock ()
399398 defer r .resourceMutex .Unlock ()
400399
401- if r .info .IsContainer () {
402- r .resource .Info = r .info .ContainerInfo (ctx )
400+ isContainer , err := r .info .IsContainer ()
401+ if err != nil {
402+ slog .WarnContext (ctx , "Failed to check if resource is container" , "error" , err )
403+ }
404+
405+ if isContainer {
406+ r .resource .Info , err = r .info .ContainerInfo (ctx )
407+ if err != nil {
408+ slog .ErrorContext (ctx , "Failed to get container info" , "error" , err )
409+ return
410+ }
403411 r .resource .ResourceId = r .resource .GetContainerInfo ().GetContainerId ()
404412 r .resource .Instances = []* mpi.Instance {}
405413 } else {
406- r .resource .Info = r .info .HostInfo (ctx )
414+ r .resource .Info , err = r .info .HostInfo (ctx )
415+ if err != nil {
416+ slog .ErrorContext (ctx , "Failed to get host info" , "error" , err )
417+ return
418+ }
407419 r .resource .ResourceId = r .resource .GetHostInfo ().GetHostId ()
408420 r .resource .Instances = []* mpi.Instance {}
409421 }
0 commit comments