summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_set_hostname.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/config/cc_set_hostname.py')
-rw-r--r--cloudinit/config/cc_set_hostname.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/cloudinit/config/cc_set_hostname.py b/cloudinit/config/cc_set_hostname.py
index c0bda6fe..fa5c023c 100644
--- a/cloudinit/config/cc_set_hostname.py
+++ b/cloudinit/config/cc_set_hostname.py
@@ -107,7 +107,7 @@ def handle(
# distro._read_hostname implementation so we only validate one artifact.
prev_fn = os.path.join(cloud.get_cpath("data"), "set-hostname")
prev_hostname = {}
- if os.path.exists(prev_fn):
+ if os.path.exists(prev_fn) and os.stat(prev_fn).st_size > 0:
prev_hostname = util.load_json(util.load_file(prev_fn))
hostname_changed = hostname != prev_hostname.get(
"hostname"