Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudinit/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

def version_string():
"""Extract a version string from cloud-init."""
if _DOWNSTREAM_VERSION != "@DOWNSTREAM_VERSION@":
if "DOWNSTREAM_VERSION" not in _DOWNSTREAM_VERSION:
return _DOWNSTREAM_VERSION
return __VERSION__
12 changes: 6 additions & 6 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
cloud-init (25.3-0ubuntu1~24.04.2) UNRELEASED; urgency=medium

* d/rules: replace DOWNSTREAM_VERSION with packaged DEB_VERSION value
* d/p/0001-Revert-fix-DNS-resolution-performance-regression-dur.patch revert Ec2 URL change
* d/p/0001-Revert-fix-support-bond-names-in-network_data.patch revert bond name change
* refresh patches:
- d/p/no-nocloud-network.patch
- d/p/no-single-process.patch
- d/p/grub-dpkg-support.patch
- d/p/retain-setuptools.patch. Include read-version, drop unsupported dev
- d/p/retain-setuptools.patch. Use PACKAGED_VERSION environment variable.
build tools and tests.
* d/p/0001-Revert-fix-DNS-resolution-performance-regression-dur.patch revert Ec2 URL change
* d/p/0001-Revert-fix-support-bond-names-in-network_data.patch revert bond name change
* d/rules: replace DOWNSTREAM_VERSION with packaged DEB_VERSION value
* Upstream snapshot based on upstream/main at 72809f80.
* Upstream snapshot based on upstream/main at 090026a3.

-- Brett Holman <brett.holman@canonical.com> Thu, 05 Feb 2026 16:23:52 +0000
-- Chad Smith <chad.smith@canonical.com> Sat, 07 Feb 2026 15:43:23 -0700

cloud-init (25.3-0ubuntu1~24.04.1) noble; urgency=medium

Expand Down
165 changes: 4 additions & 161 deletions debian/patches/retain-setuptools.patch
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Last-Update: 2025-08-25
+)
--- /dev/null
+++ b/setup_utils.py
@@ -0,0 +1,60 @@
@@ -0,0 +1,59 @@
+import os
+import subprocess
+import sys
Expand Down Expand Up @@ -411,13 +411,12 @@ Last-Update: 2025-08-25
+ # read-version can spit out something like 22.4-15-g7f97aee24
+ # which is invalid under PEP 440. If we replace the first - with a +
+ # that should give us a valid version.
+ return version.replace("-", "+", 1)
+ return version.strip("_").split("-")[0]
+
+
+def get_version() -> str:
+ cmd = [sys.executable, "tools/read-version"]
+ ver = subprocess.check_output(cmd) # B603
+ version = ver.decode("utf-8").strip()
+ ver = os.environ.get("PACKAGED_VERSION", "MISSING_ENVVAR_PACKAGED_VERSION")
+ version = ver.strip()
+ return version_to_pep440(version)
+
+
Expand All @@ -438,159 +437,3 @@ Last-Update: 2025-08-25
passlib

