Merge ~smoser/cloud-init:bug/1724354-debug-only-on-missing-json-schema into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: 24afb7d32ba3deb4097f8812122b5a7bf6279806
Merged at revision: 41152f10ddbd8681cdac44b408038a4f23ab02df
Proposed branch: ~smoser/cloud-init:bug/1724354-debug-only-on-missing-json-schema
Merge into: cloud-init:master
Diff against target: 150 lines (+32/-9)
8 files modified
cloudinit/config/cc_users_groups.py (+2/-1)
cloudinit/config/schema.py (+1/-1)
doc/examples/cloud-config-user-groups.txt (+3/-3)
tests/cloud_tests/testcases/base.py (+4/-0)
tests/cloud_tests/testcases/examples/including_user_groups.py (+6/-0)
tests/cloud_tests/testcases/examples/including_user_groups.yaml (+5/-2)
tests/cloud_tests/testcases/modules/user_groups.py (+6/-0)
tests/cloud_tests/testcases/modules/user_groups.yaml (+5/-2)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+332383@code.launchpad.net

Commit message

schema: Log debug instead of warning when jsonschema is not available.

When operating in expected path, cloud-init should avoid logging with
warning. That causes 'WARNING' messages in /var/log/cloud-init.log.
By default, warnings also go to the console.

Since jsonschema is a optional dependency, and not present on xenial
and zesty, cloud-init should not warn there.

Also here:
* Add a test to integration tests to assert that there are no
  warnings in /var/log/cloud-init.log.
* Update one integration test that did show warning and the related
  documentation and examples.

LP: #1724354

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:526ae49fa43ba0528ce4ffc30cfa56a1fe433221
https://jenkins.ubuntu.com/server/job/cloud-init-ci/402/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

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

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

FAILED: Continuous integration, rev:1dc8e693e88f31913e27bee780dc1bbee11f652d
https://jenkins.ubuntu.com/server/job/cloud-init-ci/403/
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/403/rebuild

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

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

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

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

FAILED: Continuous integration, rev:bc70e1578b9adcfd739342a2e6f3bf8d38ac26a5
https://jenkins.ubuntu.com/server/job/cloud-init-ci/405/
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/405/rebuild

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

FAILED: Continuous integration, rev:9a07f80e8e61c1d4d1ce4991e0a791c7ecf9fa35
https://jenkins.ubuntu.com/server/job/cloud-init-ci/406/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    FAILED: MAAS Compatability Testing

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

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

FAILED: Continuous integration, rev:24afb7d32ba3deb4097f8812122b5a7bf6279806
https://jenkins.ubuntu.com/server/job/cloud-init-ci/407/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    FAILED: MAAS Compatability Testing

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Once CI passes on this I'm good.

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

PASSED: Continuous integration, rev:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/408/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

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

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Ran tox locally and all good here. Looks like remote service timeouts for centos/yum etc as the failing points on CI tests. unrelated to this changeset.

  py27: commands succeeded
  py3: commands succeeded
  flake8: commands succeeded
  xenial: commands succeeded
  pylint: commands succeeded
  congratulations :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py
