Skip to content

Commit

Permalink
Enable forced release files of stopped container via environment vari…
Browse files Browse the repository at this point in the history
…able control (#2034)
  • Loading branch information
quzard authored Jan 23, 2025
1 parent 183af3a commit 5c8eff8
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 @@ -134,6 +136,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 @@ -477,9 +481,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 5c8eff8

Please sign in to comment.