Skip to content

docs: Add tedge-write documentation page#3116

Merged
Bravo555 merged 3 commits intothin-edge:mainfrom
Bravo555:docs/tedge-write
Sep 18, 2024
Merged

docs: Add tedge-write documentation page#3116
Bravo555 merged 3 commits intothin-edge:mainfrom
Bravo555:docs/tedge-write

Conversation

@Bravo555
Copy link
Copy Markdown
Member

@Bravo555 Bravo555 commented Sep 6, 2024

Proposed changes

Adds a documentation page for tedge-write component, which should contain information about the component relevant to users and references relevant tedge-write information in config_update operation reference.

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

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 10, 2024

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
505 0 2 505 100 1h25m49.965053999s

@reubenmiller reubenmiller added documentation Improvements or additions to documentation theme:configuration Theme: Configuration management labels Sep 10, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

Left small improvement suggestions

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.

The content looks fine. Just a few suggestions.

Comment on lines +9 to +10
/// A binary used for writing standard input to files which `tedge` user does not have write
/// permissions for, using sudo.
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.

Suggested change
/// A binary used for writing standard input to files which `tedge` user does not have write
/// permissions for, using sudo.
/// A binary used for writing to files which `tedge` user does not have write
/// permissions for, using sudo.
/// File content to be passed via standard input.

Just focussing on the primary purpose first, and the details later.

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.

My proposal:

Suggested change
/// A binary used for writing standard input to files which `tedge` user does not have write
/// permissions for, using sudo.
/// A binary used for writing to files which `tedge` user does not have write permissions for.
///
/// To be used in combination with sudo, passing the file content via standard input.

Copy link
Copy Markdown
Member Author

@Bravo555 Bravo555 Sep 12, 2024

Choose a reason for hiding this comment

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

Decided to go with 2nd proposal keeping first sentence short, also referenced tee which is very similar and users should be familiar with.

06a566e

Comment on lines +7 to +9
**tedge-write** is a helper thin-edge component used by tedge-agent for privilege elevation.
tedge-agent spawns a `tedge-write` process when it needs to write to files that `tedge` user/group
has no write permissions to (e.g. system files or files owned by other packages), for example when
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.

Suggested change
**tedge-write** is a helper thin-edge component used by tedge-agent for privilege elevation.
tedge-agent spawns a `tedge-write` process when it needs to write to files that `tedge` user/group
has no write permissions to (e.g. system files or files owned by other packages), for example when
**tedge-write** is a helper thin-edge component used by tedge-agent for privilege elevation,
when it needs to write to files that `tedge` user/group
has no write permissions to (e.g. system files or files owned by other packages), for example when

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.

I'd rather keep first sentence as a short summary and explain more in detail in the second sentence.

writing an updated configuration file as part of [`config_update` operation][1]. `tedge-agent` will
first try to write to a file directly and only retry using `tedge-write` if direct write fails due
to `tedge` user/group not having write permissions to either the file itself or its parent
directory. Write permission to the parent directory is required to guarantee config updates are
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.

Suggested change
directory. Write permission to the parent directory is required to guarantee config updates are
directory.
Write permission to the parent directory is required to guarantee config updates are

