Merge ~sbparke/juju-lint:bug/1940546 into juju-lint:master

Proposed by Steven Parker
Status: Merged
Approved by: James Troup
Approved revision: 5cf42202029b6caa7fa676b7598afd417371e18b
Merged at revision: b4f4cd742ecba4454c36ca2274c62c672ae8d93c
Proposed branch: ~sbparke/juju-lint:bug/1940546
Merge into: juju-lint:master
Diff against target: 127 lines (+61/-1)
3 files modified
contrib/canonical-rules.yaml (+26/-0)
jujulint/lint.py (+21/-0)
tests/test_jujulint.py (+14/-1)
Reviewer Review Type Date Requested Status
Drew Freiberger (community) Approve
James Troup Pending
Review via email: mp+407741@code.launchpad.net

Commit message

Added operations/kubernetes mandatory charms and optional charms for k8s

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
Drew Freiberger (afreiberger) wrote :

Please fix unit tests like this:

https://pastebin.canonical.com/p/4qFCWm69jM/

review: Needs Fixing
Revision history for this message
Drew Freiberger (afreiberger) wrote :

Thanks, tests pass, checks work. Further bugs already exist for checks that may be missing.

Sample output from live k8s env:
https://pastebin.canonical.com/p/cFTyGGNYtK/

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

Change successfully merged at revision b4f4cd742ecba4454c36ca2274c62c672ae8d93c

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/contrib/canonical-rules.yaml b/contrib/canonical-rules.yaml
2index d109037..fcdfdaa 100644
3--- a/contrib/canonical-rules.yaml
4+++ b/contrib/canonical-rules.yaml
5@@ -91,6 +91,23 @@ subordinates:
6 logrotated:
7 where: all
8
9+kubernetes mandatory: &kubernetes-mandatory-charms
10+ - containerd
11+ - kubeapi-load-balancer
12+ - kubernetes-master
13+ - kubernetes-worker
14+
15+kubernetes optional charms: &kubernetes-optional-charms
16+ - calico
17+ - canal
18+ - coredns
19+ - easyrsa
20+ - etcd
21+ - flannel
22+ - kubernetes-dashboard
23+ - openstack-integrator
24+ - vsphere-integrator
25+
26 operations mandatory: &operations-mandatory-charms
27 - elasticsearch
28 - grafana
29@@ -110,6 +127,9 @@ operations openstack mandatory: &operations-openstack-mandatory-charms
30 - prometheus-ceph-exporter
31 - prometheus-grok-exporter
32
33+operations kubernetes mandatory: &operations-kubernetes-mandatory-charms
34+ - kubernetes-service-checks
35+
36 operations mandatory dependencies: &operations-mandatory-deps
37 - postgresql
38
39@@ -135,6 +155,7 @@ operations optional subordinates: &operations-optional-subs
40 - rsyslog-forwarder-ha
41
42 operations charms: &operations-charms
43+ - *operations-kubernetes-mandatory-charms
44 - *operations-mandatory-charms
45 - *operations-mandatory-deps
46 - *operations-mandatory-subs
47@@ -222,7 +243,12 @@ openstack charms: &openstack-charms
48 - *masakari-charms
49 - *trilio-charms
50
51+kubernetes charms: &kubernetes-charms
52+ - *kubernetes-mandatory-charms
53+ - *kubernetes-optional-charms
54+
55 known charms:
56 - ubuntu
57 - *openstack-charms
58 - *operations-charms
59+ - *kubernetes-charms
60diff --git a/jujulint/lint.py b/jujulint/lint.py
61index 4e2f70a..a8ae702 100755
62--- a/jujulint/lint.py
63+++ b/jujulint/lint.py
64@@ -719,6 +719,27 @@ class Linter:
65 "message": "Kubernetes charm '{}' is missing".format(charm),
66 }
67 )
68+ for charm in self.lint_rules["operations kubernetes mandatory"]:
69+ if charm not in self.model.charms:
70+ self.handle_error(
71+ {
72+ "id": "kubernetes-ops-charm-missing",
73+ "tags": [
74+ "missing",
75+ "openstack",
76+ "ops",
77+ "charm",
78+ "mandatory",
79+ "principal",
80+ ],
81+ "description": "An Kubernetes ops charm is missing",
82+ "charm": charm,
83+ "message": "Kubernetes ops charm '{}' is missing".format(
84+ charm
85+ ),
86+ }
87+ )
88+
89
90 def results(self):
91 """Provide results of the linting process."""
92diff --git a/tests/test_jujulint.py b/tests/test_jujulint.py
93index 7dacb7d..35c4bbe 100644
94--- a/tests/test_jujulint.py
95+++ b/tests/test_jujulint.py
96@@ -242,10 +242,11 @@ class TestLinter:
97 assert errors[0]["id"] == "openstack-ops-charm-missing"
98 assert errors[0]["charm"] == "openstack-service-checks"
99
100- def test_openstack_charm_missing(self, linter, juju_status):
101+ def test_kubernetes_charm_missing(self, linter, juju_status):
102 """Test that missing kubernetes mandatory charms are detected."""
103 linter.cloud_type = "kubernetes"
104 linter.lint_rules["kubernetes mandatory"] = ["kubernetes-master"]
105+ linter.lint_rules["operations kubernetes mandatory"] = []
106 linter.do_lint(juju_status)
107
108 errors = linter.output_collector["errors"]
109@@ -253,6 +254,18 @@ class TestLinter:
110 assert errors[0]["id"] == "kubernetes-charm-missing"
111 assert errors[0]["charm"] == "kubernetes-master"
112
113+ def test_kubernetes_ops_charm_missing(self, linter, juju_status):
114+ """Test that missing kubernetes mandatory charms are detected."""
115+ linter.cloud_type = "kubernetes"
116+ linter.lint_rules["kubernetes mandatory"] = []
117+ linter.lint_rules["operations kubernetes mandatory"] = ["ntp"]
118+ linter.do_lint(juju_status)
119+
120+ errors = linter.output_collector["errors"]
121+ assert len(errors) == 1
122+ assert errors[0]["id"] == "kubernetes-ops-charm-missing"
123+ assert errors[0]["charm"] == "ntp"
124+
125 def test_config_eq(self, linter, juju_status):
126 """Test the config condition 'eq'."""
127 linter.lint_rules["config"] = {"ubuntu": {"fake-opt": {"eq": False}}}

Subscribers

People subscribed via source and target branches