Giuseppe Lavagetto has submitted this change and it was merged.

Change subject: naggen2: do not output duplicate resources
......................................................................


naggen2: do not output duplicate resources

Due to the way we collect monitoring information, it can happen we have
duplicate information that, if printed, would result in an invalid
icinga config.

Rely on the fact that names of resources uniquely identify them to
reduce the overhead.

Change-Id: Ib96e7c1edee1f584efa4a7a3664e488e9836a990
---
M modules/puppetmaster/files/naggen2
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, approved
  Volans: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/modules/puppetmaster/files/naggen2 
b/modules/puppetmaster/files/naggen2
index ed5077c..7c0d3a1 100755
--- a/modules/puppetmaster/files/naggen2
+++ b/modules/puppetmaster/files/naggen2
@@ -65,9 +65,15 @@
             self.log.error('Exiting  - unsupported resource type %s', what)
             sys.exit(1)
         try:
+            entities = set()
             for entity in self._query(what):
                 self.log.debug('Working on resource %s', entity['title'])
                 name, content = self._filter_entity(entity, what)
+                if name in entities:
+                    self.log.warn('Duplicate definition for %s', name)
+                    continue
+
+                entities.add(name)
                 tpl = self.env.get_template(what)
                 yield tpl.render(name=name, data=content)
         except Exception:

-- 
To view, visit https://gerrit.wikimedia.org/r/314522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib96e7c1edee1f584efa4a7a3664e488e9836a990
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Volans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to