Merge ~mb-methot/cloud-init:bug/1699282 into cloud-init:master

Proposed by Marc Methot
Status: Work in progress
Proposed branch: ~mb-methot/cloud-init:bug/1699282
Merge into: cloud-init:master
Diff against target: 22 lines (+2/-2)
1 file modified
cloudinit/helpers.py (+2/-2)
Reviewer Review Type Date Requested Status
Scott Moser Needs Fixing
Server Team CI bot continuous-integration Approve
Review via email: mp+326017@code.launchpad.net

Commit message

fix puppet module when run under python 2.

six.StringIO in python2 cannot be used in a context guard.
The solution here is to ........

Description of the change

This is intended to fix the issue faced in bug/1699282.
This was a redhat director/tripleo newton deployment.

Tested this fix successfully, also with newer versions.

To post a comment you must log in.
~mb-methot/cloud-init:bug/1699282 updated
a3640c3... by Marc Methot <email address hidden>

bug/1699282

708fed5... by Marc Methot <email address hidden>

Python compatibility issue fix

six.StringIO is not in python2. This fixes that issue by replacing
it with io.BytesIO

LP: #1699282

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:a3640c33fc2628864e96f6038798deed9f7898b5
https://jenkins.ubuntu.com/server/job/cloud-init-ci/3/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/3/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:a3640c33fc2628864e96f6038798deed9f7898b5
https://jenkins.ubuntu.com/server/job/cloud-init-ci/4/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/4/rebuild

review: Approve (continuous-integration)
Revision history for this message
Joshua Powers (powersj) wrote :

Hi Marc

Based on a quick look, it appears that in Python3 six.StringIO exists, but not in Python2. As you have corrected, io.BytesIO exists in both. Also CI looks good.

Can I get you to do the following:

1. Set a commit message with a few details:
  Summary
  <blank line>
  More information
  ...
  <blank line>
  LP: #1699282

This will link the bug as well.

2. If you have not already, sign the contributor agreement as described in HACKING.rst.

When Scott, Ryan, or Chad are around they can give it a look as well.

Revision history for this message
Marc Methot (mb-methot) wrote :

Hello,

Thank you, will do all that shortly.
Was in an exceeding rush this morning.

Cheers,
MM

~mb-methot/cloud-init:bug/1699282 updated
99c39f8... by Marc Methot <email address hidden>

Merge branch 'bug/1699282' of ssh://git.launchpad.net/~mb-methot/cloud-init into bug/1699282

Revision history for this message
Marc Methot (mb-methot) wrote :

Well I tried something, not sure if my amend didnt just change more than the commit message.
https://git.launchpad.net/~mb-methot/cloud-init/commit/?id=708fed571654baa10eb11c47dd1ba10db0c0a346

Also signed the agreement.

Let me know if you guys need more.

Cheers,
MM

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:99c39f86596b0c5fc494517061d08e6d09d16ae2
https://jenkins.ubuntu.com/server/job/cloud-init-ci/5/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    FAILED: Ubuntu LTS: Integration

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/5/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:99c39f86596b0c5fc494517061d08e6d09d16ae2
https://jenkins.ubuntu.com/server/job/cloud-init-ci/6/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/6/rebuild

review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Hi,
Thanks for the bug fix.

I've added 2 simple unit tests that show failure in python2 before your fix but show failure in python3 after your fix.

http://paste.ubuntu.com/25069502/

So, please integrate these tests and make it work in both python2 (tox -e py27) and python3 (tox -e py3).

Lastly, i've set a 'Commit Message' above. Please update it with your solution in the end.

When you've done this go ahead and move the merge proposal out of 'work in progress' to 'needs review'

And again, Thanks for your contribution.
Scott

review: Needs Fixing

Unmerged commits

99c39f8... by Marc Methot <email address hidden>

Merge branch 'bug/1699282' of ssh://git.launchpad.net/~mb-methot/cloud-init into bug/1699282

708fed5... by Marc Methot <email address hidden>

Python compatibility issue fix

six.StringIO is not in python2. This fixes that issue by replacing
it with io.BytesIO

LP: #1699282

a3640c3... by Marc Methot <email address hidden>

bug/1699282

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
2index f01021a..9159c57 100644
3--- a/cloudinit/helpers.py
4+++ b/cloudinit/helpers.py
5@@ -13,7 +13,7 @@ from time import time
6 import contextlib
7 import os
8
9-import six
10+import io
11 from six.moves.configparser import (
12 NoSectionError, NoOptionError, RawConfigParser)
13
14@@ -441,7 +441,7 @@ class DefaultingConfigParser(RawConfigParser):
15
16 def stringify(self, header=None):
17 contents = ''
18- with six.StringIO() as outputstream:
19+ with io.BytesIO() as outputstream:
20 self.write(outputstream)
21 outputstream.flush()
22 contents = outputstream.getvalue()

Subscribers

People subscribed via source and target branches