summaryrefslogtreecommitdiff
path: root/cloudinit/analyze
Commit message (Collapse)AuthorAgeFilesLines
* Remove dead code (#2038)Brett Holman2023-03-031-15/+0
|
* analyze: use init-local as start of boot record (#1767)Chris Patterson2022-10-041-4/+1
| | | | | | | | When using the Azure data source, frames are not guaranteed to be unique to each boot. Instead of splitting boot records when any event is seen more than once, do so whenever the start of `init-local` stage is found (and records have already been processed). Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
* style: prefer absolute imports over relative importsMina Galić2022-09-301-2/+1
| | | Sponsored by: FreeBSD Foundation
* Refactor: Drop inheritance from object (#1728)Alberto Contreras2022-09-141-1/+1
| | | As we do not support python2 anymore, we can remove those 8 chars.
* Resource leak cleanup (#1556)Brett Holman2022-07-131-0/+13
| | | Add tox target for tracing for resource leaks, fix some leaks
* Remove xenial references (#1472)Alberto Contreras2022-06-081-18/+13
| | | | | | - Remove references and dead code to Xenial, Eoan, Python < 3.7 - cc_ubuntu_drivers: Use python3-debconf instead of shell script - add integration test for ubuntu_drivers - bump pycloudlib for OCI subnet/jammy fixes
* upstart: drop vestigial support for upstart (#1421)Chad Smith2022-05-091-1/+1
| | | | | | | | | | | | | | | | upstream cloud-init not longer publishes to distribution versions which support upstart. Trusty has not been receiving cloud-init updates since 0.7.5 and Xenial stopped getting updates as version 21.1. Even though Ubuntu Xenial's default init system is systemd there was still an option for folks to launch amd maintain images which relied on upstart. Now that Xenial no longer has updates from upstream cloud-init we can drop all upstart support. Old Fedora and RHEL releases which use upstart are also not receiving cloud-init updates from tip of main.
* Stop hardcoding systemctl location (#1278)Robert Schweikert2022-03-011-1/+1
| | | | | Expect that "systemctl" is found in the PATH. Using the '/bin' prefix is very distribution specific. A number of distributions are moving all executables from '/' to '/usr'.
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-153-230/+302
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* Reorganize unit test locations under tests/unittests (#1126)Brett Holman2021-12-032-369/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This attempts to standardize unit test file location under test/unittests/ such that any source file located at cloudinit/path/to/file.py may have a corresponding unit test file at test/unittests/path/to/test_file.py. Noteworthy Comments: ==================== Four different duplicate test files existed: test_{gpg,util,cc_mounts,cc_resolv_conf}.py Each of these duplicate file pairs has been merged together. This is a break in git history for these files. The test suite appears to have a dependency on test order. Changing test order causes some tests to fail. This should be rectified, but for now some tests have been modified in tests/unittests/config/test_set_passwords.py. A helper class name starts with "Test" which causes pytest to try executing it as a test case, which then throws warnings "due to Class having __init__()". Silence by changing the name of the class. # helpers.py is imported in many test files, import paths change cloudinit/tests/helpers.py -> tests/unittests/helpers.py # Move directories: cloudinit/distros/tests -> tests/unittests/distros cloudinit/cmd/devel/tests -> tests/unittests/cmd/devel cloudinit/cmd/tests -> tests/unittests/cmd/ cloudinit/sources/helpers/tests -> tests/unittests/sources/helpers cloudinit/sources/tests -> tests/unittests/sources cloudinit/net/tests -> tests/unittests/net cloudinit/config/tests -> tests/unittests/config cloudinit/analyze/tests/ -> tests/unittests/analyze/ # Standardize tests already in tests/unittests/ test_datasource -> sources test_distros -> distros test_vmware -> sources/vmware test_handler -> config # this contains cloudconfig module tests test_runs -> runs
* testing: monkeypatch system_info call in unit tests (SC-533) (#1117)James Falcon2021-11-221-11/+2
| | | | | | | | | | | | | | testing: monkeypatch system_info call in unit tests system_info can make calls that read or write from the filesystem, which should require special mocking. It is also decorated with 'lru_cache', which means test authors often don't realize they need to be mocking. Also, we don't actually want the results from the user's local machine, so monkeypatching it across all tests should be reasonable. Additionally, moved some of 'system_info` into a helper function to reduce the surface area of the monkeypatch, added tests for the new function (and fixed a bug as a result), and removed related mocks that should be no longer needed.
* tox: bump the pylint version to 2.6.0 in the default run (#544)Paride Legovini2020-08-251-1/+1
| | | | | | Changes: tox: bump the pylint version to 2.6.0 in the default run Fix pylint 2.6.0 W0707 warnings (raise-missing-from)
* cloudinit: remove global disable of pylint W0105 and fix errors (#480)Daniel Watkins2020-07-131-22/+19
| | | | This includes a fix to a test that had a string concatenation issue, and so was only testing a prefix of what was intended.
* Move subp into its own module. (#416)Scott Moser2020-06-084-12/+15
| | | | | | | | | | | | | | | | | This was painful, but it finishes a TODO from cloudinit/subp.py. It moves the following from util to subp: ProcessExecutionError subp which target_path I moved subp_blob_in_tempfile into cc_chef, which is its only caller. That saved us from having to deal with it using write_file and temp_utils from subp (which does not import any cloudinit things now). It is arguable that 'target_path' could be moved to a 'path_utils' or something, but in order to use it from subp and also from utils, we had to get it out of utils.
* analyze/dump: refactor shared string into variable (#350)Daniel Watkins2020-05-111-2/+3
|
* analyze/dump: add support for Amazon Linux 2 log lines (#346)Daniel Watkins2020-05-062-2/+29
| | | | | | | Amazon Linux 2 is configured with a log format different to the one shipped by upstream, which means analyze fails to parse any of the log lines. This updates the code to know how to parse such lines. LP: #1876323
* Make tests work with Python 3.8 (#139)Conrad Hoffmann2020-01-081-4/+4
| | | | | | | | | | | | | | | | | | | | | * Make DistroChecker test work with Python 3.8 In Python 3.8, `platform.linux_distribution` has been removed. This was anticipated, and the cloud-init code uses its own `util.get_linux_distro` instead, which works fine w/o `platform.linux_distribution`. However, these tests still try to mock the platform function, which fails if it doesn't exist (Python 3.8). Instead, mock the new function here, as this is a test for code that depends on it rather than the function itself. * Make GetLinuxDistro tests work with Python 3.8 In Python 3.8, `platform.dist` was removed, so allow mock to create the function by setting `create=True`. * Make linter happy in Python 3.8 Suppress E1101(no-member) as this function was removed.
* analyze/show: remove trailing space in outputDaniel Watkins2019-09-251-1/+1
|
* Cloud-init analyze module: Added ability to analyze boot events.Sam Gilson2019-07-153-12/+448
| | | | | | | | | | | | | | | This branch introduces a new command line feature for cloud-init. Currently, the cloud-init module has the capability to analyze events in cloud-init.log in three ways: 'show', 'blame', 'dump'. These changes add a fourth capability, called 'boot'. Running the command 'cloud-init analyze boot' will provide the user three timestamps. 1) Timestamp for when the kernel starts initializing. 2) Timestamp for when the kernel finishes its initialization. 3) Timestamp for when systemd activates cloud-init. This feature enables cloud-init users to analyze different boot phases. This would aid in debugging performance issues related to cloud-init startup or tracking regression.
* tests: Disallow use of util.subp except for where needed.Scott Moser2018-09-051-53/+33
| | | | | | | | | | | | | | | | | | In many cases, cloud-init uses 'util.subp' to run a subprocess. This is not really desirable in our unit tests as it makes the tests dependent upon existance of those utilities. The change here is to modify the base test case class (CiTestCase) to raise exception any time subp is called. Then, fix all callers. For cases where subp is necessary or actually desired, we can use it via   a.) context hander CiTestCase.allow_subp(value)   b.) class level self.allowed_subp = value Both cases the value is a list of acceptable executable names that will be called (essentially argv[0]). Some cleanups in AltCloud were done as the code was being updated.
* pylint: pay attention to unused variable warnings.Scott Moser2018-04-191-1/+1
| | | | | This enables warnings produced by pylint for unused variables (W0612), and fixes the existing errors.
* pycodestyle: Fix invalid escape sequences in string literals.Scott Moser2018-04-181-1/+1
| | | | | | | | | | | | | Python has deprecated these invalid string literals now https://bugs.python.org/issue27364 and pycodestyle is identifying them with a W605 warning. https://github.com/PyCQA/pycodestyle/pull/676 So basically, any use of \ not followed by one of [\'"abfnrtv] or \ooo (octal) \xhh (hex) or a newline is invalid. This is most comomnly seen for us in regex. To solve, you either: a.) use a raw string r'...' b.) correctly escape the \ that was not intended to be interpreted.
* Datasources: Formalize DataSource get_data and related properties.Chad Smith2017-12-052-8/+4
| | | | | | | | | | | | | | | | | | | | | Each DataSource subclass must define its own get_data method. This branch formalizes our DataSource class to require that subclasses define an explicit dsname for sourcing cloud-config datasource configuration. Subclasses must also override the _get_data method or a NotImplementedError is raised. The branch also writes /run/cloud-init/instance-data.json. This file contains all meta-data, user-data and vendor-data and a standardized set of metadata keys in a json blob which other utilities with root-access could make use of. Because some meta-data or user-data is potentially sensitive the file is only readable by root. Generally most metadata content types should be json serializable. If specific keys or values are not serializable, those specific values will be base64encoded and the key path will be listed under the top-level key 'base64-encoded-keys' in instance-data.json. If json writing fails due to other TypeErrors or UnicodeDecodeErrors, a warning log will be emitted to /var/log/cloud-init.log and no instance-data.json will be created.
* relocate tests/unittests/helpers.py to cloudinit/testsLars Kellogg-Stedman2017-09-051-1/+1
| | | | | This moves the base test case classes into into cloudinit/tests and updates all the corresponding imports.
* cloud-init analyze: fix issues running under python 2.Andrew Jorgensen2017-08-252-3/+3
| | | | | | Some Python 3 exception names crept into the cloud-init analyze code. This patches those back out at a cost of catching less specific parents of the desired exceptions.
* tools: Add tooling for basic cloud-init performance analysis.Chad Smith2017-08-215-0/+748
This branch adds cloudinit-analyze into cloud-init proper. It adds an "analyze" subcommand to the cloud-init command line utility for quick performance assessment of cloud-init stages and events. On a cloud-init configured instance, running "cloud-init analyze blame" will now report which cloud-init events cost the most wall time. This allows for quick assessment of the most costly stages of cloud-init. This functionality is pulled from Ryan Harper's analyze work. The cloudinit-analyze main script itself has been refactored a bit for inclusion as a subcommand of cloud-init CLI. There will be a followup branch at some point which will optionally instrument detailed strace profiling, but that approach needs a bit more discussion first. This branch also adds: * additional debugging topic to the sphinx-generated docs describing cloud-init analyze, dump and show as well as cloud-init single usage. * Updates the Makefile unittests target to include cloudinit directory because we now have unittests within that package. LP: #1709761