Add type checking of fields in Layer specification to avoid list vs str issues
See original GitHub issueWhen defining dependent layer (based on Layer specification) I’ve noticed that I cannot use layer names longer than 1 character. If I change layer definition to p
, everything works.
return {
"summary": "opensearch layer",
"description": "pebble config layer for opensearchproject/opensearch",
"services": {
"procps": {
"override": "merge",
"command": "yum install -y procps",
"startup": "enabled",
"summary": "procps",
},
"opensearch": {
"requires": "procps",
"override": "merge",
"environment": environment,
"summary": "opensearch",
"command": cmd,
"startup": "disabled",
}
}
}
unit-opensearch-k8s-0: 16:12:32 ERROR juju.worker.uniter.operation hook "opensearch-pebble-ready" (via hook dispatching script: dispatch) failed: exit status 1
unit-opensearch-k8s-0: 16:12:32 ERROR juju.worker.uniter pebble poll failed for container "opensearch": hook failed
unit-opensearch-k8s-0: 16:12:37 ERROR unit.opensearch-k8s/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/pebble.py", line 729, in _request_raw
response = self.opener.open(request, timeout=self.timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./src/charm.py", line 142, in <module>
main(CharmOpenSearch)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/main.py", line 406, in main
_emit_charm_event(charm, dispatcher.event_name)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/main.py", line 140, in _emit_charm_event
event_to_emit.emit(*args, **kwargs)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/framework.py", line 278, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/framework.py", line 722, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/framework.py", line 767, in _reemit
custom_handler(event)
File "./src/charm.py", line 102, in _on_opensearch_pebble_ready
container.add_layer("opensearch", layer, combine=True)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/model.py", line 1067, in add_layer
self._pebble.add_layer(label, layer, combine=combine)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/pebble.py", line 879, in add_layer
self._request('POST', '/v1/layers', body=body)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/pebble.py", line 700, in _request
response = self._request_raw(method, path, query, headers, data)
File "/var/lib/juju/agents/unit-opensearch-k8s-0/charm/venv/ops/pebble.py", line 740, in _request_raw
raise APIError(body, code, status, message)
ops.pebble.APIError: cannot parse layer YAML: service "p" does not exist
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Layers | Style Specification | Mapbox GL JS
A style's layers property lists all the layers available in that style. The type of layer is specified by the "type" property, and...
Read more >TSConfig Reference - Docs on every TSConfig option
A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript project... Compiler Options. Top Level....
Read more >Quick reference—ArcGIS Survey123 | Documentation
ArcGIS Survey123 supports a large amount of the XLSForm specification. This reference guide provides a summary of the XLSForm features that you can...
Read more >java - How can I validate two or more fields in combination?
The model is invalid if both getValue1() and getValue2() are null and valid otherwise. How can I perform this kind of validation with...
Read more >Structural pattern matching in Python 3.10 - Ben Hoyt
Go to: What it is | Where it shines | My code | Other projects | Problems | Wrapping ... Match sequences using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds good – I’ve renamed the issue title to reflect what we intend to do to fix it. Could add some simple checks into the list fields, or potentially start using a involved schema definition tool like voluptuous
We should still have a bug that notices if you are using a string instead of a list and error/warn because it is a common pitfall and not what you want. We protect against that sort of misuse elsewhere, and it leads to better information for people writing a charm.
On Sat, May 22, 2021 at 8:39 AM Jon Seager @.***> wrote: