Skip to content

Commit 713e6af

Browse files
authored
Merge pull request #2492 from tedyu/container-info-copy
Make a copy of containerInfo in containerData#GetInfo
2 parents b52edf2 + cbfa6e8 commit 713e6af

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

manager/container.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,17 @@ func (c *containerData) GetInfo(shouldUpdateSubcontainers bool) (*containerInfo,
172172
}
173173
c.infoLastUpdatedTime = c.clock.Now()
174174
}
175-
// Make a copy of the info for the user.
176175
c.lock.Lock()
177176
defer c.lock.Unlock()
178-
return &c.info, nil
177+
cInfo := containerInfo{
178+
Subcontainers: c.info.Subcontainers,
179+
Spec: c.info.Spec,
180+
}
181+
cInfo.Id = c.info.Id
182+
cInfo.Name = c.info.Name
183+
cInfo.Aliases = c.info.Aliases
184+
cInfo.Namespace = c.info.Namespace
185+
return &cInfo, nil
179186
}
180187

181188
func (c *containerData) DerivedStats() (v2.DerivedStats, error) {

0 commit comments

Comments
 (0)