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
diff --git a/contrib/canonical-rules.yaml b/contrib/canonical-rules.yaml
index d109037..fcdfdaa 100644
--- a/contrib/canonical-rules.yaml
+++ b/contrib/canonical-rules.yaml
@@ -91,6 +91,23 @@ subordinates:
91 logrotated:91 logrotated:
92 where: all92 where: all
9393
94kubernetes mandatory: &kubernetes-mandatory-charms
95 - containerd
96 - kubeapi-load-balancer
97 - kubernetes-master
98 - kubernetes-worker
99
100kubernetes optional charms: &kubernetes-optional-charms
101 - calico
102 - canal
103 - coredns
104 - easyrsa
105 - etcd
106 - flannel
107 - kubernetes-dashboard
108 - openstack-integrator
109 - vsphere-integrator
110
94operations mandatory: &operations-mandatory-charms111operations mandatory: &operations-mandatory-charms
95 - elasticsearch112 - elasticsearch
96 - grafana113 - grafana
@@ -110,6 +127,9 @@ operations openstack mandatory: &operations-openstack-mandatory-charms
110 - prometheus-ceph-exporter127 - prometheus-ceph-exporter
111 - prometheus-grok-exporter128 - prometheus-grok-exporter
112129
130operations kubernetes mandatory: &operations-kubernetes-mandatory-charms
131 - kubernetes-service-checks
132
113operations mandatory dependencies: &operations-mandatory-deps133operations mandatory dependencies: &operations-mandatory-deps
114 - postgresql134 - postgresql
115135
@@ -135,6 +155,7 @@ operations optional subordinates: &operations-optional-subs
135 - rsyslog-forwarder-ha155 - rsyslog-forwarder-ha
136156
137operations charms: &operations-charms157operations charms: &operations-charms
158 - *operations-kubernetes-mandatory-charms
138 - *operations-mandatory-charms159 - *operations-mandatory-charms
139 - *operations-mandatory-deps160 - *operations-mandatory-deps
140 - *operations-mandatory-subs161 - *operations-mandatory-subs
@@ -222,7 +243,12 @@ openstack charms: &openstack-charms
222 - *masakari-charms243 - *masakari-charms
223 - *trilio-charms244 - *trilio-charms
224245
246kubernetes charms: &kubernetes-charms
247 - *kubernetes-mandatory-charms
248 - *kubernetes-optional-charms
249
225known charms:250known charms:
226 - ubuntu251 - ubuntu
227 - *openstack-charms252 - *openstack-charms
228 - *operations-charms253 - *operations-charms
254 - *kubernetes-charms
diff --git a/jujulint/lint.py b/jujulint/lint.py
index 4e2f70a..a8ae702 100755
--- a/jujulint/lint.py
+++ b/jujulint/lint.py
@@ -719,6 +719,27 @@ class Linter:
719 "message": "Kubernetes charm '{}' is missing".format(charm),719 "message": "Kubernetes charm '{}' is missing".format(charm),
720 }720 }
721 )721 )
722 for charm in self.lint_rules["operations kubernetes mandatory"]:
723 if charm not in self.model.charms:
724 self.handle_error(
725 {
726 "id": "kubernetes-ops-charm-missing",
727 "tags": [
728 "missing",
729 "openstack",
730 "ops",
731 "charm",
732 "mandatory",
733 "principal",
734 ],
735 "description": "An Kubernetes ops charm is missing",
736 "charm": charm,
737 "message": "Kubernetes ops charm '{}' is missing".format(
738 charm
739 ),
740 }
741 )
742
722743
723 def results(self):744 def results(self):
724 """Provide results of the linting process."""745 """Provide results of the linting process."""
diff --git a/tests/test_jujulint.py b/tests/test_jujulint.py
index 7dacb7d..35c4bbe 100644
--- a/tests/test_jujulint.py
+++ b/tests/test_jujulint.py
@@ -242,10 +242,11 @@ class TestLinter:
242 assert errors[0]["id"] == "openstack-ops-charm-missing"242 assert errors[0]["id"] == "openstack-ops-charm-missing"
243 assert errors[0]["charm"] == "openstack-service-checks"243 assert errors[0]["charm"] == "openstack-service-checks"
244244
245 def test_openstack_charm_missing(self, linter, juju_status):245 def test_kubernetes_charm_missing(self, linter, juju_status):
246 """Test that missing kubernetes mandatory charms are detected."""246 """Test that missing kubernetes mandatory charms are detected."""
247 linter.cloud_type = "kubernetes"247 linter.cloud_type = "kubernetes"
248 linter.lint_rules["kubernetes mandatory"] = ["kubernetes-master"]248 linter.lint_rules["kubernetes mandatory"] = ["kubernetes-master"]
249 linter.lint_rules["operations kubernetes mandatory"] = []
249 linter.do_lint(juju_status)250 linter.do_lint(juju_status)
250251
251 errors = linter.output_collector["errors"]252 errors = linter.output_collector["errors"]
@@ -253,6 +254,18 @@ class TestLinter:
253 assert errors[0]["id"] == "kubernetes-charm-missing"254 assert errors[0]["id"] == "kubernetes-charm-missing"
254 assert errors[0]["charm"] == "kubernetes-master"255 assert errors[0]["charm"] == "kubernetes-master"
255256
257 def test_kubernetes_ops_charm_missing(self, linter, juju_status):
258 """Test that missing kubernetes mandatory charms are detected."""
259 linter.cloud_type = "kubernetes"
260 linter.lint_rules["kubernetes mandatory"] = []
261 linter.lint_rules["operations kubernetes mandatory"] = ["ntp"]
262 linter.do_lint(juju_status)
263
264 errors = linter.output_collector["errors"]
265 assert len(errors) == 1
266 assert errors[0]["id"] == "kubernetes-ops-charm-missing"
267 assert errors[0]["charm"] == "ntp"
268
256 def test_config_eq(self, linter, juju_status):269 def test_config_eq(self, linter, juju_status):
257 """Test the config condition 'eq'."""270 """Test the config condition 'eq'."""
258 linter.lint_rules["config"] = {"ubuntu": {"fake-opt": {"eq": False}}}271 linter.lint_rules["config"] = {"ubuntu": {"fake-opt": {"eq": False}}}

Subscribers

People subscribed via source and target branches