CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
repository_abort.cc
Go to the documentation of this file.
1 
5 #include "cvmfs_config.h"
6 #include "publish/repository.h"
7 
8 #include <unistd.h>
9 
10 #include <string>
11 
12 #include "logging.h"
13 #include "publish/except.h"
15 #include "publish/settings.h"
16 #include "util/posix.h"
17 
18 namespace publish {
19 
21  // TODO(jblomer): implement for enter shell etc.
22  if (!managed_node_.IsValid())
23  return;
24 
25  managed_node_->ClearScratch();
26 }
27 
29  if (is_publishing()) {
30  throw EPublish(
31  "Repository " + settings_.fqrn() + " is currently publishing "
32  "(aborting abort)", EPublish::kFailTransactionState);
33  }
34 
35  if (!in_transaction()) {
36  if (session_->has_lease()) {
37  LogCvmfs(kLogCvmfs, kLogSyslogWarn, "removing stale session token for %s",
38  settings_.fqrn().c_str());
39  session_->Drop();
40  }
41  throw EPublish(
42  "Repository " + settings_.fqrn() + " is not in a transaction",
44  }
45 
46  session_->Drop();
47 
48  if (managed_node_.IsValid()) {
49  // We already checked for is_publishing and in_transaction. Normally, at
50  // this point we do want to repair the mount points of a repository
51  // in transaction
52  EUnionMountRepairMode repair_mode =
53  settings_.transaction().spool_area().repair_mode();
54  if (repair_mode == kUnionMountRepairSafe) {
55  settings_.GetTransaction()->GetSpoolArea()->SetRepairMode(
57  }
58  int rvi = managed_node_->Check(false /* is_quiet */);
59  settings_.GetTransaction()->GetSpoolArea()->SetRepairMode(repair_mode);
60  if (rvi != 0) throw EPublish("publisher file system mount state is broken");
61 
62  managed_node_->Unmount();
63  managed_node_->ClearScratch();
64  managed_node_->Mount();
65  }
66 
68  settings_.transaction().spool_area().transaction_lock());
69  in_transaction_ = false;
70 }
71 
72 } // namespace publish
#define LogCvmfs(source, mask,...)
Definition: logging.h:20
const SettingsRepository settings_
Definition: repository.h:136
UniquePtr< ManagedNode > managed_node_
Definition: repository.h:383
EUnionMountRepairMode
Definition: settings.h:64
bool is_publishing() const
Definition: repository.h:316
bool in_transaction_
Definition: repository.h:372
void Abort()
void WipeScratchArea()
UniquePtr< Session > session_
Definition: repository.h:382
bool in_transaction() const
Definition: repository.h:315
static void Release(const std::string &path)
std::string fqrn() const
Definition: settings.h:368