Skip to content

allowing for the forced release of stopped container files based on an environment variable(FORCE_RELEASE_STOP_CONTAINER_FILE) #2034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
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
Loading