From: Arvin Schnell Date: Fri, 4 Dec 2020 09:12:22 +0000 (+0100) Subject: - continue with other configs if one config is broken X-Git-Tag: v0.8.15~6^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e436c6239bb30c408f074208b271e911de16ac7;p=thirdparty%2Fsnapper.git - continue with other configs if one config is broken --- diff --git a/client/proxy.cc b/client/proxy.cc index ce156d0c..c70eb359 100644 --- a/client/proxy.cc +++ b/client/proxy.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) [2016-2017] SUSE LLC + * Copyright (c) [2016-2020] SUSE LLC * * All Rights Reserved. * @@ -55,6 +55,14 @@ ProxyConfig::getValue(const string& key, string& value) const } +bool +ProxyConfig::is_yes(const char* key) const +{ + map::const_iterator pos = values.find(key); + return pos != values.end() && pos->second == "yes"; +} + + SMD ProxySnapshot::getSmd() const { diff --git a/client/proxy.h b/client/proxy.h index bf0c1db9..77197894 100644 --- a/client/proxy.h +++ b/client/proxy.h @@ -82,6 +82,8 @@ public: bool getValue(const string& key, string& value) const; + bool is_yes(const char* key) const; + private: map values; diff --git a/client/systemd-helper.cc b/client/systemd-helper.cc index b01b0c18..9589e5d8 100644 --- a/client/systemd-helper.cc +++ b/client/systemd-helper.cc @@ -72,25 +72,31 @@ timeline(ProxySnappers* snappers, const map& userdata) map configs = snappers->getConfigs(); for (const map::value_type& value : configs) { - const map& raw = value.second.getAllValues(); + const ProxyConfig& proxy_config = value.second; - map::const_iterator pos1 = raw.find("TIMELINE_CREATE"); - if (pos1 != raw.end() && pos1->second == "yes") - { - ProxySnapper* snapper = snappers->getSnapper(value.first); + if (!proxy_config.is_yes("TIMELINE_CREATE")) + continue; - SCD scd; - scd.description = "timeline"; - scd.cleanup = "timeline"; - scd.userdata = userdata; + cout << "running timeline for '" << value.first << "'." << endl; - cout << "running timeline for '" << value.first << "'." << endl; + ProxySnapper* snapper = nullptr; - if (!call_with_error_check([snapper, scd](){ snapper->createSingleSnapshot(scd); })) - { - cerr << "timeline for '" << value.first << "' failed." << endl; - ok = false; - } + if (!call_with_error_check([&snappers, &snapper, &value](){ snapper = snappers->getSnapper(value.first); })) + { + cerr << "timeline for '" << value.first << "' failed." << endl; + ok = false; + continue; + } + + SCD scd; + scd.description = "timeline"; + scd.cleanup = "timeline"; + scd.userdata = userdata; + + if (!call_with_error_check([snapper, scd](){ snapper->createSingleSnapshot(scd); })) + { + cerr << "timeline for '" << value.first << "' failed." << endl; + ok = false; } } @@ -106,12 +112,27 @@ cleanup(ProxySnappers* snappers) map configs = snappers->getConfigs(); for (const map::value_type& value : configs) { - const map& raw = value.second.getAllValues(); + const ProxyConfig& proxy_config = value.second; + + bool do_number = proxy_config.is_yes("NUMBER_CLEANUP"); + bool do_timeline = proxy_config.is_yes("TIMELINE_CLEANUP"); + bool do_empty_pre_post = proxy_config.is_yes("EMPTY_PRE_POST_CLEANUP"); + + if (!do_number && !do_timeline && !do_empty_pre_post) + continue; + + cout << "running cleanup for '" << value.first << "'." << endl; - ProxySnapper* snapper = snappers->getSnapper(value.first); + ProxySnapper* snapper = nullptr; - map::const_iterator pos1 = raw.find("NUMBER_CLEANUP"); - if (pos1 != raw.end() && pos1->second == "yes") + if (!call_with_error_check([&snappers, &snapper, &value](){ snapper = snappers->getSnapper(value.first); })) + { + cerr << "cleanup for '" << value.first << "' failed." << endl; + ok = false; + continue; + } + + if (do_number) { cout << "running number cleanup for '" << value.first << "'." << endl; @@ -122,8 +143,7 @@ cleanup(ProxySnappers* snappers) } } - map::const_iterator pos2 = raw.find("TIMELINE_CLEANUP"); - if (pos2 != raw.end() && pos2->second == "yes") + if (do_timeline) { cout << "running timeline cleanup for '" << value.first << "'." << endl; @@ -134,8 +154,7 @@ cleanup(ProxySnappers* snappers) } } - map::const_iterator pos3 = raw.find("EMPTY_PRE_POST_CLEANUP"); - if (pos3 != raw.end() && pos3->second == "yes") + if (do_empty_pre_post) { cout << "running empty-pre-post cleanup for '" << value.first << "'." << endl; diff --git a/package/snapper.changes b/package/snapper.changes index 0bf1285d..242f7dde 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Dec 04 10:05:05 CET 2020 - aschnell@suse.com + +- in systemd-helper continue with other configs if one config is + broken (gh#openSUSE/snapper#495) + ------------------------------------------------------------------- Thu Dec 03 10:12:04 CET 2020 - aschnell@suse.com