Skip to content

Commit

Permalink
add forceReleaseStopContainerFile
Browse files Browse the repository at this point in the history
  • Loading branch information
quzard committed Jan 13, 2025
1 parent 839de1a commit bcd7e04
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions plugins/input/docker/logmeta/metric_container_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type InputDockerFile struct {
matchList map[string]*helper.DockerInfoDetail
CollectingContainersMeta bool
firstStart bool

forceReleaseStopContainerFile bool
}

func formatPath(path string) string {
Expand All @@ -133,6 +135,8 @@ func (idf *InputDockerFile) Name() string {
func (idf *InputDockerFile) Init(context pipeline.Context) (int, error) {
idf.context = context

idf.forceReleaseStopContainerFile = os.Getenv("FORCE_RELEASE_STOP_CONTAINER_FILE") == "true"

idf.lastContainerInfoCache = make(map[string]ContainerInfoCache)

idf.firstStart = true
Expand Down Expand Up @@ -476,9 +480,14 @@ func (idf *InputDockerFile) Collect(collector pipeline.Collector) error {
idf.deleteMetric.Add(1)
idf.notifyStop(id)
idf.deleteMapping(id)
} else if c.Status() != helper.ContainerStatusRunning && len(idf.LogPath) > 0 {
// input_file时会触发
idf.notifyStop(id)
} else if c.Status() != helper.ContainerStatusRunning && len(idf.LogPath) > 0 { // input_file时会触发
if idf.forceReleaseStopContainerFile {
idf.deleteMetric.Add(1)
idf.notifyStop(id)
idf.deleteMapping(id)
} else {
idf.notifyStop(id)
}
}
}
if allCmd != nil {
Expand Down

0 comments on commit bcd7e04

Please sign in to comment.