Skip to content
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

fix enable containerd upper dir detect not effective #2041

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions core/common/LogtailCommonFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
// 1024 * 50);
// #endif
// DEFINE_FLAG_BOOL(enable_sls_metrics_format, "if enable format metrics in SLS metricstore log pattern", false);
// DEFINE_FLAG_BOOL(enable_containerd_upper_dir_detect,
// "if enable containerd upper dir detect when locating rootfs",
Copy link
Collaborator

Choose a reason for hiding this comment

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

想不想要不要都删掉

// false);
// DEFINE_FLAG_INT32(profile_data_send_interval, "interval of send LogFile/DomainSocket profile data, seconds", 600);
// DEFINE_FLAG_STRING(logtail_profile_snapshot, "reader profile on local disk", "logtail_profile_snapshot");
// DEFINE_FLAG_BOOL(default_secondary_storage, "default strategy whether enable secondary storage", false);
Expand Down
4 changes: 0 additions & 4 deletions core/go_pipeline/LogtailPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
#endif

DEFINE_FLAG_BOOL(enable_sls_metrics_format, "if enable format metrics in SLS metricstore log pattern", false);
DEFINE_FLAG_BOOL(enable_containerd_upper_dir_detect,
"if enable containerd upper dir detect when locating rootfs",
false);

using namespace std;
using namespace logtail;
Expand Down Expand Up @@ -76,7 +73,6 @@ LogtailPlugin::LogtailPlugin() {
mPluginCfg["LoongcollectorPrometheusAuthorizationPath"] = GetAgentPrometheusAuthorizationPath();
mPluginCfg["HostIP"] = LoongCollectorMonitor::mIpAddr;
mPluginCfg["Hostname"] = LoongCollectorMonitor::mHostname;
mPluginCfg["EnableContainerdUpperDirDetect"] = BOOL_FLAG(enable_containerd_upper_dir_detect);
mPluginCfg["EnableSlsMetricsFormat"] = BOOL_FLAG(enable_sls_metrics_format);
}

Expand Down
2 changes: 0 additions & 2 deletions core/logtail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ DECLARE_FLAG_STRING(metrics_report_method);
DECLARE_FLAG_INT32(data_server_port);
DECLARE_FLAG_BOOL(enable_env_ref_in_config);
DECLARE_FLAG_BOOL(enable_sls_metrics_format);
DECLARE_FLAG_BOOL(enable_containerd_upper_dir_detect);
DECLARE_FLAG_BOOL(logtail_mode);

