Merge ~mthaddon/charm-k8s-ingress/+git/charm-k8s-ingress:unknown-message into charm-k8s-ingress:master

Proposed by Tom Haddon
Status: Merged
Approved by: Jon Seager
Approved revision: 80c0ad31f0d12fba98a85322d5955752a2bc9fe5
Merged at revision: 36e7314e2ed5e03f992cfe4a5fa37ae1afb59ca5
Proposed branch: ~mthaddon/charm-k8s-ingress/+git/charm-k8s-ingress:unknown-message
Merge into: charm-k8s-ingress:master
Diff against target: 46 lines (+10/-10)
1 file modified
lib/charms/nginx_ingress_integrator/v0/ingress.py (+10/-10)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-is (community) continuous-integration Approve
ingress-charmers Pending
Review via email: mp+401394@code.launchpad.net

Commit message

If we have unknown fields in the relation, return appropriate error

Description of the change

If we have unknown fields in the relation, return appropriate error.

Previous to this change we'd check for unknown fields, but also check for missing required fields. We should only ever return the first error message to avoid confusion.

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
🤖 prod-jenkaas-is (prod-jenkaas-is) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-is (prod-jenkaas-is) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-is (prod-jenkaas-is) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

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

Change successfully merged at revision 36e7314e2ed5e03f992cfe4a5fa37ae1afb59ca5

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/charms/nginx_ingress_integrator/v0/ingress.py b/lib/charms/nginx_ingress_integrator/v0/ingress.py
2index bbb8a71..a935d5a 100644
3--- a/lib/charms/nginx_ingress_integrator/v0/ingress.py
4+++ b/lib/charms/nginx_ingress_integrator/v0/ingress.py
5@@ -53,9 +53,9 @@ LIBID = "db0af4367506491c91663468fb5caa4c"
6 # Increment this major API version when introducing breaking changes
7 LIBAPI = 0
8
9-# Increment this PATCH version before using `charmcraft push-lib` or reset
10+# Increment this PATCH version before using `charmcraft publish-lib` or reset
11 # to 0 if you are raising the major API version
12-LIBPATCH = 2
13+LIBPATCH = 3
14
15 logger = logging.getLogger(__name__)
16
17@@ -102,21 +102,21 @@ class IngressRequires(Object):
18
19 def _config_dict_errors(self, update_only=False):
20 """Check our config dict for errors."""
21- block_status = False
22+ blocked_message = "Error in ingress relation, check `juju debug-log`"
23 unknown = [
24 x for x in self.config_dict if x not in REQUIRED_INGRESS_RELATION_FIELDS | OPTIONAL_INGRESS_RELATION_FIELDS
25 ]
26 if unknown:
27- logger.error("Unknown key(s) in config dictionary found: %s", ", ".join(unknown))
28- block_status = True
29+ logger.error("Ingress relation error, unknown key(s) in config dictionary found: %s", ", ".join(unknown))
30+ self.model.unit.status = BlockedStatus(blocked_message)
31+ return True
32 if not update_only:
33 missing = [x for x in REQUIRED_INGRESS_RELATION_FIELDS if x not in self.config_dict]
34 if missing:
35- logger.error("Missing required key(s) in config dictionary: %s", ", ".join(missing))
36- block_status = True
37- if block_status:
38- self.model.unit.status = BlockedStatus("Error in ingress relation, check `juju debug-log`")
39- return True
40+ logger.error(
41+ "Ingress relation error, missing required key(s) in config dictionary: %s", ", ".join(missing))
42+ self.model.unit.status = BlockedStatus(blocked_message)
43+ return True
44 return False
45
46 def _on_relation_changed(self, event):

Subscribers

People subscribed via source and target branches

to all changes: