From 1dfc20c02d3b1076570a7146581799eab0773d6d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 22 May 2024 19:34:06 +0300 Subject: Replace ci_start::abandon() with ci_start::cancel() --- mod/ci-common.cxx | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'mod/ci-common.cxx') diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx index 6ce47f2..7c41a7b 100644 --- a/mod/ci-common.cxx +++ b/mod/ci-common.cxx @@ -685,12 +685,13 @@ namespace brep return r; } - void ci_start:: - abandon (const basic_mark& error, - const basic_mark&, - const basic_mark* trace, - odb::core::database& db, - tenant_service&& service) const + optional ci_start:: + cancel (const basic_mark&, + const basic_mark&, + const basic_mark* trace, + odb::core::database& db, + const string& type, + const string& id) const { using namespace odb::core; @@ -701,37 +702,22 @@ namespace brep using query = query; shared_ptr t ( - db.query_one (query::service.id == service.id && - query::service.type == service.type)); - + db.query_one (query::service.id == id && + query::service.type == type)); if (t == nullptr) - { - error << "unable to find tenant for service " << service.id << ' ' - << service.type; - - return; - } - else if (!t->unloaded_timestamp) - { - error << "tenant " << t->id << " for service " << service.id << ' ' - << service.type << " is already loaded"; + return nullopt; - return; - } - - // We could probably remove the tenant from the database, but let's just - // archive it and keep for troubleshooting. - // - if (!t->archived) - { - t->archived = true; - db.update (t); - } + optional r (move (t->service)); + t->service = nullopt; + t->archived = true; + db.update (t); tr.commit (); if (trace != nullptr) - *trace << "unloaded CI request " << t->id << " for service " - << service.id << ' ' << service.type << " is abandoned"; + *trace << "CI request " << t->id << " for service " << id << ' ' << type + << " is canceled"; + + return r; } } -- cgit v1.1