BIND 10 trac2436, updated. 24d4a811795ef1e7f72af8ca9534ff12e4a59b06 [2436] Remove the validation from the b10-loadzone

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jan 4 17:32:36 UTC 2013


The branch, trac2436 has been updated
       via  24d4a811795ef1e7f72af8ca9534ff12e4a59b06 (commit)
       via  6b199fc7d5e9880822aaa1f2e285760f59200751 (commit)
      from  0c25dda981710f0a8d46e79cfa7b1a5af75c7b7f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 24d4a811795ef1e7f72af8ca9534ff12e4a59b06
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Jan 4 18:30:30 2013 +0100

    [2436] Remove the validation from the b10-loadzone
    
    It is now done in the ZoneLoader in the C++ backend, so don't duplicate
    the code.

commit 6b199fc7d5e9880822aaa1f2e285760f59200751
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Jan 4 18:28:05 2013 +0100

    [2436] Perform the validation in ZoneLoader
    
    TODO: Modify this commit and use the datasource RRsetCollection. This
    way it doesn't work.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/loadzone/loadzone.py.in               |   23 ---------------
 src/bin/loadzone/loadzone_messages.mes        |    8 ------
 src/lib/datasrc/datasrc_messages.mes          |   11 +++++++
 src/lib/datasrc/tests/zone_loader_unittest.cc |   14 +++++----
 src/lib/datasrc/zone_loader.cc                |   38 +++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 37 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/loadzone/loadzone.py.in b/src/bin/loadzone/loadzone.py.in
index 294df55..e054d71 100755
--- a/src/bin/loadzone/loadzone.py.in
+++ b/src/bin/loadzone/loadzone.py.in
@@ -282,28 +282,6 @@ class LoadZoneRunner:
                              self._zone_class)
             raise LoadFailure(str(ex))
 
-    def _post_load_checks(self):
-        '''Perform minimal validity checks on the loaded zone.
-
-        We do this ourselves because the underlying library currently
-        doesn't do any checks.  Once the library support post-load validation
-        this check should be removed.
-
-        '''
-        datasrc_client = DataSourceClient(self._datasrc_type,
-                                          self._datasrc_config)
-        _, finder = datasrc_client.find_zone(self._zone_name) # should succeed
-        result = finder.find(self._zone_name, RRType.SOA())[0]
-        if result is not finder.SUCCESS:
-            self._post_load_warning('zone has no SOA')
-        result = finder.find(self._zone_name, RRType.NS())[0]
-        if result is not finder.SUCCESS:
-            self._post_load_warning('zone has no NS')
-
-    def _post_load_warning(self, msg):
-        logger.warn(LOADZONE_POSTLOAD_ISSUE, self._zone_name,
-                    self._zone_class, msg)
-
     def _set_signal_handlers(self):
         signal.signal(signal.SIGINT, self._interrupt_handler)
         signal.signal(signal.SIGTERM, self._interrupt_handler)
@@ -321,7 +299,6 @@ class LoadZoneRunner:
             total_elapsed_txt = "%.2f" % (time.time() - self.__start_time)
             logger.info(LOADZONE_DONE, self.__loaded_rrs, self._zone_name,
                         self._zone_class, total_elapsed_txt)
-            self._post_load_checks()
             return 0
         except BadArgument as ex:
             logger.error(LOADZONE_ARGUMENT_ERROR, ex)
diff --git a/src/bin/loadzone/loadzone_messages.mes b/src/bin/loadzone/loadzone_messages.mes
index db79269..ca241b3 100644
--- a/src/bin/loadzone/loadzone_messages.mes
+++ b/src/bin/loadzone/loadzone_messages.mes
@@ -46,14 +46,6 @@ in the zone file.  When this happens, the RRs loaded so far are
 effectively deleted from the zone, and the old version (if exists)
 will still remain valid for operations.
 
-% LOADZONE_POSTLOAD_ISSUE New version of zone %1/%2 has an issue: %3
-b10-loadzone detected a problem after a successful load of zone:
-either or both of SOA and NS records are missing at the zone origin.
-In the current implementation the load will not be canceled for such
-problems.  The operator will need to fix the issues and reload the
-zone; otherwise applications (such as b10-auth) that use this data
-source will not work as expected.
-
 % LOADZONE_SQLITE3_USING_DEFAULT_CONFIG Using default configuration with SQLite3 DB file %1
 The SQLite3 data source is specified as the data source type without a
 data source configuration.  b10-loadzone uses the default
diff --git a/src/lib/datasrc/datasrc_messages.mes b/src/lib/datasrc/datasrc_messages.mes
index 6983459..cfe52a0 100644
--- a/src/lib/datasrc/datasrc_messages.mes
+++ b/src/lib/datasrc/datasrc_messages.mes
@@ -844,3 +844,14 @@ data source.
 % DATASRC_UNEXPECTED_QUERY_STATE unexpected query state
 This indicates a programming error. An internal task of unknown type was
 generated.
