diff options
| author | Dan Engelbrecht <[email protected]> | 2026-04-08 17:42:57 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-08 17:42:57 +0200 |
| commit | 110aa738efe8f30afd16461fb6e6ee238624f714 (patch) | |
| tree | 2059294cec9792c2f5e3cc16ea7f1dbd6e25bfa8 /src | |
| parent | use correct return code for unsupported multirange requests in objectstore (#... (diff) | |
| download | zen-110aa738efe8f30afd16461fb6e6ee238624f714.tar.xz zen-110aa738efe8f30afd16461fb6e6ee238624f714.zip | |
fully provisioned hub instances now sets initial check status to "passing" in consul (#930)
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/hub/zenhubserver.cpp | 9 | ||||
| -rw-r--r-- | src/zenutil/consul/consul.cpp | 11 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/consul.h | 1 |
3 files changed, 14 insertions, 7 deletions
diff --git a/src/zenserver/hub/zenhubserver.cpp b/src/zenserver/hub/zenhubserver.cpp index b94e04092..db988395c 100644 --- a/src/zenserver/hub/zenhubserver.cpp +++ b/src/zenserver/hub/zenhubserver.cpp @@ -438,12 +438,9 @@ ZenHubServer::OnModuleStateChanged(std::string_view HubInstanceId, .Tags = std::vector<std::pair<std::string, std::string>>{std::make_pair("module", std::string(ModuleId)), std::make_pair("zen-hub", std::string(HubInstanceId)), std::make_pair("version", std::string(ZEN_CFG_VERSION))}, - .HealthIntervalSeconds = NewState == HubInstanceState::Provisioning - ? 0u - : m_ConsulHealthIntervalSeconds, // Disable health checks while not finished provisioning - .DeregisterAfterSeconds = NewState == HubInstanceState::Provisioning - ? 0u - : m_ConsulDeregisterAfterSeconds}; // Disable health checks while not finished provisioning + .HealthIntervalSeconds = NewState == HubInstanceState::Provisioning ? 0u : m_ConsulHealthIntervalSeconds, + .DeregisterAfterSeconds = NewState == HubInstanceState::Provisioning ? 0u : m_ConsulDeregisterAfterSeconds, + .InitialStatus = NewState == HubInstanceState::Provisioned ? "passing" : ""}; if (!m_ConsulClient->RegisterService(ServiceInfo)) { diff --git a/src/zenutil/consul/consul.cpp b/src/zenutil/consul/consul.cpp index 951beed65..c9884ea61 100644 --- a/src/zenutil/consul/consul.cpp +++ b/src/zenutil/consul/consul.cpp @@ -205,6 +205,10 @@ ConsulClient::RegisterService(const ServiceRegistrationInfo& Info) { Writer.AddString("DeregisterCriticalServiceAfter"sv, fmt::format("{}s", Info.DeregisterAfterSeconds)); } + if (!Info.InitialStatus.empty()) + { + Writer.AddString("Status"sv, Info.InitialStatus); + } } Writer.EndObject(); // Check } @@ -693,13 +697,18 @@ TEST_CASE("util.consul.service_lifecycle") REQUIRE(Client.DeregisterService(ServiceId)); CHECK_FALSE(Client.HasService(ServiceId)); - // Phase 3: Register again, verify passing, then fail health and verify check goes critical + // Phase 3: Register with InitialStatus, verify immediately passing before any health check fires, + // then fail health and verify check goes critical HealthServer.Mock.HealthCheckCount.store(0); HealthServer.Mock.FailHealth.store(false); + Info.InitialStatus = "passing"; REQUIRE(Client.RegisterService(Info)); REQUIRE(Client.HasService(ServiceId)); + CHECK_EQ(HealthServer.Mock.HealthCheckCount.load(), 0); + CHECK_EQ(GetCheckStatus(Client, ServiceId), "passing"); + REQUIRE(WaitForCondition([&]() { return HealthServer.Mock.HealthCheckCount.load() >= 1; }, 10000)); CHECK_EQ(GetCheckStatus(Client, ServiceId), "passing"); diff --git a/src/zenutil/include/zenutil/consul.h b/src/zenutil/include/zenutil/consul.h index 7517ddd1e..c3d0e5f1d 100644 --- a/src/zenutil/include/zenutil/consul.h +++ b/src/zenutil/include/zenutil/consul.h @@ -23,6 +23,7 @@ struct ServiceRegistrationInfo std::vector<std::pair<std::string, std::string>> Tags; uint32_t HealthIntervalSeconds = 10; uint32_t DeregisterAfterSeconds = 30; + std::string InitialStatus; }; class ConsulClient |