[backport]: handle multiple consecutive slashes in the path
string.
#2045
+75
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述:
当用户在 Kubernetes 配置中使用以多个斜杠开头的挂载路径时(如
//test/log
),会导致 formateContainerPath 获取到的挂载路径与采集配置中的 idf.LogPath 路径(/test/log
)不匹配,从而引发数组越界问题。例如以下挂载配置:
采集路径为
/test/log/**/*.log
修复方案:
优化 formatPath 函数,确保当路径以斜杠开头时,只保留一个斜杠,使路径格式符合标准规范。