From 6484764f7df92b3f9d88b2718057d8de8c1d58e6 Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Wed, 22 Dec 2010 15:14:49 +0000 Subject: [PATCH 1/7] icreate short-lived branch for ticet #435 (if cfgmgr can't read configs then runs anyways with defaults) git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac435@3963 e5f2f494-b856-4b98-b285-d166d9295462 From 29296c5c5787f09a773558934c737a5ee65a92d6 Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Wed, 22 Dec 2010 15:32:59 +0000 Subject: [PATCH 2/7] do not write config on exit, only on config changes git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac435@3964 e5f2f494-b856-4b98-b285-d166d9295462 --- src/bin/cfgmgr/b10-cfgmgr.py.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bin/cfgmgr/b10-cfgmgr.py.in b/src/bin/cfgmgr/b10-cfgmgr.py.in index 98e33fff86..73906b7707 100644 --- a/src/bin/cfgmgr/b10-cfgmgr.py.in +++ b/src/bin/cfgmgr/b10-cfgmgr.py.in @@ -61,8 +61,6 @@ def main(): except ConfigManagerDataReadError as cmdre: print("[b10-cfgmgr] " + str(cmdre)) return 2 - if cm: - return cm.write_config() return 0 if __name__ == "__main__": From a2f96dea2a968b6a48588bbfbc9c1863b5e2f7ee Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Wed, 22 Dec 2010 15:37:01 +0000 Subject: [PATCH 3/7] forgot to commit test git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac435@3965 e5f2f494-b856-4b98-b285-d166d9295462 --- src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in b/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in index 05339a15b3..c2687ff1ca 100644 --- a/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in +++ b/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in @@ -58,7 +58,8 @@ class TestConfigManagerStartup(unittest.TestCase): self.assertTrue(b.cm.read_config_called) self.assertTrue(b.cm.notify_boss_called) self.assertTrue(b.cm.run_called) - self.assertTrue(b.cm.write_config_called) + # if there are no changes, config is not written + self.assertFalse(b.cm.write_config_called) self.assertTrue(b.cm.running) b.signal_handler(None, None) From 32e9990ab838e4425927aed4dfea951ca722ec9a Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Wed, 22 Dec 2010 15:50:29 +0000 Subject: [PATCH 4/7] fail with exit if configuration file cannot be read for any other ioerror reason than 'file not found' git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac435@3966 e5f2f494-b856-4b98-b285-d166d9295462 --- src/lib/python/isc/config/cfgmgr.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/python/isc/config/cfgmgr.py b/src/lib/python/isc/config/cfgmgr.py index 212b67e1d1..74a6ba2e76 100644 --- a/src/lib/python/isc/config/cfgmgr.py +++ b/src/lib/python/isc/config/cfgmgr.py @@ -26,6 +26,7 @@ import os import copy import tempfile import json +import errno from isc.cc import data from isc.config import ccsession, config_data @@ -87,7 +88,12 @@ class ConfigManagerData: else: raise ConfigManagerDataReadError("No version information in configuration file " + config.db_filename) except IOError as ioe: - raise ConfigManagerDataEmpty("No configuration file found") + # if IOError is 'no such file or directory', then continue + # (raise empty), otherwise fail (raise error) + if ioe.errno == errno.ENOENT: + raise ConfigManagerDataEmpty("No configuration file found") + else: + raise ConfigManagerDataReadError("Can't read configuration file: " + str(ioe)) except ValueError: raise ConfigManagerDataReadError("Configuration file out of date or corrupt, please update or remove " + config.db_filename) finally: From 3b56eb515ddfd85ed2156398838a536b39ab7c86 Mon Sep 17 00:00:00 2001 From: Scott Mann Date: Fri, 7 Jan 2011 14:01:00 -0700 Subject: [PATCH 5/7] temporary fix to defect #432 --- src/bin/bind10/bind10.8 | 11 +---------- src/bin/resolver/main.cc | 2 +- src/bin/resolver/resolver.cc | 14 +++++++------- src/lib/log/dummylog.cc | 4 ++-- src/lib/log/dummylog.h | 2 +- src/lib/python/isc/config/cfgmgr.py | 4 ++++ 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/bin/bind10/bind10.8 b/src/bin/bind10/bind10.8 index 09963a607b..a3ac653613 100644 --- a/src/bin/bind10/bind10.8 +++ b/src/bin/bind10/bind10.8 @@ -1,7 +1,7 @@ '\" t .\" Title: bind10 .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.76.0 +.\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: July 29, 2010 .\" Manual: BIND10 .\" Source: BIND10 @@ -9,15 +9,6 @@ .\" .TH "BIND10" "8" "July 29, 2010" "BIND10" "BIND10" .\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation diff --git a/src/bin/resolver/main.cc b/src/bin/resolver/main.cc index e41d6b8169..29d91f5cdf 100644 --- a/src/bin/resolver/main.cc +++ b/src/bin/resolver/main.cc @@ -169,7 +169,7 @@ main(int argc, char* argv[]) { dlog("Server started."); io_service.run(); } catch (const std::exception& ex) { - dlog(string("Server failed: ") + ex.what()); + dlog(string("Server failed: ") + ex.what(),true); ret = 1; } diff --git a/src/bin/resolver/resolver.cc b/src/bin/resolver/resolver.cc index da162e85ef..bcbf5c50db 100644 --- a/src/bin/resolver/resolver.cc +++ b/src/bin/resolver/resolver.cc @@ -93,7 +93,7 @@ public: if (dnss) { if (upstream_.empty()) { dlog("Asked to do full recursive, but not implemented yet. " - "I'll do nothing."); + "I'll do nothing.",true); } else { dlog("Setting forward addresses:"); BOOST_FOREACH(const addr_t& address, upstream) { @@ -322,7 +322,7 @@ Resolver::~Resolver() { delete checkin_; delete dns_lookup_; delete dns_answer_; - dlog("Deleting the Resolver"); + dlog("Deleting the Resolver",true); } void @@ -360,7 +360,7 @@ Resolver::processMessage(const IOMessage& io_message, MessagePtr message, return; } } catch (const Exception& ex) { - dlog(string("DNS packet exception: ") + ex.what()); + dlog(string("DNS packet exception: ") + ex.what(),true); server->resume(false); return; } @@ -525,7 +525,7 @@ Resolver::updateConfig(ConstElementPtr config) { } return (isc::config::createAnswer()); } catch (const isc::Exception& error) { - dlog(string("error in config: ") + error.what()); + dlog(string("error in config: ") + error.what(),true); return (isc::config::createAnswer(1, error.what())); } } @@ -577,13 +577,13 @@ Resolver::setListenAddresses(const vector& addresses) { * If that fails, bad luck, but we are useless anyway, so just die * and let boss start us again. */ - dlog(string("Unable to set new address: ") + e.what()); + dlog(string("Unable to set new address: ") + e.what(),true); try { setAddresses(dnss_, impl_->listen_); } catch (const exception& e2) { - dlog(string("Unable to recover from error;")); - dlog(string("Rollback failed with: ") + e2.what()); + dlog(string("Unable to recover from error;"),true); + dlog(string("Rollback failed with: ") + e2.what(),true); abort(); } throw e; // Let it fly a little bit further diff --git a/src/lib/log/dummylog.cc b/src/lib/log/dummylog.cc index 8554178d59..dda05787f0 100644 --- a/src/lib/log/dummylog.cc +++ b/src/lib/log/dummylog.cc @@ -24,8 +24,8 @@ namespace log { bool denabled = false; string dprefix; -void dlog(const string& message) { - if (denabled) { +void dlog(const string& message,bool error_flag) { + if (denabled || error_flag) { if (!dprefix.empty()) { cerr << "[" << dprefix << "] "; } diff --git a/src/lib/log/dummylog.h b/src/lib/log/dummylog.h index 9462bb1b70..f20c0328bf 100644 --- a/src/lib/log/dummylog.h +++ b/src/lib/log/dummylog.h @@ -52,7 +52,7 @@ extern std::string dprefix; * @param message The message to log. The real interface will probably have * more parameters. */ -void dlog(const std::string& message); +void dlog(const std::string& message, bool error_flag=false); } } diff --git a/src/lib/python/isc/config/cfgmgr.py b/src/lib/python/isc/config/cfgmgr.py index 212b67e1d1..f1cd007918 100644 --- a/src/lib/python/isc/config/cfgmgr.py +++ b/src/lib/python/isc/config/cfgmgr.py @@ -19,6 +19,9 @@ configuration to the modules that need them. """ +# defect #426 +import pdb +# import isc import signal import ast @@ -100,6 +103,7 @@ class ConfigManagerData: output_file_name is not specified, the file used in read_from_file is used.""" filename = None + pdb.set_trace() try: file = tempfile.NamedTemporaryFile(mode='w', prefix="b10-config.db.", From 880220478c3e8702d56d761b1e0b21b77d08ee5a Mon Sep 17 00:00:00 2001 From: Scott Mann Date: Fri, 7 Jan 2011 14:44:51 -0700 Subject: [PATCH 6/7] remove a spurious change to cfgmgr.py --- src/lib/python/isc/config/cfgmgr.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib/python/isc/config/cfgmgr.py b/src/lib/python/isc/config/cfgmgr.py index f1cd007918..212b67e1d1 100644 --- a/src/lib/python/isc/config/cfgmgr.py +++ b/src/lib/python/isc/config/cfgmgr.py @@ -19,9 +19,6 @@ configuration to the modules that need them. """ -# defect #426 -import pdb -# import isc import signal import ast @@ -103,7 +100,6 @@ class ConfigManagerData: output_file_name is not specified, the file used in read_from_file is used.""" filename = None - pdb.set_trace() try: file = tempfile.NamedTemporaryFile(mode='w', prefix="b10-config.db.", From 73ad11062c6ccf59edbaf0cb480f2c0918aa33f1 Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Tue, 18 Jan 2011 18:13:16 +0100 Subject: [PATCH 7/7] update changelog --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index c711dbf159..fb571458b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ + 150. [bug] jelte + b10-cfgmgr: No longer save the configuration on exit. Configuration + is already saved if it is changed succesfully, so writing it on + exit (and hence, when nothing has changed too) is unnecessary and + may even cause problems. + (Trac #435, git fd7baa38c08d54d5b5f84930c1684c436d2776dc) + 149. [bug] jelte bindctl: Check if the user session has disappeared (either by a timeout or by a server restart), and reauthenticate if so. This