@@ -19,10 +19,11 @@ import (
19
19
"strings"
20
20
"sync"
21
21
22
- "github.com/nginx/agent/v3/internal/datasource/host/exec"
23
-
22
+ "github.com/nginx/agent/v3/pkg/host/exec"
24
23
"github.com/nginx/agent/v3/pkg/nginxprocess"
25
24
25
+ "github.com/nginx/agent/v3/pkg/host"
26
+
26
27
parser "github.com/nginx/agent/v3/internal/datasource/config"
27
28
datasource "github.com/nginx/agent/v3/internal/datasource/proto"
28
29
"github.com/nginx/agent/v3/internal/model"
@@ -34,8 +35,6 @@ import (
34
35
35
36
"github.com/nginx/agent/v3/internal/config"
36
37
37
- "github.com/nginx/agent/v3/internal/datasource/host"
38
-
39
38
mpi "github.com/nginx/agent/v3/api/grpc/mpi/v1"
40
39
)
41
40
@@ -398,12 +397,25 @@ func (r *ResourceService) updateResourceInfo(ctx context.Context) {
398
397
r .resourceMutex .Lock ()
399
398
defer r .resourceMutex .Unlock ()
400
399
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
+ }
403
411
r .resource .ResourceId = r .resource .GetContainerInfo ().GetContainerId ()
404
412
r .resource .Instances = []* mpi.Instance {}
405
413
} 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
+ }
407
419
r .resource .ResourceId = r .resource .GetHostInfo ().GetHostId ()
408
420
r .resource .Instances = []* mpi.Instance {}
409
421
}
0 commit comments