Bug 1465440 - Cloud-init sysconifg.py called util.write_file incorrectly
Cloud-init sysconifg.py called util.write_file incorrectly
Status: ON_QA
Product: Fedora
Classification: Fedora
Component: cloud-init (Show other bugs)
26
x86_64 Linux
unspecified Severity medium
: ---
: ---
Assigned To: Garrett Holmstrom
Fedora Extras Quality Assurance
AcceptedFreezeException
: Reopened
Depends On:
Blocks: F26FinalFreezeException
  Show dependency treegraph
 
Reported: 2017-06-27 08:37 EDT by Ben Howard
Modified: 2017-09-19 21:21 EDT (History)
10 users (show)

See Also:
Fixed In Version: cloud-init-0.7.9-7.fc26
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-07-06 18:50:48 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ben Howard 2017-06-27 08:37:43 EDT
When provisioning Fedora 25 and 26 Atomic, it fails to setup networking due to:

This is caused by line 423, which calls util.write incorrectly: 
util.write_file(nm_conf_path, nm_conf_content, file_mode)

The third parameter of "file_mode" appears to be a backport, since it appears in the current upstream trunk. 

Potential fix:
--- /usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py	1970-01-01 00:00:00.000000000 +0000
+++ /tmp/sysconfig.py	2017-06-27 12:36:47.455379873 +0000
@@ -420,7 +420,7 @@
                                             self.networkmanager_conf_path)
             nm_conf_content = self._render_networkmanager_conf(network_state)
             if nm_conf_content:
-                util.write_file(nm_conf_path, nm_conf_content, file_mode)
+                util.write_file(nm_conf_path, nm_conf_content)
         if self.netrules_path:
             netrules_content = self._render_persistent_net(network_state)
             netrules_path = os.path.join(target, self.netrules_path)
Comment 1 Lars Kellogg-Stedman 2017-06-27 08:58:01 EDT
That appears to be a mis-applied backport.  The changes to write_file were implemented in https://git.launchpad.net/cloud-init/commit/?id=721348a6 to resolve https://bugzilla.redhat.com/show_bug.cgi?id=1295984.

I think that the fix in the description here is incorrect; rather, the Fedora package should probably carry 721348a6 as well.
Comment 2 Lars Kellogg-Stedman 2017-06-27 09:04:19 EDT
Actually, I lied. The support for the mode parameter has been around forever. Going back to 0.7.5, write_file looks like:

   def write_file(filename, content, mode=0644, omode="wb"):

Which is fine.  So actually, I don't see any problem here.  Are you seeing some sort of failure?  Could you post the error/traceback? Thanks!
Comment 3 Dusty Mabe 2017-06-27 09:10:42 EDT
Here is the traceback he sent me earlier:

```
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper
    ret = functor(name, args) 
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 269, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python3.6/site-packages/cloudinit/stages.py", line 641, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/__init__.py", line 150, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/rhel.py", line 60, in _write_network_config 
    self._net_renderer.render_network_state("/", ns)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 423, in render_network_state   
    util.write_file(nm_conf_path, nm_conf_content, file_mode)
  NameError: name 'file_mode' is not defined
```
Comment 4 Lars Kellogg-Stedman 2017-06-27 09:17:47 EDT
Okay, so, still a mis-applied backport.  The file_mode variable should be defined at the top of render_network_state.  That was introduced in ef18b8ac4cf7e3dfd98830fbdb298380a192a0fc.
Comment 5 Fedora Update System 2017-06-27 19:09:23 EDT
cloud-init-0.7.9-7.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-faae58b0d0
Comment 6 Fedora Update System 2017-06-27 19:09:43 EDT
cloud-init-0.7.9-7.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-faae58b0d0
Comment 7 Garrett Holmstrom 2017-06-27 19:17:15 EDT
F26 update:  https://bodhi.fedoraproject.org/updates/cloud-init-0.7.9-7.fc26
Comment 8 Fedora Update System 2017-06-28 15:20:32 EDT
cloud-init-0.7.9-7.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-a687a6d05c
Comment 9 Fedora Update System 2017-06-28 17:53:00 EDT
cloud-init-0.7.9-7.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-faae58b0d0
Comment 11 Fedora Blocker Bugs Application 2017-06-28 22:19:00 EDT
Proposed as a Freeze Exception for 26-final by Fedora user dustymabe using the blocker tracking app because:

 This fixes an issue with static networking configuration in cloud-init. Our DigitalOcean images use this in order to configure network. Please allow it as a freeze exception.
Comment 12 Ben Howard 2017-06-29 08:30:14 EDT
Images posted in Comment #10 still have the previous version of Cloud-init:

# rpm -qa cloud-init
cloud-init-0.7.9-6.fc26.noarch

/var/log/cloud-init.log
2017-06-29 12:26:26,021 - util.py[DEBUG]: failed stage init-local
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 269, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python3.6/site-packages/cloudinit/stages.py", line 641, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/__init__.py", line 150, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/rhel.py", line 60, in _write_network_config
    self._net_renderer.render_network_state("/", ns)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 423, in render_network_state
    util.write_file(nm_conf_path, nm_conf_content, file_mode)
NameError: name 'file_mode' is not defined
Comment 13 Dusty Mabe 2017-06-29 09:49:03 EDT
ok the cloud base image did not have the new cloud-init. The atomic image was good. Can you re-download the cloud-base image and verify your images match:


```
$ md5sum atomic-host-cloud-init-0.7.9-7.qcow2 cloud-base-cloud-init-0.7.9-7.qcow2 
50c418f240b04ef7ceaa6e933d0de628  atomic-host-cloud-init-0.7.9-7.qcow2
e56b3b64a2b1bd3a569afe7f90a2b62a  cloud-base-cloud-init-0.7.9-7.qcow2
```
Comment 14 Adam Williamson 2017-06-29 15:30:53 EDT
Discussed at 2017-06-29 freeze exception review meeting: https://meetbot-raw.fedoraproject.org/fedora-blocker-review/2017-06-29/f26-blocker-review.2017-06-29-16.00.html . Accepted as a freeze exception as a significant issue which can't be fully fixed with a post-release update.
Comment 15 Fedora Update System 2017-07-06 18:50:48 EDT
cloud-init-0.7.9-7.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.
Comment 16 Fedora Update System 2017-09-18 18:38:19 EDT
cloud-init-0.7.9-9.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-5507234819
Comment 17 Fedora Update System 2017-09-19 21:21:54 EDT
cloud-init-0.7.9-9.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-5507234819

Note You need to log in before you can comment on or make changes to this bug.