weizhouapache opened a new pull request, #8739:
URL: https://github.com/apache/cloudstack/pull/8739
### Description
This PR fixes the issue that VM cannot start with binary userdata. This is a
regression of #8497
Steps to reproduce the issue and verify the fix
1. create a userdata with content below
cloud-init supports gzip compress userdata. for example
```
$ echo "Apache CloudStack" |gzip |base64 -w0
H4sIAAAAAAAAA3MsSEzOSFVwzskvTQkuSUzO5gIAxXcOkxIAAAA=
```
3. deploy a vm with the userdata, it failed
```
2024-03-04T11:13:27,400 DEBUG [c.c.a.t.Request] (AgentManager-Handler-7:[])
(logid:) Seq 1-8288593639198687341:
Processing: { Ans: , MgmtId: 167781234, via: 1, Ver: v1, Flags: 10,
[{"com.cloud.agent.api.routing.GroupAnswer":{"results":
["null - success: Creating file in VR, with ip: 169.254.52.151, file:
vm_password.json.5f0a36da-6fa7-48e4-8aae-
dcc8923fc42d","null - success:
"],"result":"true","wait":"0","bypassHostMaintenance":"false"}},
{"com.cloud.agent.api.routing.GroupAnswer":{"results":["null - success:
Creating file in VR, with ip: 169.254.52.151, file:
vm_metadata.json.53c05bda-dc05-49df-b548-f517ae0fa546","null - failed:
Traceback (most recent call last): File
"/opt/cloud/bin/update_config.py", line 147, in <module> process_file()
File "/opt/cloud/bin/update_config.py", line 57, in
process_file finish_config() File "/opt/cloud/bin/update_config.py",
line 42, in finish_config returncode =
configure.main(sys.argv) ^^^^^^^^^^^^^^^^^^^^^^^^ File
"/opt/cloud/bin/configure.py", line 1413, in main
execDatabag(json_type, databag_map) File "/opt/cloud/bin/configure.py",
line 1400, in execDatabag executor.process() File
"/opt/cloud/bin/configure.py", line 625, in process self.__createfile(ip,
folder, file, data) File "/opt/cloud/bin/configure.py", line
652, in __createfile fh.write(data.decode())
^^^^^^^^^^^^^UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in
position 1: invalid start
byte"],"result":"false","wait":"0","bypassHostMaintenance":"false"}}] }
```
4. apply this PR, vm is started successfully
5. check the userdata in vm

<!--- Describe your changes in DETAIL - And how has behaviour functionally
changed. -->
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to
reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be
closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!---
*******************************************************************************
-->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE
DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!---
*******************************************************************************
-->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] build/CI
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [ ] Minor
#### Bug Severity
- [ ] BLOCKER
- [x] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to
-->
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
document -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]