void HandleSigtermSignal(int signum, siginfo_t* info, void* context) {
Expand Down Expand Up @@ -84,7 +83,6 @@ static void overwrite_community_edition_flags() {
STRING_FLAG(metrics_report_method) = "";
INT32_FLAG(data_server_port) = 443;
BOOL_FLAG(enable_env_ref_in_config) = true;
BOOL_FLAG(enable_containerd_upper_dir_detect) = true;
BOOL_FLAG(enable_sls_metrics_format) = false;
}

Expand Down
2 changes: 0 additions & 2 deletions core/logtail_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ DECLARE_FLAG_STRING(metrics_report_method);
DECLARE_FLAG_INT32(data_server_port);
DECLARE_FLAG_BOOL(enable_env_ref_in_config);
DECLARE_FLAG_BOOL(enable_sls_metrics_format);
DECLARE_FLAG_BOOL(enable_containerd_upper_dir_detect);

static void overwrite_community_edition_flags() {
// support run in installation dir on default
STRING_FLAG(metrics_report_method) = "";
INT32_FLAG(data_server_port) = 443;
BOOL_FLAG(enable_env_ref_in_config) = true;
BOOL_FLAG(enable_containerd_upper_dir_detect) = true;
BOOL_FLAG(enable_sls_metrics_format) = false;
}

Expand Down
12 changes: 7 additions & 5 deletions docs/cn/installation/start-with-k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@
```yaml
- name: loongcollector
command:
- /usr/local/loongcollector/loongcollector_control.sh
- /usr/local/loongcollector/loongcollector_control.sh
args:
- "start_and_block"
- "-enable_containerd_upper_dir_detect=true"
- "-dirfile_check_interval_ms=5000"
- "-logtail_checkpoint_check_gc_interval_sec=120"
- "start_and_block"
- "-dirfile_check_interval_ms=5000"
- "-logtail_checkpoint_check_gc_interval_sec=120"
env:
- name: enable_containerd_upper_dir_detect
value: "true"
```

应用上述配置
Expand Down
7 changes: 3 additions & 4 deletions pkg/config/global_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ type GlobalConfig struct {
AlwaysOnline bool
DelayStopSec int

EnableTimestampNanosecond bool
UsingOldContentTag bool
EnableContainerdUpperDirDetect bool
EnableSlsMetricsFormat bool
EnableTimestampNanosecond bool
UsingOldContentTag bool
EnableSlsMetricsFormat bool
}

// LoongcollectorGlobalConfig is the singleton instance of GlobalConfig.
Expand Down
38 changes: 20 additions & 18 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,25 @@ var (

SelfEnvConfigFlag bool

GlobalConfig = flag.String("global", "./global.json", "global config.")
PluginConfig = flag.String("plugin", "./plugin.json", "plugin config.")
FlusherConfig = flag.String("flusher", "./default_flusher.json", "the default flusher configuration is used not only in the plugins without flusher but also to transfer the self telemetry data.")
ForceSelfCollect = flag.Bool("force-statics", false, "force collect self telemetry data before closing.")
AutoProfile = flag.Bool("prof-auto", true, "auto dump prof file when prof-flag is open.")
HTTPProfFlag = flag.Bool("prof-flag", false, "http pprof flag.")
Cpuprofile = flag.String("cpu-profile", "cpu.prof", "write cpu profile to file.")
Memprofile = flag.String("mem-profile", "mem.prof", "write mem profile to file.")
HTTPAddr = flag.String("server", ":18689", "http server address.")
Doc = flag.Bool("doc", false, "generate plugin docs")
DocPath = flag.String("docpath", "./docs/en/plugins", "generate plugin docs")
HTTPLoadFlag = flag.Bool("http-load", false, "export http endpoint for load plugin config.")
FileIOFlag = flag.Bool("file-io", false, "use file for input or output.")
InputFile = flag.String("input-file", "./input.log", "input file")
InputField = flag.String("input-field", "content", "input file")
InputLineLimit = flag.Int("input-line-limit", 1000, "input file")
OutputFile = flag.String("output-file", "./output.log", "output file")
StatefulSetFlag = flag.Bool("ALICLOUD_LOG_STATEFULSET_FLAG", false, "alibaba log export ports flag, set true if you want to use it")
EnableContainerdUpperDirDetect = flag.Bool("enable_containerd_upper_dir_detect", false, "if enable containerd upper dir detect when locating rootfs")
GlobalConfig = flag.String("global", "./global.json", "global config.")
PluginConfig = flag.String("plugin", "./plugin.json", "plugin config.")
FlusherConfig = flag.String("flusher", "./default_flusher.json", "the default flusher configuration is used not only in the plugins without flusher but also to transfer the self telemetry data.")
ForceSelfCollect = flag.Bool("force-statics", false, "force collect self telemetry data before closing.")
AutoProfile = flag.Bool("prof-auto", true, "auto dump prof file when prof-flag is open.")
HTTPProfFlag = flag.Bool("prof-flag", false, "http pprof flag.")
Cpuprofile = flag.String("cpu-profile", "cpu.prof", "write cpu profile to file.")
Memprofile = flag.String("mem-profile", "mem.prof", "write mem profile to file.")
HTTPAddr = flag.String("server", ":18689", "http server address.")
Doc = flag.Bool("doc", false, "generate plugin docs")
DocPath = flag.String("docpath", "./docs/en/plugins", "generate plugin docs")
HTTPLoadFlag = flag.Bool("http-load", false, "export http endpoint for load plugin config.")
FileIOFlag = flag.Bool("file-io", false, "use file for input or output.")
InputFile = flag.String("input-file", "./input.log", "input file")
InputField = flag.String("input-field", "content", "input file")
InputLineLimit = flag.Int("input-line-limit", 1000, "input file")
OutputFile = flag.String("output-file", "./output.log", "output file")
StatefulSetFlag = flag.Bool("ALICLOUD_LOG_STATEFULSET_FLAG", false, "alibaba log export ports flag, set true if you want to use it")

DeployMode = flag.String("DEPLOY_MODE", DeployDaemonset, "alibaba log deploy mode, daemonset or statefulset or singleton")
EnableKubernetesMeta = flag.Bool("ENABLE_KUBERNETES_META", false, "enable kubernetes meta")
Expand Down Expand Up @@ -331,6 +332,7 @@ func init() {
_ = util.InitFromEnvString("ALICLOUD_LOG_REGION", DefaultRegion, *DefaultRegion)
_ = util.InitFromEnvBool("ALICLOUD_LOG_PLUGIN_ENV_CONFIG", DockerConfigPluginInitFlag, *DockerConfigPluginInitFlag)

_ = util.InitFromEnvBool("enable_containerd_upper_dir_detect", EnableContainerdUpperDirDetect, *EnableContainerdUpperDirDetect)
_ = util.InitFromEnvBool("LOGTAIL_DEBUG_FLAG", HTTPProfFlag, *HTTPProfFlag)
_ = util.InitFromEnvBool("LOGTAIL_AUTO_PROF", AutoProfile, *AutoProfile)
_ = util.InitFromEnvBool("LOGTAIL_FORCE_COLLECT_SELF_TELEMETRY", ForceSelfCollect, *ForceSelfCollect)
Expand Down
4 changes: 2 additions & 2 deletions pkg/helper/docker_cri_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"google.golang.org/grpc"
cri "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

"github.com/alibaba/ilogtail/pkg/config"
"github.com/alibaba/ilogtail/pkg/flags"
"github.com/alibaba/ilogtail/pkg/logger"
)

Expand Down Expand Up @@ -173,7 +173,7 @@ func NewCRIRuntimeWrapper(dockerCenter *DockerCenter) (*CRIRuntimeWrapper, error
}

var containerdClient *containerd.Client
if config.LoongcollectorGlobalConfig.EnableContainerdUpperDirDetect {
if *flags.EnableContainerdUpperDirDetect {
containerdClient, err = containerd.New(containerdUnixSocket, containerd.WithDefaultNamespace("k8s.io"))
if err == nil {
_, err = containerdClient.Version(context.Background())
Expand Down
Loading