Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] ephemeral directory module not used #4766

Closed
holmanb opened this issue Jan 10, 2024 · 2 comments · Fixed by #4820
Closed

[bug] ephemeral directory module not used #4766

holmanb opened this issue Jan 10, 2024 · 2 comments · Fixed by #4820
Assignees
Labels
bug Something isn't working correctly

Comments

@holmanb
Copy link
Member

holmanb commented Jan 10, 2024

Bug report

In PR #4677, /run/ was relocated to /var/run on BSD. However, due to inconsistent use of the Paths object, several parts of cloud-init still have directories hard-coded to /run/cloud-init/. It should be fairly straightforward to update all of these with a reference to path.run_dir (where path is an instance of cloudinit.helpers.Paths).

A quick grep shows:

$ rg '/run/cloud-init' cloudinit         
cloudinit/settings.py
19:RUN_CLOUD_CONFIG = "/run/cloud-init/cloud.cfg"

cloudinit/cmd/devel/logs.py
25:CLOUDINIT_RUN_DIR = "/run/cloud-init"
135:    """Return a list of files to ignore for /run/cloud-init directory"""

cloudinit/cmd/devel/render.py
44:            " /run/cloud-init/instance-data.json"

cloudinit/cmd/main.py
705:        link_d = os.path.normpath("/run/cloud-init")

cloudinit/sources/helpers/azure.py
42:LOG_PUSHED_TO_KVP_INDEX_FILE = "/run/cloud-init/log_pushed_to_kvp_index"

cloudinit/helpers.py
310:        self.run_dir: str = path_cfgs.get("run_dir", "/run/cloud-init")

cloudinit/stages.py
1072:            # runtime config. I.e., /run/cloud-init/cloud.cfg

cloudinit/temp_utils.py
14:_ROOT_TMPDIR = "/run/cloud-init/tmp"
33:    When root, cloud-init will use /run/cloud-init/tmp to avoid

More annoying, and maybe more difficult to solve, is the fact that some parts of the codebase blindly call Path({}).

cloudinit/cmd/devel/logs.py
141:        ignored_files.append(Paths({}).lookups["instance_data_sensitive"])

cloudinit/stages.py
260:        no_cfg_paths = helpers.Paths({}, self.datasource)

This is particularly troublesome, for example, in the second call where /run/ is being called, since this is used to identify from the configuration which distro this is - a chicken / egg scenario.

@holmanb holmanb added bug Something isn't working correctly new An issue that still needs triage labels Jan 10, 2024
@blackboxsw
Copy link
Collaborator

the function cloudinit.cmd.devel.read_cfg_paths may be helpful in a lot of these cases for grabbing the configured run_dir from Paths.

@blackboxsw blackboxsw removed the new An issue that still needs triage label Jan 15, 2024
@holmanb
Copy link
Member Author

holmanb commented Jan 29, 2024

the function cloudinit.cmd.devel.read_cfg_paths may be helpful in a lot of these cases for grabbing the configured run_dir from Paths.

@blackboxsw This can't be done in stages.py, since cloudinit.cmd.devel.read_cfg_paths literally calls the problematic line:

cloudinit/stages.py
260:        no_cfg_paths = helpers.Paths({}, self.datasource)

That would cause infinite recursion.

holmanb added a commit that referenced this issue Apr 2, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes GH-4766
blackboxsw pushed a commit to blackboxsw/cloud-init that referenced this issue Apr 2, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes canonicalGH-4766
blackboxsw pushed a commit to blackboxsw/cloud-init that referenced this issue Apr 2, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes canonicalGH-4766
blackboxsw pushed a commit to blackboxsw/cloud-init that referenced this issue Apr 3, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes canonicalGH-4766
holmanb added a commit that referenced this issue Apr 3, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes GH-4766
holmanb added a commit that referenced this issue Apr 3, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes GH-4766
holmanb added a commit that referenced this issue Apr 3, 2024
Update various hard-coded filepaths. Also make sure we
bootstrap our Paths() config correctly so that we read
from the configured rundir.

Co-authored-by: Mina Galić <freebsd@igalic.co>
Sponsored by: The FreeBSD Foundation

Fixes GH-4766
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants