Merge ~arif-ali/juju-lint/+git/juju-lint:lp_1855857 into juju-lint:master

Proposed by Arif Ali
Status: Merged
Approved by: James Hebden
Approved revision: fd2712ec167f4b7ec9fd82f2e19c36b87f019f31
Merged at revision: ec12e91e4470e975e2da72cbba82bfb9be093110
Proposed branch: ~arif-ali/juju-lint/+git/juju-lint:lp_1855857
Merge into: juju-lint:master
Diff against target: 41 lines (+23/-0)
1 file modified
jujulint/lint.py (+23/-0)
Reviewer Review Type Date Requested Status
James Hebden (community) Approve
Review via email: mp+383939@code.launchpad.net

Commit message

Allow the option for exception for container aware

Fixes: LP #1855857

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Arif Ali (arif-ali) wrote :

This commit will allow us to have the following in the yaml file

```
subordinates:
 nrpe:
  where: container aware
  host-suffixes: [host, physical, guest]
  container-suffixes: [lxd, container]
  exceptions: [nagios]
```

Revision history for this message
Arif Ali (arif-ali) wrote :

rebased to new codebase

Revision history for this message
Arif Ali (arif-ali) wrote :

pinging this again, if anyone could have a look

Revision history for this message
James Hebden (ec0) wrote :

Thanks for the MR. Please see comments inline. Actual change looks great, I have some concerns about the setup.py changes. This would close out bug #1801100 with the appropriate exception for nagios on the NRPE mandatory subordinate rule.

review: Needs Fixing
Revision history for this message
James Hebden (ec0) wrote :

Additionally, please consider reviving the existing "except nagios" logic on the subordinate rule instead of adding a new key. It could be easier and cleaner to simply make the following work -

subordinates:
  nrpe:
    where: container aware except nagios
    host-suffixes: [host, physical, guest]
    container-suffixes: [lxd, container]

Revision history for this message
Arif Ali (arif-ali) wrote :

> Additionally, please consider reviving the existing "except nagios" logic on
> the subordinate rule instead of adding a new key. It could be easier and
> cleaner to simply make the following work -
>
> subordinates:
> nrpe:
> where: container aware except nagios
> host-suffixes: [host, physical, guest]
> container-suffixes: [lxd, container]

The reason, why I did it this way, was that this would allow multiple exceptions, rather than the one.

But happy to go in that direction, if you would prefer

Revision history for this message
James Hebden (ec0) wrote :

OK, that makes sense, I can't think of a tidy way to do multiple exceptions with the previous logic. Thanks!

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision ec12e91e4470e975e2da72cbba82bfb9be093110

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jujulint/lint.py b/jujulint/lint.py
2index 6e6a1b0..26f2c81 100755
3--- a/jujulint/lint.py
4+++ b/jujulint/lint.py
5@@ -458,6 +458,17 @@ class Linter:
6 suffixes,
7 )
8 )
9+ exceptions = []
10+ if "exceptions" in self.lint_rules["subordinates"][required_sub]:
11+ exceptions = self.lint_rules["subordinates"][required_sub]["exceptions"]
12+ self.logger.debug(
13+ "[{}] [{}/{}] -> exceptions == {}".format(
14+ self.cloud_name,
15+ self.controller_name,
16+ self.model_name,
17+ exceptions,
18+ )
19+ )
20 found = False
21 for suffix in suffixes:
22 looking_for = "{}-{}".format(required_sub, suffix)
23@@ -488,6 +499,18 @@ class Linter:
24 )
25 found = True
26 if not found:
27+ for exception in exceptions:
28+ if exception in apps:
29+ self.logger.debug(
30+ "[{}] [{}/{}]-> continuing as found exception: {}".format(
31+ self.cloud_name,
32+ self.controller_name,
33+ self.model_name,
34+ exception,
35+ )
36+ )
37+ found = True
38+ if not found:
39 self.logger.debug(
40 "[{}] [{}/{}] -> NOT FOUND".format(
41 self.cloud_name, self.controller_name, self.model_name,

Subscribers

People subscribed via source and target branches