Bug 1868439

Summary: openstack UPI: scripts fail modifying the masters Ignition file
Product: OpenShift Container Platform Reporter: Pierre Prinetti <pprinett>
Component: InstallerAssignee: Pierre Prinetti <pprinett>
Installer sub component: OpenShift on OpenStack QA Contact: weiwei jiang <wjiang>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: jmalde, mbridges, mvardhan, rheinzma, wjiang
Version: 4.6Keywords: UpcomingSprint
Target Milestone: ---   
Target Release: 4.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: A change in how Ignition files are generated in 4.6 removed an empty property from Ignition files. Consequence: A Python 'KeyError' when running the steaps documented in UPI Fix: The documentation is updated to create the missing key. Result: The error is not happening any more.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 16:28:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pierre Prinetti 2020-08-12 17:13:40 UTC
Description of problem:

While applying this script:

```
python -c "import base64, json, sys;
    python -c "import base64, json, sys;
ignition = json.load(sys.stdin);
ignition = json.load(sys.stdin);
files = ignition['storage'].get('files', []);
storage = ignition.get('storage', {});
files.append({'path': '/etc/hostname', 'mode': 420, 'contents': {'source': 'data:text/plain;charset=utf-8;base64,' + base64.standard_b64encode(b'$MASTER_HOSTNAME').decode().strip()}});
files = storage.get('files', []);
ignition['storage']['files'] = files;
files.append({'path': '/etc/hostname', 'mode': 420, 'contents': {'source': 'data:text/plain;charset=utf-8;base64,' + base64.standard_b64encode(b'$MASTER_HOSTNAME').decode().strip(), 'verification': {}}, 'filesystem': 'root'});
storage['files'] = files;
ignition['storage'] = storage
json.dump(ignition, sys.stdout)" <master.ign
```

Python fails with:

```
Traceback (most recent call last):
  File "<string>", line 3, in <module>
KeyError: 'storage' 
```

The 'storage' property does not seem to be present any more in the master ignition file.

Comment 2 Pierre Prinetti 2020-09-08 15:05:25 UTC
*** Bug 1876835 has been marked as a duplicate of this bug. ***

Comment 5 weiwei jiang 2020-09-09 10:08:46 UTC
Verified

$ python -c "import base64, json, sys;                                                                                                                                                                                       
ignition = json.load(sys.stdin);
storage = ignition.get('storage', {});
files = storage.get('files', []);
files.append({'path': '/etc/hostname', 'mode': 420, 'contents': {'source': 'data:text/plain;charset=utf-8;base64,' + base64.standard_b64encode(b'$MASTER_HOSTNAME').decode().strip()}});
storage['files'] = files;
ignition['storage'] = storage
json.dump(ignition, sys.stdout)" <master.ign
{"ignition": {"config": {"merge": [{"source": "https://192.168.0.5:22623/config/master"}]}, "security": {"tls": {"certificateAuthorities": [{"source": "data:text/plain;charset=utf-8;base64,xxxxxxxxx"}]}}, "version": "3.1.0"}, "storage": {"files": [{"path": "/etc/hostname", "mode": 420, "contents": {"source": "data:text/plain;charset=utf-8;base64,"}}]}}

Comment 6 Max Bridges 2020-09-18 19:05:48 UTC
@wjiang Can you verify this downstream, too?

https://github.com/openshift/openshift-docs/pull/25605

Comment 7 Max Bridges 2020-09-24 12:20:34 UTC
*** Bug 1876843 has been marked as a duplicate of this bug. ***

Comment 8 Max Bridges 2020-10-07 16:25:19 UTC
Moving to QE again, as this needs to be verified in the downstream docs, too. 

https://github.com/openshift/openshift-docs/pull/25605

Comment 9 weiwei jiang 2020-10-09 02:52:53 UTC
The Doc look good from the QE perspective, so move to verified.

Comment 10 Max Bridges 2020-10-09 13:44:10 UTC
Change merged into 4.6 release + master branches.

Comment 12 errata-xmlrpc 2020-10-27 16:28:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.6 GA Images), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4196