In docs, we try to follow a convention where new sentences are always started on a new line, to have smaller diffs when changes are made in future. A single line which is too long can be broken into smaller ones across multiple lines (I usually break where there's a punctuation). Would be nice if you could do that for the remaining sentences as well.

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.

I will follow this style more closely.
Usually I use rewrap extension in Vscode which automatically wraps text to a defined number of columns, but it reflows whole paragraphs, so it tends to merge back two sentences when separated by only a single newline, which is a bit unfortunate.

Comment on lines +18 to +21
`tedge-write` will perform an atomic write, i.e. it will write to a temporary file, set file
ownership and mode, and finally rename the temporary into the final file. If the target file already
exists, its original ownership/mode will be preserved and optionally provided new values will be
ignored.
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.

Suggested change
`tedge-write` will perform an atomic write, i.e. it will write to a temporary file, set file
ownership and mode, and finally rename the temporary into the final file. If the target file already
exists, its original ownership/mode will be preserved and optionally provided new values will be
ignored.
While updating a file, `tedge-write` performs an atomic write, i.e. it first writes to a temporary file, set file ownership and mode, and finally moves it to the target location.
If the target file already exists, its original ownership/mode is preserved and the optionally provided new values are ignored.

exists, its original ownership/mode will be preserved and optionally provided new values will be
ignored.

For `tedge-write` to work, it needs to be able to write to and set ownership and mode of all files.
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.

Suggested change
For `tedge-write` to work, it needs to be able to write to and set ownership and mode of all files.
For `tedge-write` to work, it needs to be able to write to and set ownership and mode of the target files.

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.

fixed 14fe31f

Comment on lines +24 to +25
To achieve this we can use `sudo` with a `sudoers` configuration that allows `tedge` user to run
`tedge-write` as root without password if the destination file is inside `/etc`:
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.

Suggested change
To achieve this we can use `sudo` with a `sudoers` configuration that allows `tedge` user to run
`tedge-write` as root without password if the destination file is inside `/etc`:
To achieve this we can use `sudo` with a `sudoers` configuration that allows `tedge` user to run
`tedge-write` as root without password.
For example, the following setting allows `tedge-write` to update any file inside `/etc` with elevated privileges:

Comment on lines +33 to +35
The sudoers entry will be created by thin-edge.io automatically under `/etc/sudoers.d/tedge`, but in
non-standard setups the default configuration may need to be changed. It's necessary to provide a
full path to `tedge-write` in the `sudoers` entry. See [`sudoers(5)`][2] for additional details.
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.

Suggested change
The sudoers entry will be created by thin-edge.io automatically under `/etc/sudoers.d/tedge`, but in
non-standard setups the default configuration may need to be changed. It's necessary to provide a
full path to `tedge-write` in the `sudoers` entry. See [`sudoers(5)`][2] for additional details.
When %%te%% is installed using any one of the standard installation methods, the sudoers entry is automatically created under `/etc/sudoers.d/tedge`,
but in non-standard setups the sudoers configuration may need to be updated manually.
It's necessary to provide a full path to `tedge-write` in the `sudoers` entry. See [`sudoers(5)`][2] for additional details.

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.

fixed 14fe31f

## Command help

```sh title="tedge-write"
A binary used for writing to files which `tedge` user does not have write permissions for, using sudo
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.

Nitpick: This message got updated in this PR.

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.

Indeed manually generating command help is quite a churn and easy to forget to update, it would be good to generate automatically in the future so we could easily see help for all commands in the documentation.

pros:

  • command help always in sync
  • would be easier to verify that flags and options for commands are consistent between different commands

cons:

  • more build scripts for the CI pipeline

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.

fixed 14fe31f

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek Sep 13, 2024

Choose a reason for hiding this comment

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

it would be good to generate it automatically

We already have that: Command block

Instead of sh title="tedge-write" use:

text command="tedge-write --help" title="tedge-write"

Copy link
Copy Markdown
Member Author

@Bravo555 Bravo555 Sep 13, 2024

Choose a reason for hiding this comment

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

Replaced with a call to command block, but I'll need to verify when it's deployed to gh-pages that the output is present as when the command could not be started (e.g. because it wasn't found) the build doesn't fail but the text is left empty.

fb530fb

@Bravo555 Bravo555 temporarily deployed to Test Pull Request September 13, 2024 10:13 — with GitHub Actions Inactive
Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

Looks good!

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

Copy link
Copy Markdown
Contributor

@gligorisaev gligorisaev left a comment

Choose a reason for hiding this comment

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

Documentation describes the feature correctly

Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
@Bravo555 Bravo555 temporarily deployed to Test Pull Request September 18, 2024 11:16 — with GitHub Actions Inactive
@Bravo555 Bravo555 added this pull request to the merge queue Sep 18, 2024
@Bravo555 Bravo555 removed their assignment Sep 18, 2024
Merged via the queue into thin-edge:main with commit a4a57ae Sep 18, 2024
@Bravo555 Bravo555 deleted the docs/tedge-write branch June 3, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants