Dcmanager subcloud add command returns an empty string (b' ') when using a YAML with indentation issue
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
StarlingX |
Fix Released
|
Low
|
srana |
Bug Description
Brief Description
-----------------
If the operator tries to add a subcloud using a YAML with indentation issue, a byte string is returned instead of an error message/proper string.
$ dcmanager subcloud add --bootstrap-address .... --bootstrap-values /home/sysadmin/
ERROR (app) b''
Severity
--------
Minor
Steps to Reproduce
------------------
1. Modify bootstrap yaml file to insert YAML indentation issue.
2. Add the subcloud
Expected Behavior
------------------
Error message displayed
Actual Behavior
----------------
CLI outputs byte string b' ' so operator need to investigate the reason through dcmanager-api.log
Reproducibility
---------------
100%
System Configuration
-------
DC
Branch/Pull Time/Commit
-------
Master (10/27/2023)
Last Pass
---------
This was never tested before.
Timestamp/Logs
--------------
xception in AuditLoggingHook passed to event 'on_error': mapping values are not allowed here
in "<unicode string>", line 42, column 13:
k8s.gcr.io:
^: yaml.scanner.
in "<unicode string>", line 42, column 13:
k8s.gcr.io:
^
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
2023-10-17 22:22:03.682 25339 ERROR dcmanager.
Test Activity
-------------
System Test
Workaround
----------
Fix YAML file
Changed in starlingx: | |
status: | New → In Progress |
Changed in starlingx: | |
importance: | Undecided → Low |
tags: | added: stx.9.0 stx.distcloud |
Changed in starlingx: | |
assignee: | nobody → srana (salmanr) |
Reviewed: https:/ /review. opendev. org/c/starlingx /distcloud/ +/899490 /opendev. org/starlingx/ distcloud/ commit/ a46055a2efd9a7a cb1e37368b55197 9ea3d650f1
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit a46055a2efd9a7a cb1e37368b55197 9ea3d650f1
Author: srana <email address hidden>
Date: Fri Oct 27 11:40:39 2023 -0400
Fix: Error Handling for YAML Load
Introduce yaml_safe_load, a util wrapper to invoke
yaml.safe_load and correctly handle malformed YAML files.
This wrapper catches exceptions thrown (e.g., incorrect syntax)
while loading/parsing a yaml file. Currently, there's no error
reported back to the user on such failures, rather an ambiguous
python object string is reported and the user is unaware of the
cause of failure. All calls for reading yaml files being uploaded
by the user have been replaced with the wrapper for correct error
reporting.
Test:
"Error: Unable to load file contents.
(problem on line: #)."
space after the colon:
" key:val"
malformed bootstrap file
following error message is reported:
"Error: Unable to load file contents.
(empty file provided)."
1. PASS: Ensure that the following error message is reported when
a malformed file is passed to a command:
- Add an entry in the bootstrap yaml file without a
- Run dcmanager subcloud add with the
- Check the cmdline reported error
2. PASS: Repeat test #1 with common YAML issues, for example:
- Incorrect indentation
- Missing new line between entries
3. PASS: Repeat test #1 with an empty file. Ensure that the
Closes-Bug: 2041679
Change-Id: I33210a45038d6d 4e98b69809ffa8d 2d431b43190
Signed-off-by: Salman Rana <email address hidden>