aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-12-02 17:51:31 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-12-03 08:25:21 +0200
commit69d9dc3943f68b06d05a58a81ef603d135e51986 (patch)
tree6df53f44146233d3e2ff68d3e5608ffea7b3bcbc
parente938c4a00c46cdff5a5718a0cec3ae7af714c583 (diff)
Handle replaced tenants
-rw-r--r--mod/mod-ci-github.cxx45
-rw-r--r--mod/mod-ci-github.hxx3
2 files changed, 33 insertions, 15 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index e04570e..64ab9c5 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -1302,7 +1302,7 @@ namespace brep
function<optional<string> (const string& tenant_id,
const tenant_service&)> ci_github::
- build_unloaded (const string& /*tenant_id*/,
+ build_unloaded (const string& ti,
tenant_service&& ts,
const diag_epilogue& log_writer) const noexcept
{
@@ -1322,8 +1322,8 @@ namespace brep
}
return sd.pre_check
- ? build_unloaded_pre_check (move (ts), move (sd), log_writer)
- : build_unloaded_load (move (ts), move (sd), log_writer);
+ ? build_unloaded_pre_check (move (ts), move (sd), log_writer)
+ : build_unloaded_load (ti, move (ts), move (sd), log_writer);
}
function<optional<string> (const string& tenant_id,
@@ -1529,7 +1529,8 @@ namespace brep
function<optional<string> (const string& tenant_id,
const tenant_service&)> ci_github::
- build_unloaded_load (tenant_service&& ts,
+ build_unloaded_load (const string& ti,
+ tenant_service&& ts,
service_data&& sd,
const diag_epilogue& log_writer) const noexcept
try
@@ -1731,15 +1732,19 @@ namespace brep
return nullptr; // Nothing to save (but potentially retry on next call).
return [&error,
+ ti,
iat = move (new_iat),
cni = move (conclusion_node_id)]
- (const string& /*tenant_id*/,
+ (const string& tenant_id,
const tenant_service& ts) -> optional<string>
{
// NOTE: this lambda may be called repeatedly (e.g., due to
// transaction being aborted) and so should not move out of its
// captures.
+ if (tenant_id != ti)
+ return nullopt; // Do nothing if the tenant has been replaced.
+
service_data sd;
try
{
@@ -1873,7 +1878,7 @@ namespace brep
//
function<optional<string> (const string& tenant_id,
const tenant_service&)> ci_github::
- build_queued (const string& /*tenant_id*/,
+ build_queued (const string& ti,
const tenant_service& ts,
const vector<build>& builds,
optional<build_state> istate,
@@ -1999,16 +2004,20 @@ namespace brep
}
}
- return [bs = move (bs),
+ return [ti,
+ bs = move (bs),
iat = move (new_iat),
crs = move (crs),
error = move (error),
- warn = move (warn)] (const string& /*tenant_id*/,
+ warn = move (warn)] (const string& tenant_id,
const tenant_service& ts) -> optional<string>
{
// NOTE: this lambda may be called repeatedly (e.g., due to transaction
// being aborted) and so should not move out of its captures.
+ if (tenant_id != ti)
+ return nullopt; // Do nothing if the tenant has been replaced.
+
service_data sd;
try
{
@@ -2059,7 +2068,7 @@ namespace brep
function<optional<string> (const string& tenant_id,
const tenant_service&)> ci_github::
- build_building (const string& /*tenant_id*/,
+ build_building (const string& ti,
const tenant_service& ts,
const build& b,
const diag_epilogue& log_writer) const noexcept
@@ -2167,15 +2176,19 @@ namespace brep
}
}
- return [iat = move (new_iat),
+ return [ti,
+ iat = move (new_iat),
cr = move (*cr),
error = move (error),
- warn = move (warn)] (const string& /*tenant_id*/,
+ warn = move (warn)] (const string& tenant_id,
const tenant_service& ts) -> optional<string>
{
// NOTE: this lambda may be called repeatedly (e.g., due to transaction
// being aborted) and so should not move out of its captures.
+ if (tenant_id != ti)
+ return nullopt; // Do nothing if the tenant has been replaced.
+
service_data sd;
try
{
@@ -2223,7 +2236,7 @@ namespace brep
function<optional<string> (const string& tenant_id,
const tenant_service&)> ci_github::
- build_built (const string& /*tenant_id*/,
+ build_built (const string& ti,
const tenant_service& ts,
const build& b,
const diag_epilogue& log_writer) const noexcept
@@ -2548,16 +2561,20 @@ namespace brep
}
}
- return [iat = move (new_iat),
+ return [ti,
+ iat = move (new_iat),
cr = move (cr),
completed = completed,
error = move (error),
- warn = move (warn)] (const string& /*tenant_id*/,
+ warn = move (warn)] (const string& tenant_id,
const tenant_service& ts) -> optional<string>
{
// NOTE: this lambda may be called repeatedly (e.g., due to transaction
// being aborted) and so should not move out of its captures.
+ if (tenant_id != ti)
+ return nullopt; // Do nothing if the tenant has been replaced.
+
service_data sd;
try
{
diff --git a/mod/mod-ci-github.hxx b/mod/mod-ci-github.hxx
index 9b9814e..55105b7 100644
--- a/mod/mod-ci-github.hxx
+++ b/mod/mod-ci-github.hxx
@@ -56,7 +56,8 @@ namespace brep
function<optional<string> (const string& tenant_id,
const tenant_service&)>
- build_unloaded_load (tenant_service&&,
+ build_unloaded_load (const string& tenant_id,
+ tenant_service&&,
service_data&&,
const diag_epilogue&) const noexcept;