2index b80d1d3..f363000 100644
3--- a/cloudinit/config/cc_users_groups.py
4+++ b/cloudinit/config/cc_users_groups.py
5@@ -15,7 +15,8 @@ options, see the ``Including users and groups`` config example.
6 Groups to add to the system can be specified as a list under the ``groups``
7 key. Each entry in the list should either contain a the group name as a string,
8 or a dictionary with the group name as the key and a list of users who should
9-be members of the group as the value.
10+be members of the group as the value. **Note**: Groups are added before users,
11+so any users in a group list must already exist on the system.
12
13 The ``users`` config key takes a list of users to configure. The first entry in
14 this list is used as the default user for the system. To preserve the standard
15diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py
16index bb291ff..ca7d0d5 100644
17--- a/cloudinit/config/schema.py
18+++ b/cloudinit/config/schema.py
19@@ -74,7 +74,7 @@ def validate_cloudconfig_schema(config, schema, strict=False):
20 try:
21 from jsonschema import Draft4Validator, FormatChecker
22 except ImportError:
23- logging.warning(
24+ logging.debug(
25 'Ignoring schema validation. python-jsonschema is not present')
26 return
27 validator = Draft4Validator(schema, format_checker=FormatChecker())
28diff --git a/doc/examples/cloud-config-user-groups.txt b/doc/examples/cloud-config-user-groups.txt
29index 9c5202f..0554d1f 100644
30--- a/doc/examples/cloud-config-user-groups.txt
31+++ b/doc/examples/cloud-config-user-groups.txt
32@@ -1,8 +1,8 @@
33 # Add groups to the system
34-# The following example adds the ubuntu group with members foo and bar and
35-# the group cloud-users.
36+# The following example adds the ubuntu group with members 'root' and 'sys'
37+# and the empty group cloud-users.
38 groups:
39- - ubuntu: [foo,bar]
40+ - ubuntu: [root,sys]
41 - cloud-users
42
43 # Add users to the system. Users are added after groups are added.
44diff --git a/tests/cloud_tests/testcases/base.py b/tests/cloud_tests/testcases/base.py
45index bb545ab..b2b5b4b 100644
46--- a/tests/cloud_tests/testcases/base.py
47+++ b/tests/cloud_tests/testcases/base.py
48@@ -72,6 +72,10 @@ class CloudTestCase(unittest.TestCase):
49 result = self.get_status_data(self.get_data_file('result.json'))
50 self.assertEqual(len(result['errors']), 0)
51
52+ def test_no_warnings_in_log(self):
53+ """Warnings should not be found in the log."""
54+ self.assertNotIn("WARN", self.get_data_file('cloud-init.log'))
55+
56
57 class PasswordListTest(CloudTestCase):
58 """Base password test case class."""
59diff --git a/tests/cloud_tests/testcases/examples/including_user_groups.py b/tests/cloud_tests/testcases/examples/including_user_groups.py
60index 67af527..93b7a82 100644
61--- a/tests/cloud_tests/testcases/examples/including_user_groups.py
62+++ b/tests/cloud_tests/testcases/examples/including_user_groups.py
63@@ -40,4 +40,10 @@ class TestUserGroups(base.CloudTestCase):
64 out = self.get_data_file('user_cloudy')
65 self.assertRegex(out, r'cloudy:x:[0-9]{3,4}:')
66
67+ def test_user_root_in_secret(self):
68+ """Test root user is in 'secret' group."""
69+ user, _, groups = self.get_data_file('root_groups').partition(":")
70+ self.assertIn("secret", groups.split(),
71+ msg="User root is not in group 'secret'")
72+
73 # vi: ts=4 expandtab
74diff --git a/tests/cloud_tests/testcases/examples/including_user_groups.yaml b/tests/cloud_tests/testcases/examples/including_user_groups.yaml
75index 0aa7ad2..469d03c 100644
76--- a/tests/cloud_tests/testcases/examples/including_user_groups.yaml
77+++ b/tests/cloud_tests/testcases/examples/including_user_groups.yaml
78@@ -8,7 +8,7 @@ cloud_config: |
79 #cloud-config
80 # Add groups to the system
81 groups:
82- - secret: [foobar,barfoo]
83+ - secret: [root]
84 - cloud-users
85
86 # Add users to the system. Users are added after groups are added.
87@@ -24,7 +24,7 @@ cloud_config: |
88 - name: barfoo
89 gecos: Bar B. Foo
90 sudo: ALL=(ALL) NOPASSWD:ALL
91- groups: cloud-users
92+ groups: [cloud-users, secret]
93 lock_passwd: true
94 - name: cloudy
95 gecos: Magic Cloud App Daemon User
96@@ -49,5 +49,8 @@ collect_scripts:
97 user_cloudy: |
98 #!/bin/bash
99 getent passwd cloudy
100+ root_groups: |
101+ #!/bin/bash
102+ groups root
103
104 # vi: ts=4 expandtab
105diff --git a/tests/cloud_tests/testcases/modules/user_groups.py b/tests/cloud_tests/testcases/modules/user_groups.py
106index 67af527..93b7a82 100644
107--- a/tests/cloud_tests/testcases/modules/user_groups.py
108+++ b/tests/cloud_tests/testcases/modules/user_groups.py
109@@ -40,4 +40,10 @@ class TestUserGroups(base.CloudTestCase):
110 out = self.get_data_file('user_cloudy')
111 self.assertRegex(out, r'cloudy:x:[0-9]{3,4}:')
112
113+ def test_user_root_in_secret(self):
114+ """Test root user is in 'secret' group."""
115+ user, _, groups = self.get_data_file('root_groups').partition(":")
116+ self.assertIn("secret", groups.split(),
117+ msg="User root is not in group 'secret'")
118+
119 # vi: ts=4 expandtab
120diff --git a/tests/cloud_tests/testcases/modules/user_groups.yaml b/tests/cloud_tests/testcases/modules/user_groups.yaml
121index 71cc9da..22b5d70 100644
122--- a/tests/cloud_tests/testcases/modules/user_groups.yaml
123+++ b/tests/cloud_tests/testcases/modules/user_groups.yaml
124@@ -7,7 +7,7 @@ cloud_config: |
125 #cloud-config
126 # Add groups to the system
127 groups:
128- - secret: [foobar,barfoo]
129+ - secret: [root]
130 - cloud-users
131
132 # Add users to the system. Users are added after groups are added.
133@@ -23,7 +23,7 @@ cloud_config: |
134 - name: barfoo
135 gecos: Bar B. Foo
136 sudo: ALL=(ALL) NOPASSWD:ALL
137- groups: cloud-users
138+ groups: [cloud-users, secret]
139 lock_passwd: true
140 - name: cloudy
141 gecos: Magic Cloud App Daemon User
142@@ -48,5 +48,8 @@ collect_scripts:
143 user_cloudy: |
144 #!/bin/bash
145 getent passwd cloudy
146+ root_groups: |
147+ #!/bin/bash
148+ groups root
149
150 # vi: ts=4 expandtab

Subscribers

People subscribed via source and target branches