Skip to content

Commit

Permalink
fix possible send fail for enterprise local config on upgrade from il…
Browse files Browse the repository at this point in the history
…ogtail (#2105)
  • Loading branch information
henryzhx8 authored Feb 19, 2025
1 parent ab63061 commit d591ea2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/plugin/flusher/sls/DiskBufferWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ SLSResponse DiskBufferWriter::SendBufferFileData(const sls_logs::LogtailBufferMe
#ifdef __ENTERPRISE__
if (bufferMeta.endpointmode() == sls_logs::EndpointMode::DEFAULT) {
EnterpriseSLSClientManager::GetInstance()->UpdateRemoteRegionEndpoints(
region, {bufferMeta.endpoint()}, EnterpriseSLSClientManager::RemoteEndpointUpdateAction::CREATE);
region, {bufferMeta.endpoint()}, EnterpriseSLSClientManager::RemoteEndpointUpdateAction::APPEND);
}
auto info = EnterpriseSLSClientManager::GetInstance()->GetCandidateHostsInfo(
region, bufferMeta.project(), GetEndpointMode(bufferMeta.endpointmode()));
Expand Down
2 changes: 1 addition & 1 deletion core/plugin/flusher/sls/FlusherSLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ bool FlusherSLS::Init(const Json::Value& config, Json::Value& optionalGoPipeline
mContext->GetRegion());
}
EnterpriseSLSClientManager::GetInstance()->UpdateRemoteRegionEndpoints(
mRegion, {mEndpoint}, EnterpriseSLSClientManager::RemoteEndpointUpdateAction::CREATE);
mRegion, {mEndpoint}, EnterpriseSLSClientManager::RemoteEndpointUpdateAction::APPEND);
}
mCandidateHostsInfo
= EnterpriseSLSClientManager::GetInstance()->GetCandidateHostsInfo(mRegion, mProject, mEndpointMode);
Expand Down
7 changes: 4 additions & 3 deletions core/unittest/flusher/FlusherSLSUnittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void FlusherSLSUnittest::OnSuccessfulInit() {
APSARA_TEST_EQUAL(EndpointMode::ACCELERATE, flusher->mCandidateHostsInfo->GetMode());
SenderQueueManager::GetInstance()->Clear();

// Endpoint should be added to region remote endpoints if not existed
// region remote endpoints not existed
configStr = R"(
{
"Type": "flusher_sls",
Expand All @@ -294,7 +294,7 @@ void FlusherSLSUnittest::OnSuccessfulInit() {
APSARA_TEST_EQUAL(EndpointMode::DEFAULT, flusher->mCandidateHostsInfo->GetMode());
SenderQueueManager::GetInstance()->Clear();

// Endpoint should be ignored when region remote endpoints existed
// region remote endpoints existed
configStr = R"(
{
"Type": "flusher_sls",
Expand All @@ -312,8 +312,9 @@ void FlusherSLSUnittest::OnSuccessfulInit() {
APSARA_TEST_TRUE(flusher->Init(configJson, optionalGoPipeline));
APSARA_TEST_EQUAL(EndpointMode::DEFAULT, flusher->mEndpointMode);
endpoints = EnterpriseSLSClientManager::GetInstance()->mRegionCandidateEndpointsMap["test_region"].mRemoteEndpoints;
APSARA_TEST_EQUAL(1U, endpoints.size());
APSARA_TEST_EQUAL(2U, endpoints.size());
APSARA_TEST_EQUAL("test_region.log.aliyuncs.com", endpoints[0]);
APSARA_TEST_EQUAL("test_region-intranet.log.aliyuncs.com", endpoints[1]);
APSARA_TEST_EQUAL(flusher->mProject, flusher->mCandidateHostsInfo->GetProject());
APSARA_TEST_EQUAL(flusher->mRegion, flusher->mCandidateHostsInfo->GetRegion());
APSARA_TEST_EQUAL(EndpointMode::DEFAULT, flusher->mCandidateHostsInfo->GetMode());
Expand Down

0 comments on commit d591ea2

Please sign in to comment.