]> granicus.if.org Git - icinga2/commitdiff
Fix cluster crash w/ config sync 5249/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Fri, 12 May 2017 08:48:11 +0000 (10:48 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 12 May 2017 08:48:11 +0000 (10:48 +0200)
refs #5212

lib/remote/apilistener-filesync.cpp
lib/remote/apilistener.cpp
lib/remote/apilistener.hpp

index a798dfe680ad1d9d570e930078df46945a8209fd..d4a4a21da6905623233be9be33dcc7680636cca0 100644 (file)
@@ -283,8 +283,8 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D
        }
 
        Log(LogInformation, "ApiListener")
-           << "Applying config update from endpoint '" << origin->FromClient->GetEndpoint()->GetName() << "' of zone  '"
-           << origin->FromZone->GetName() << "'";
+           << "Applying config update from endpoint '" << origin->FromClient->GetEndpoint()->GetName()
+           << "' of zone '" << GetFromZoneName(origin->FromZone) << "'.";
 
        Dictionary::Ptr updateV1 = params->Get("update");
        Dictionary::Ptr updateV2 = params->Get("update_v2");
index 55f628fa87c6632f632ae42ec2d9ca6e0a0dce6d..21ccae3619be9f1ce7189cc64afb593d43b95118 100644 (file)
@@ -1245,3 +1245,19 @@ bool ApiListener::IsHACluster(void)
        return zone->IsSingleInstance();
 }
 
+/* Provide a helper function for zone origin name. */
+String ApiListener::GetFromZoneName(const Zone::Ptr& fromZone)
+{
+       String fromZoneName;
+
+       if (fromZone) {
+               fromZoneName = fromZone->GetName();
+       } else {
+               Zone::Ptr lzone = Zone::GetLocalZone();
+
+               if (lzone)
+                       fromZoneName = lzone->GetName();
+       }
+
+       return fromZoneName;
+}
index e7749827f6ab493a48b06aed283d11ddfc32d4d9..8e12f0dcae147c40eb8e4e8d9ec0b22c272f70fe 100644 (file)
@@ -99,6 +99,7 @@ public:
        static void UpdateObjectAuthority(void);
 
        static bool IsHACluster(void);
+       static String GetFromZoneName(const Zone::Ptr& fromZone);
 
 protected:
        virtual void OnConfigLoaded(void) override;