+
+% DATASRC_VALIDATE_ERROR validation of zone %1/%2 failed: %3
+The zone was loaded into the data source successfully, but the content fails
+basic sanity checks. See the message if you want to know what exactly is wrong
+with the data. The data can not be used and previous version, if any, will be
+preserved.
+
+% DATASRC_VALIDATE_WARNING %1/%2: %3
+The zone was loaded, but there's some problem with the content. The problem
+is not serious enough to make the zone unusable, but it should still be checked
+and fixed. See the message to know what exactly is wrong with the data.
diff --git a/src/lib/datasrc/tests/zone_loader_unittest.cc b/src/lib/datasrc/tests/zone_loader_unittest.cc
index 9f4cf2b..fc17361 100644
--- a/src/lib/datasrc/tests/zone_loader_unittest.cc
+++ b/src/lib/datasrc/tests/zone_loader_unittest.cc
@@ -82,9 +82,9 @@ public:
 // and this way, it is much simpler.
 class Updater : public ZoneUpdater {
 public:
-    Updater(MockClient* client) :
+    Updater(MockClient* client, const Name& name) :
         client_(client),
-        finder_(client_->rrclass_)
+        finder_(client_->rrclass_, name)
     {}
     virtual ZoneFinder& getFinder() {
         return (finder_);
@@ -105,14 +105,15 @@ private:
     MockClient* client_;
     class Finder : public ZoneFinder {
     public:
-        Finder(const RRClass& rrclass) :
-            class_(rrclass)
+        Finder(const RRClass& rrclass, const Name& name) :
+            class_(rrclass),
+            name_(name)
         {}
         virtual RRClass getClass() const {
             return (class_);
         }
         virtual Name getOrigin() const {
-            isc_throw(isc::NotImplemented, "Method not used in tests");
+            return (name_);
         }
         virtual shared_ptr<Context> find(const Name&, const RRType&,
                                          const FindOptions)
@@ -130,6 +131,7 @@ private:
         }
     private:
         const RRClass class_;
+        const Name name_;
     } finder_;
 };
 
@@ -144,7 +146,7 @@ MockClient::getUpdater(const Name& name, bool replace, bool journaling) const {
     // const_cast is bad. But the const on getUpdater seems wrong in the first
     // place, since updater will be modifying the data there. And the updater
     // wants to store data into the client so we can examine it later.
-    return (ZoneUpdaterPtr(new Updater(const_cast<MockClient*>(this))));
+    return (ZoneUpdaterPtr(new Updater(const_cast<MockClient*>(this), name)));
 }
 
 class ZoneLoaderTest : public ::testing::Test {
diff --git a/src/lib/datasrc/zone_loader.cc b/src/lib/datasrc/zone_loader.cc
index 01f216e..10a22ac 100644
--- a/src/lib/datasrc/zone_loader.cc
+++ b/src/lib/datasrc/zone_loader.cc
@@ -19,12 +19,19 @@
 #include <datasrc/data_source.h>
 #include <datasrc/iterator.h>
 #include <datasrc/zone.h>
+#include <datasrc/logger.h>
 
 #include <dns/rrset.h>
+#include <dns/rrset_collection.h>
+#include <dns/zone_checker.h>
+
+#include <boost/bind.hpp>
 
 using isc::dns::Name;
 using isc::dns::ConstRRsetPtr;
 using isc::dns::MasterLoader;
+// XXX: Remove once the datasrc one exists
+using isc::dns::RRsetCollection;
 
 namespace isc {
 namespace datasrc {
@@ -99,6 +106,22 @@ copyRRsets(const ZoneUpdaterPtr& destination, const ZoneIteratorPtr& source,
     return (false); // Not yet, there may be more
 }
 
+void
+logWarning(const dns::Name* zone_name, const dns::RRClass* rrclass,
+           const std::string& reason)
+{
+    LOG_WARN(logger, DATASRC_VALIDATE_WARNING).arg(*zone_name).arg(*rrclass).
+        arg(reason);
+}
+
+void
+logError(const dns::Name* zone_name, const dns::RRClass* rrclass,
+         const std::string& reason)
+{
+    LOG_ERROR(logger, DATASRC_VALIDATE_ERROR).arg(*zone_name).arg(*rrclass).
+        arg(reason);
+}
+
 } // end unnamed namespace
 
 bool
@@ -123,6 +146,21 @@ ZoneLoader::loadIncremental(size_t limit) {
     }
 
     if (complete_) {
+        // Everything is loaded. Perform some basic sanity checks on the zone.
+        // XXX: Pass the updater_ (or its finder) once we have the datasrc
+        // collection
+        RRsetCollection collection;
+        dns::Name zone_name(updater_->getFinder().getOrigin());
+        dns::RRClass zone_class(updater_->getFinder().getClass());
+        dns::ZoneCheckerCallbacks
+            callbacks(boost::bind(&logError, &zone_name, &zone_class, _1),
+                      boost::bind(&logWarning, &zone_name, &zone_class, _1));
+        if (!dns::checkZone(zone_name, zone_class, collection, callbacks)) {
+            // Validation failed.
+            loaded_ok_ = false;
+            isc_throw(ZoneContentError, "Errors found when validating zone " <<
+                      zone_name << "/" << zone_class);
+        }
         updater_->commit();
     }
     return (complete_);



More information about the bind10-changes mailing list