Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions container/crio/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ type crioContainerHandler struct {
ipAddress string

ignoreMetrics container.MetricSet

// container restart count
restartCount int
}

var _ container.ContainerHandler = &crioContainerHandler{}
Expand Down Expand Up @@ -175,7 +172,10 @@ func newCrioContainerHandler(
// ignore err and get zero as default, this happens with sandboxes, not sure why...
// kube isn't sending restart count in labels for sandboxes.
restartCount, _ := strconv.Atoi(cInfo.Annotations["io.kubernetes.container.restartCount"])
handler.restartCount = restartCount
// Only adds restartcount label if it's greater than 0
if restartCount > 0 {
handler.labels["restartcount"] = strconv.Itoa(restartCount)
}

handler.ipAddress = cInfo.IP

Expand Down Expand Up @@ -225,10 +225,6 @@ func (self *crioContainerHandler) GetSpec() (info.ContainerSpec, error) {
spec, err := common.GetSpec(self.cgroupPaths, self.machineInfoFactory, self.needNet(), hasFilesystem)

spec.Labels = self.labels
// Only adds restartcount label if it's greater than 0
if self.restartCount > 0 {
spec.Labels["restartcount"] = strconv.Itoa(self.restartCount)
}
spec.Envs = self.envs
spec.Image = self.image

Expand Down
11 changes: 4 additions & 7 deletions container/docker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ type dockerContainerHandler struct {

// zfs watcher
zfsWatcher *zfs.ZfsWatcher

// container restart count
restartCount int
}

var _ container.ContainerHandler = &dockerContainerHandler{}
Expand Down Expand Up @@ -251,6 +248,10 @@ func newDockerContainerHandler(
handler.networkMode = ctnr.HostConfig.NetworkMode
handler.deviceID = ctnr.GraphDriver.Data["DeviceId"]
handler.restartCount = ctnr.RestartCount

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line needed to be removed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is correct upstream :-/ not sure how it didn't make the pick.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure either indeed, my bad guys

// Only adds restartcount label if it's greater than 0
if ctnr.RestartCount > 0 {
handler.labels["restartcount"] = strconv.Itoa(ctnr.RestartCount)
}

// Obtain the IP address for the contianer.
// If the NetworkMode starts with 'container:' then we need to use the IP address of the container specified.
Expand Down Expand Up @@ -386,10 +387,6 @@ func (self *dockerContainerHandler) GetSpec() (info.ContainerSpec, error) {
spec, err := common.GetSpec(self.cgroupPaths, self.machineInfoFactory, self.needNet(), hasFilesystem)

spec.Labels = self.labels
// Only adds restartcount label if it's greater than 0
if self.restartCount > 0 {
spec.Labels["restartcount"] = strconv.Itoa(self.restartCount)
}
spec.Envs = self.envs
spec.Image = self.image
spec.CreationTime = self.creationTime
Expand Down