# This one is currently used only by the CloudSigma and SmartOS datasources.
--- /dev/null
+++ b/tools/read-version
@@ -0,0 +1,153 @@
+#!/usr/bin/env python3
+
+# This script has tests. Run pytest on the tools directory if you make changes
+
+import json
+import os
+import re
+import subprocess
+import sys
+from shutil import which
+
+repo_base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+sys.path.insert(0, repo_base_dir)
+
+from cloudinit import version as ci_version # noqa: E402
+
+
+def tiny_p(cmd):
+ stderr = subprocess.PIPE
+ return subprocess.check_output(
+ cmd, stderr=stderr, stdin=None, universal_newlines=True
+ )
+
+
+def is_gitdir(path):
+ # Return boolean indicating if path is a git tree.
+ git_meta = os.path.join(path, ".git")
+ if os.path.isdir(git_meta):
+ return True
+ if os.path.exists(git_meta):
+ # in a git worktree, .git is a file with 'gitdir: x'
+ with open(git_meta, "rb") as fp:
+ if b"gitdir:" in fp.read():
+ return True
+ return False
+
+
+def get_version_details(version, version_long, is_release_branch_ci):
+ release = None
+ extra = None
+ commit = None
+ distance = None
+
+ # Should match upstream version number. E.g., 23.1 or 23.1.2
+ short_regex = r"(\d+\.\d+\.?\d*)"
+ # Should match version including upstream version, distance, and commit
+ # E.g., 23.1.2-10-g12ab34cd
+ long_regex = r"(\d+\.\d+\.?\d*){1}.*-(\d+)+-g([a-f0-9]{8}){1}.*"
+
+ short_match = re.search(short_regex, version)
+ long_match = re.search(long_regex, version_long)
+ if long_match:
+ release, distance, commit = long_match.groups()
+ extra = f"-{distance}-g{commit}"
+ elif short_match:
+ release = short_match.groups()[0]
+
+ return {
+ "release": release,
+ "version": version,
+ "version_long": version_long,
+ "extra": extra,
+ "commit": commit,
+ "distance": distance,
+ "is_release_branch_ci": is_release_branch_ci,
+ }
+
+
+def get_version_from_git(
+ src_version, major_minor_version, use_tags, is_release_branch_ci
+):
+ if is_gitdir(repo_base_dir) and which("git") and not is_release_branch_ci:
+ branch_name = tiny_p(
+ ["git", "rev-parse", "--abbrev-ref", "HEAD"]
+ ).strip()
+ if branch_name.startswith(f"upstream/{major_minor_version}"):
+ version = src_version
+ version_long = ""
+ else:
+ flags = ["--tags"] if use_tags else []
+ cmd = [
+ "git",
+ "describe",
+ branch_name,
+ "--abbrev=8",
+ ] + flags
+
+ try:
+ version = tiny_p(cmd).strip()
+ version_long = tiny_p(cmd + ["--long"]).strip()
+ except subprocess.CalledProcessError as e:
+ if not any(
+ [
+ "No tags can describe" in e.stderr,
+ "cannot describe anything" in e.stderr,
+ ]
+ ):
+ raise
+ version = src_version
+ version_long = ""
+ else:
+ version = src_version
+ version_long = ""
+ return version, version_long
+
+
+def main(use_tags: bool = False, output_json: bool = False):
+ src_version = ci_version.version_string()
+ # upstream/MM.NN.x tracks our patch level releases so ignore trailing '.x'
+ major_minor_version = ".".join(src_version.split(".")[:2])
+
+ # If we're performing CI for a new release branch (which our tooling
+ # creates with an "upstream/" prefix), then we don't want to enforce
+ # strict version matching because we know it will fail.
+ github_ci_release_br = bool(
+ os.environ.get("GITHUB_HEAD_REF", "").startswith(
+ f"upstream/{major_minor_version}"
+ )
+ )
+ travis_ci_release_br = bool(
+ os.environ.get("TRAVIS_PULL_REQUEST_BRANCH", "").startswith(
+ "upstream/"
+ )
+ )
+ is_release_branch_ci = github_ci_release_br or travis_ci_release_br
+
+ version, version_long = get_version_from_git(
+ src_version=src_version,
+ major_minor_version=major_minor_version,
+ use_tags=use_tags,
+ is_release_branch_ci=is_release_branch_ci,
+ )
+
+ details = get_version_details(version, version_long, is_release_branch_ci)
+
+ if output_json:
+ return json.dumps(details, indent=1)
+
+ output = ""
+ if details["release"]:
+ output += details["release"]
+ if details["extra"]:
+ output += details["extra"]
+ if not output:
+ output = src_version
+ return output
+
+
+if __name__ == "__main__":
+ arg_use_tags = "--tags" in sys.argv or bool(os.environ.get("CI_RV_TAGS"))
+ arg_output_json = "--json" in sys.argv
+ output = main(arg_use_tags, arg_output_json)
+ print(output)
1 change: 1 addition & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include /usr/share/dpkg/pkg-info.mk

INIT_SYSTEM ?= systemd
export PYBUILD_INSTALL_ARGS=--init-system=$(INIT_SYSTEM)
export PACKAGED_VERSION=$(DEB_VERSION)

%:
dh $@ --with python3 --buildsystem pybuild
Expand Down
5 changes: 0 additions & 5 deletions doc/man/cloud-id.1
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ Report all standardized cloud-id information as json
.B "-l, --long"
Report extended cloud-id information as tab-delimited string

.TP
.BR "-i <data>, --instance-data <data>"
Path to instance-data.json file. Default is
/run/cloud-init/instance-data.json

.SH EXIT STATUS
.TP
0
Expand Down
19 changes: 17 additions & 2 deletions doc/rtd/development/internal_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ unexpected cloud-init failures.

.. _data_files:

Data files
==========
/var/
=====

Inside the :file:`/var/lib/cloud/` directory there are two important
subdirectories:
Expand Down Expand Up @@ -44,3 +44,18 @@ previous boot:
* :file:`status.json`:
JSON file showing the datasource used, a breakdown of all four stages,
whether any errors occurred, and the start and stop times of the stages.


/run/
=====

Cloud-init uses :file:`/run/cloud-init/` for the following files:

* :file:`/run/cloud-init/instance-data.json`: world-readable JSON containing
standardized keys, sensitive keys redacted.
* :file:`/run/cloud-init/instance-data-sensitive.json`: root-readable
unredacted JSON blob.
* :file:`/run/cloud-init/combined-cloud-config.json`: root-readable
unredacted JSON blob. Any meta-data, vendor-data and user-data overrides
are applied to the :file:`/run/cloud-init/combined-cloud-config.json` config
values.
Loading
Loading