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

feat: reload pipeline config independently #1713

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

Abingcbc
Copy link
Collaborator

@Abingcbc Abingcbc commented Aug 22, 2024

背景

目前加载配置都是全量停止,全量重新加载和全量启动。这会造成一些没有变化的配置的重复加载。使得转发类和抓取类Input的流水线出现采集中断

方案

C++

重新实现了加载逻辑,不会在加载配置前停止所有流水线,按照如下的顺序,独立加载

  1. 新流水线创建
  2. 旧流水线停止
  3. 新流水线启动

Go

修改了CGO接口,提供了新的Go流水线加载接口,命名与C++侧统一。

  1. StopAll:用于进程退出
  2. Stop:停止指定配置
  3. Start:启动指定配置

@Abingcbc Abingcbc changed the title feat: reload Go pipeline config independently feat: reload pipeline config independently Aug 26, 2024
Copy link
Collaborator

@henryzhx8 henryzhx8 left a comment

Choose a reason for hiding this comment

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

配置变更的时候是先init新的,然后stop老的,再start新的,目前看代码里是不支持这种模式的

@Abingcbc Abingcbc marked this pull request as ready for review September 16, 2024 08:51
@Abingcbc Abingcbc marked this pull request as draft September 16, 2024 09:15
@Abingcbc Abingcbc marked this pull request as ready for review September 18, 2024 03:06
Copy link
Collaborator

Choose a reason for hiding this comment

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

以下接口已经废弃,直接移除:ProcessRawLog、ProcessRawLogV2、ProcessLog(C++ observer代码有依赖,但是observer也会整体废除,所以可以不用管)

plugin_main/plugin_export.go Outdated Show resolved Hide resolved
@@ -134,10 +133,6 @@ func LoadGlobalConfig(jsonStr string) int {
//export LoadConfig
func LoadConfig(project string, logstore string, configName string, logstoreKey int64, jsonStr string) int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个接口需要从长计议,logstorekey这个肯定不能要,但是Go流水线需要知道是不是要往C++发送,所以这个信息也是需要放到Go的GlobalConfig里的。flusher的IsReady函数需要进行修改,理论上不应该传logstorekey,而应该传configname

plugin_main/plugin_export.go Show resolved Hide resolved
plugin_main/plugin_export.go Show resolved Hide resolved
core/pipeline/Pipeline.cpp Outdated Show resolved Hide resolved
Comment on lines 32 to 39
if (HasContext()) {
unique_ptr<SenderQueueItem> tombStone = make_unique<SenderQueueItem>("", 0, this, mQueueKey);
tombStone->mPipeline = PipelineManager::GetInstance()->FindConfigByName(mContext->GetConfigName());
if (!tombStone->mPipeline) {
LOG_ERROR(sLogger, ("failed to find pipeline when stop flusher", mContext->GetConfigName()));
}
SenderQueueManager::GetInstance()->PushQueue(mQueueKey, std::move(tombStone));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的实现肯定不对,要是这么简单当时就这么弄了,去看一下senderqueue的实现,想一想这么写能保证tombstone在所有item之后再pop吗

core/pipeline/Pipeline.h Outdated Show resolved Hide resolved
core/pipeline/queue/ProcessQueueItem.h Outdated Show resolved Hide resolved
core/pipeline/PipelineManager.cpp Show resolved Hide resolved
plugin_main/plugin_export.go Outdated Show resolved Hide resolved
pluginmanager/logstore_config.go Outdated Show resolved Hide resolved
pluginmanager/plugin_manager.go Outdated Show resolved Hide resolved
core/go_pipeline/LogtailPlugin.cpp Outdated Show resolved Hide resolved
core/pipeline/plugin/interface/Flusher.cpp Outdated Show resolved Hide resolved
core/pipeline/plugin/interface/Flusher.cpp Outdated Show resolved Hide resolved
core/pipeline/plugin/interface/Flusher.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/ProcessQueueItem.h Show resolved Hide resolved
core/pipeline/Pipeline.cpp Outdated Show resolved Hide resolved
core/pipeline/Pipeline.cpp Outdated Show resolved Hide resolved
@@ -2841,6 +2853,29 @@ void PipelineUnittest::TestFlushBatch() const {
}
}

void PipelineUnittest::TestInProcessingCount() const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

UT很弱,没有什么针对性的用例

plugin_main/plugin_export.go Outdated Show resolved Hide resolved
core/pipeline/queue/BoundedProcessQueue.h Outdated Show resolved Hide resolved
core/pipeline/queue/ExactlyOnceQueueManager.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/ProcessQueueManager.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/BoundedSenderQueueInterface.h Outdated Show resolved Hide resolved
core/pipeline/queue/SenderQueue.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/SenderQueue.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/ExactlyOnceSenderQueue.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/SenderQueueManager.cpp Outdated Show resolved Hide resolved
core/pipeline/plugin/interface/Flusher.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/ExactlyOnceSenderQueue.cpp Outdated Show resolved Hide resolved
core/pipeline/queue/SenderQueue.cpp Outdated Show resolved Hide resolved
core/runner/ProcessorRunner.h Outdated Show resolved Hide resolved
core/runner/ProcessorRunner.h Outdated Show resolved Hide resolved
core/pipeline/PipelineManager.h Show resolved Hide resolved
@@ -37,37 +36,36 @@ using namespace std;

namespace logtail {

PipelineManager::PipelineManager()
: mInputRunners({
PrometheusInputRunner::GetInstance(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

逗号的位置是不是应该在宏里面?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

最后一个元素有逗号应该不影响

core/pipeline/PipelineManager.cpp Outdated Show resolved Hide resolved
core/pipeline/PipelineManager.cpp Outdated Show resolved Hide resolved
core/pipeline/PipelineManager.cpp Outdated Show resolved Hide resolved
plugin_main/plugin_export.go Outdated Show resolved Hide resolved
plugin_main/plugin_export.go Outdated Show resolved Hide resolved
core/pipeline/PipelineManager.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants