summaryrefslogtreecommitdiff
path: root/cloudinit/apport.py
diff options
context:
space:
mode:
authorAlberto Contreras <alberto.contreras@canonical.com>2022-06-22 17:38:17 +0200
committerGitHub <noreply@github.com>2022-06-22 10:38:17 -0500
commita23c886ea2cd301b6021eb03636beb5b92c429dc (patch)
tree7d2bffbc225c2134115a6db93a9041c08772d562 /cloudinit/apport.py
parent2ab0e67da69fc7141e14c172ab73c9ad3895eda3 (diff)
downloadcloud-init-git-a23c886ea2cd301b6021eb03636beb5b92c429dc.tar.gz
cloud-config: honor cloud_dir setting (#1523)
Ensure cloud_dir setting is respected rather than hardcoding "/var/lib/cloud" - Modules affected: cmd.main, apport, devel.logs (collect-logs), cc_snap, sources.DataSourceAzure, sources.DataSourceBigstep, util:fetch_ssl_details. - testing: Extend and port to pytest unit tests, add integration test. LP: #1976564
Diffstat (limited to 'cloudinit/apport.py')
-rw-r--r--cloudinit/apport.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/cloudinit/apport.py b/cloudinit/apport.py
index 92068aa9..aa3a6c5c 100644
--- a/cloudinit/apport.py
+++ b/cloudinit/apport.py
@@ -3,6 +3,7 @@
# This file is part of cloud-init. See LICENSE file for license information.
"""Cloud-init apport interface"""
+from cloudinit.cmd.devel import read_cfg_paths
try:
from apport.hookutils import (
@@ -53,7 +54,11 @@ KNOWN_CLOUD_NAMES = [
# Potentially clear text collected logs
CLOUDINIT_LOG = "/var/log/cloud-init.log"
CLOUDINIT_OUTPUT_LOG = "/var/log/cloud-init-output.log"
-USER_DATA_FILE = "/var/lib/cloud/instance/user-data.txt" # Optional
+
+
+def _get_user_data_file() -> str:
+ paths = read_cfg_paths()
+ return paths.get_ipath_cur("userdata_raw")
def attach_cloud_init_logs(report, ui=None):
@@ -106,18 +111,19 @@ def attach_cloud_info(report, ui=None):
def attach_user_data(report, ui=None):
"""Optionally provide user-data if desired."""
if ui:
+ user_data_file = _get_user_data_file()
prompt = (
"Your user-data or cloud-config file can optionally be provided"
" from {0} and could be useful to developers when addressing this"
" bug. Do you wish to attach user-data to this bug?".format(
- USER_DATA_FILE
+ user_data_file
)
)
response = ui.yesno(prompt)
if response is None:
raise StopIteration # User cancelled
if response:
- attach_file(report, USER_DATA_FILE, "user_data.txt")
+ attach_file(report, user_data_file, "user_data.txt")
def add_bug_tags(report):