aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/hub/httphubservice.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-23 23:52:27 +0100
committerGitHub Enterprise <[email protected]>2026-03-23 23:52:27 +0100
commit658a5fea740d97033cd12aa37bd6ecd32b15a924 (patch)
tree517f69ebeb87fc2e995eb6d158acd3d17bc25cca /src/zenserver/hub/httphubservice.cpp
parentCross-platform process metrics support (#887) (diff)
downloadzen-658a5fea740d97033cd12aa37bd6ecd32b15a924.tar.xz
zen-658a5fea740d97033cd12aa37bd6ecd32b15a924.zip
refactor hub notifications (#888)
* refactor hub callbacks * improve http responses
Diffstat (limited to 'src/zenserver/hub/httphubservice.cpp')
-rw-r--r--src/zenserver/hub/httphubservice.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/zenserver/hub/httphubservice.cpp b/src/zenserver/hub/httphubservice.cpp
index a91e36128..34f4294e4 100644
--- a/src/zenserver/hub/httphubservice.cpp
+++ b/src/zenserver/hub/httphubservice.cpp
@@ -269,9 +269,6 @@ HttpHubService::HandleModuleGet(HttpServerRequest& Request, std::string_view Mod
return;
}
- // TODO: A separate http request for the modules/{moduleid}/deprovision endpoint can be called and deprovision the instance leaving us
- // with a dangling pointer...
-
CbObjectWriter Obj;
Obj << "moduleId" << ModuleId;
Obj << "state" << ToString(InstanceInfo.State);
@@ -288,12 +285,29 @@ HttpHubService::HandleModuleDelete(HttpServerRequest& Request, std::string_view
return;
}
- if (InstanceInfo.State == HubInstanceState::Provisioned)
+ if (InstanceInfo.State == HubInstanceState::Provisioned || InstanceInfo.State == HubInstanceState::Hibernated ||
+ InstanceInfo.State == HubInstanceState::Crashed)
{
- std::string Reason;
- if (!m_Hub.Deprovision(std::string(ModuleId), Reason))
+ std::string FailureReason;
+ try
+ {
+ if (!m_Hub.Deprovision(std::string(ModuleId), FailureReason))
+ {
+ if (FailureReason.empty())
+ {
+ Request.WriteResponse(HttpResponseCode::NotFound);
+ }
+ else
+ {
+ Request.WriteResponse(HttpResponseCode::BadRequest, HttpContentType::kText, FailureReason);
+ }
+ return;
+ }
+ }
+ catch (const std::exception& Ex)
{
- Request.WriteResponse(HttpResponseCode::InternalServerError, HttpContentType::kText, Reason);
+ ZEN_ERROR("Exception while deprovisioning module '{}': {}", ModuleId, Ex.what());
+ Request.WriteResponse(HttpResponseCode::InternalServerError, HttpContentType::kText, Ex.what());
return;
}
}