Skip to content

feat: create parent directories if missing for config_update operation#3718

Merged
rina23q merged 3 commits intothin-edge:mainfrom
rina23q:improve/3693/add-immediate-parent-dir-control-to-config-mamagement
Jul 14, 2025
Merged

feat: create parent directories if missing for config_update operation#3718
rina23q merged 3 commits intothin-edge:mainfrom
rina23q:improve/3693/add-immediate-parent-dir-control-to-config-mamagement

Conversation

@rina23q
Copy link
Copy Markdown
Member

@rina23q rina23q commented Jul 2, 2025

Proposed changes

Previously, the config_update operation would fail if any parent directories of the target file were missing.

This change ensures that missing parent directories are automatically created when the operation is executed.

The mode, user, and group of the immediate parent directory can be configured via tedge-configuration-plugin.toml using the following keys:

  • parent_mode
  • parent_user
  • parent_group

If parent_user and parent_group are not explicitly specified, but the target file's ownership is provided, the parent directory will inherit the file's user and group.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#3693

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@rina23q rina23q temporarily deployed to Test Pull Request July 2, 2025 16:56 — with GitHub Actions Inactive
@rina23q rina23q changed the title Improve/3693/add immediate parent dir control to config mamagement feat: create parent directories if missing for config_update operation Jul 2, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 25.28736% with 130 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/core/tedge_write/src/bin.rs 0.00% 40 Missing ⚠️
crates/core/tedge_write/src/api.rs 0.00% 38 Missing ⚠️
...rates/extensions/tedge_config_manager/src/actor.rs 22.22% 26 Missing and 2 partials ⚠️
crates/common/tedge_utils/src/file.rs 5.26% 16 Missing and 2 partials ⚠️
crates/common/tedge_utils/src/atomic.rs 62.50% 0 Missing and 6 partials ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 2, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
655 0 3 655 100 1h48m18.738640999s

@rina23q rina23q temporarily deployed to Test Pull Request July 3, 2025 18:42 — with GitHub Actions Inactive
@rina23q rina23q temporarily deployed to Test Pull Request July 3, 2025 20:36 — with GitHub Actions Inactive
@rina23q rina23q marked this pull request as ready for review July 4, 2025 07:21
@reubenmiller reubenmiller added the theme:configuration Theme: Configuration management label Jul 4, 2025
@rina23q rina23q had a problem deploying to Test Pull Request July 4, 2025 14:30 — with GitHub Actions Failure
@rina23q rina23q temporarily deployed to Test Pull Request July 4, 2025 14:49 — with GitHub Actions Inactive
@rina23q rina23q temporarily deployed to Test Pull Request July 10, 2025 16:28 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

This PR has to be rebased on top of #3727, to have the broken unit tests fixed.

@rina23q rina23q had a problem deploying to Test Pull Request July 11, 2025 14:49 — with GitHub Actions Failure
@rina23q rina23q force-pushed the improve/3693/add-immediate-parent-dir-control-to-config-mamagement branch from 1596df4 to 9876dda Compare July 11, 2025 14:53
@rina23q rina23q had a problem deploying to Test Pull Request July 11, 2025 14:53 — with GitHub Actions Failure
@rina23q rina23q force-pushed the improve/3693/add-immediate-parent-dir-control-to-config-mamagement branch from 9876dda to 59af83e Compare July 11, 2025 14:53
@rina23q rina23q temporarily deployed to Test Pull Request July 11, 2025 14:54 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +392 to +393
${hash_before}= Execute Command md5sum ${device_file} ||true
${stat_before}= Execute Command stat ${device_file} ||true
Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That || true was intentional? If the expected file doesn't exist upfront (when it is expected to exist), wouldn't it be better to have the tests fail here with the clear "file not found error" rather than in the file content equiality check failing later on(which could be misleading)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reubenmiller Can I remove || true as Albin suggested?

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the downside is that the Execute Command will take 30 seconds to fail if the file isn't found (due to the in-built "smart retry" mechanism.

If you want clarify I would suggest using the "File Exists" check prior to getting it, as that will be the most descriptive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though given that the ||true was only added afterwards, then it might be better to remove it as it seems to be just a by-product of the PR and not directly required by it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ThinEdgeIo.File Should Exist and remove ||true. 6a61165

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@rina23q rina23q had a problem deploying to Test Pull Request July 14, 2025 12:29 — with GitHub Actions Failure
@rina23q rina23q force-pushed the improve/3693/add-immediate-parent-dir-control-to-config-mamagement branch from 6a61165 to 94b0a27 Compare July 14, 2025 12:31
@rina23q rina23q temporarily deployed to Test Pull Request July 14, 2025 12:31 — with GitHub Actions Inactive
rina23q and others added 3 commits July 14, 2025 14:25
Previously, the `config_update` operation would fail if any parent
directories of the target file were missing.

This change ensures that missing parent directories are automatically
created when the operation is executed.

The mode, user, and group of the immediate parent directory can be
configured via `tedge-configuration-plugin.toml` using the following
keys:
- `parent_mode`
- `parent_user`
- `parent_group`

If `parent_user` and `parent_group` are not explicitly specified,
but the target file's ownership is provided, the parent directory will
inherit the file's user and group.

Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
…settings

Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
@rina23q rina23q force-pushed the improve/3693/add-immediate-parent-dir-control-to-config-mamagement branch from 94b0a27 to 59d5806 Compare July 14, 2025 14:25
@rina23q rina23q temporarily deployed to Test Pull Request July 14, 2025 14:25 — with GitHub Actions Inactive
@rina23q rina23q added this pull request to the merge queue Jul 14, 2025
Merged via the queue into thin-edge:main with commit 6de1ab8 Jul 14, 2025
34 checks passed
@rina23q rina23q deleted the improve/3693/add-immediate-parent-dir-control-to-config-mamagement branch August 8, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:configuration Theme: Configuration management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants