@@ -918,9 +918,9 @@ func (c *CriManager) attachLog(logPath string, containerID string, openStdin boo
918918func (c * CriManager ) getContainerMetrics (ctx context.Context , meta * mgr.Container ) (* runtime.ContainerStats , error ) {
919919 var usedBytes , inodesUsed uint64
920920
921- stats , _ , err := c . ContainerMgr . Stats ( ctx , meta .ID )
921+ metadata , err := parseContainerName ( meta .Name )
922922 if err != nil {
923- return nil , fmt .Errorf ("failed to get stats of container %q: %v" , meta .ID , err )
923+ return nil , fmt .Errorf ("failed to get metadata of container %q: %v" , meta .ID , err )
924924 }
925925
926926 sn , err := c .SnapshotStore .Get (meta .ID )
@@ -938,12 +938,6 @@ func (c *CriManager) getContainerMetrics(ctx context.Context, meta *mgr.Containe
938938 UsedBytes : & runtime.UInt64Value {usedBytes },
939939 InodesUsed : & runtime.UInt64Value {inodesUsed },
940940 }
941-
942- metadata , err := parseContainerName (meta .Name )
943- if err != nil {
944- return nil , fmt .Errorf ("failed to get metadata of container %q: %v" , meta .ID , err )
945- }
946-
947941 labels , annotations := extractLabels (meta .Config .Labels )
948942
949943 cs .Attributes = & runtime.ContainerAttributes {
@@ -953,6 +947,11 @@ func (c *CriManager) getContainerMetrics(ctx context.Context, meta *mgr.Containe
953947 Annotations : annotations ,
954948 }
955949
950+ stats , _ , err := c .ContainerMgr .Stats (ctx , meta .ID )
951+ if err != nil {
952+ return nil , fmt .Errorf ("failed to get stats of container %q: %v" , meta .ID , err )
953+ }
954+
956955 if stats != nil {
957956 s , err := typeurl .UnmarshalAny (stats .Data )
958957 if err != nil {
0 commit comments