Merge ~harlowja/cloud-init:no-cheetah into cloud-init:master

Proposed by Joshua Harlow
Status: Work in progress
Proposed branch: ~harlowja/cloud-init:no-cheetah
Merge into: cloud-init:master
Diff against target: 62 lines (+11/-12)
2 files modified
cloudinit/templater.py (+11/-9)
setup.py (+0/-3)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing
Scott Moser Disapprove
Review via email: mp+308304@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

I think I'm OK with this. The big thing really is external users. But anyone using Python 3 has already moved.

Can you verify that there is no actual runtime change if cheetah is available (or on an existing distribution)

Revision history for this message
Scott Moser (smoser) wrote :

per Josh in irc:

so in [1] if people still have cheetah installed, and there templates say to use cheetah explicitly then it will still continue using cheetah the default though does change from:
  - LOG.debug("Using Cheetah as the renderer for unknown template.")
  - return ('cheetah', cheetah_render, text)
to jinja this maybe should cause a 0.8.0 version, idk
--
[1] https://code.launchpad.net/~harlowja/cloud-init/+git/cloud-init/+merge/308304

Revision history for this message
Joshua Harlow (harlowja) wrote :

Ya, this changes the default away from cheetah; might be smart to bump some version number to denote this (just incase).

Revision history for this message
Scott Moser (smoser) wrote :

one thing we could do that would guarantee backwards compatibility would be to switch to jinja as default/unknown for python3 only, and still use cheetah for unknown in python2.

Revision history for this message
Joshua Harlow (harlowja) wrote :

that could be a solution; i'd be ok with that, other option is to release cloud-init 1.0 and switch it then.

Revision history for this message
Scott Moser (smoser) wrote :

I think that we should probably just leave this as it is.
I dont want to change the 'unknown' renderer to jinja. i'd prefer that be basic.

and in python3, since cheetah will never be available we have unknown -> basic.

The one change i think is valid is that its probably better to raise the exception on explicit 'jinja' request when jina isnot available then try to render it with the basic renderer which isnt even close.

review: Disapprove
Revision history for this message
Scott Moser (smoser) wrote :

Just to summarize. I'm going to leave this as 'Disapprove'.
Things we could do here:
 * use the TemplaterNotFound(Exception) when the format is known and there is no renderer available (such as jinja content without jinja).
 * explicitly make the renderer of unknown be 'builtin' if python3 (rather than implicitly getting that affect by the fallback since there will not be cheetah on python3).

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

Moving this to work-in-progress, feel free to move back to needs review if changes are made.

Unmerged commits

31b3af8... by Joshua Harlow

Cheetah shouldn't actually be needed anymore

All things should now be in jinja2 format (at
least when bundled in cloud-init) so there should
be no more need for a mandatory include of cheetah
on python 2.x

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/templater.py b/cloudinit/templater.py
2index 41ef27e..2adaa42 100644
3--- a/cloudinit/templater.py
4+++ b/cloudinit/templater.py
5@@ -47,6 +47,10 @@ TYPE_MATCHER = re.compile(r"##\s*template:(.*)", re.I)
6 BASIC_MATCHER = re.compile(r'\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+)')
7
8
9+class TemplaterNotFound(Exception):
10+ """Exception raised when explict templater requested, but not found."""
11+
12+
13 def basic_render(content, params):
14 """This does simple replacement of bash variable like templates.
15
16@@ -104,9 +108,9 @@ def detect_template(text):
17 rest = ''
18 type_match = TYPE_MATCHER.match(ident)
19 if not type_match:
20- if CHEETAH_AVAILABLE:
21- LOG.debug("Using Cheetah as the renderer for unknown template.")
22- return ('cheetah', cheetah_render, text)
23+ if JINJA_AVAILABLE:
24+ LOG.debug("Using jinja as the renderer for unknown template.")
25+ return ('jinja', jinja_render, text)
26 else:
27 return ('basic', basic_render, text)
28 else:
29@@ -115,15 +119,13 @@ def detect_template(text):
30 raise ValueError("Unknown template rendering type '%s' requested"
31 % template_type)
32 if template_type == 'jinja' and not JINJA_AVAILABLE:
33- LOG.warn("Jinja not available as the selected renderer for"
34- " desired template, reverting to the basic renderer.")
35- return ('basic', basic_render, rest)
36+ raise TemplaterNotFound("Jinja not available as the selected"
37+ " renderer for desired template")
38 elif template_type == 'jinja' and JINJA_AVAILABLE:
39 return ('jinja', jinja_render, rest)
40 if template_type == 'cheetah' and not CHEETAH_AVAILABLE:
41- LOG.warn("Cheetah not available as the selected renderer for"
42- " desired template, reverting to the basic renderer.")
43- return ('basic', basic_render, rest)
44+ raise TemplaterNotFound("Cheetah not available as the selected"
45+ " renderer for desired template")
46 elif template_type == 'cheetah' and CHEETAH_AVAILABLE:
47 return ('cheetah', cheetah_render, rest)
48 # Only thing left over is the basic renderer (it is always available).
49diff --git a/setup.py b/setup.py
50index 8ff667d..d190696 100755
51--- a/setup.py
52+++ b/setup.py
53@@ -197,9 +197,6 @@ else:
54
55
56 requirements = read_requires()
57-if sys.version_info < (3,):
58- requirements.append('cheetah')
59-
60 setuptools.setup(
61 name='cloud-init',
62 version=get_version(),

Subscribers

People subscribed via source and target branches