Enhance connections and fix online db - #764
Conversation
This commit add support for host backend. Goal is to be able to use same approach between containers and host just by using different backend.
This commit add support to be able to specify user under which connection should be made. Exec will wrap commands with su and copy will change ownership.
When using "mgrctl cp file server:file" we always had to specify filename. This commit inders the filename in case of "mgrctl cp file server:" Similarly when copying into the directory when path ends with "/".
There was a problem hiding this comment.
Pull request overview
This PR enhances the shared.Connection abstraction to support running commands as a specific user (via su), adds a "host" backend mode, and improves Copy() destination inference (scp-like behavior). It also updates DB backup commands to run SQL checks as the Postgres runtime user to work with stricter pg_hba.conf defaults (e.g., peer).
Changes:
- Add per-connection runtime user support (
NewUserConnection) and wrapExec()withsuwhen configured. - Add
"host"backend support forExec(),Copy(), and existence checks. - Improve
Copy()to infer destination filenames forserver:and directory targets; update DB backup commands to use the Postgres runtime user.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| uyuni-tools.changes.oholecek.connection_enhancements | Changelog entry for DB backup fix and copy inference. |
| shared/podman/utils.go | Add DBRuntimeUser constant (postgres). |
| shared/connection.go | Add runtime user support, host backend support, quoteArgs, and copy destination inference. |
| shared/connection_test.go | Add unit tests for host exec/copy, user exec, and argument quoting. |
| mgradm/cmd/backup/db/status.go | Use NewUserConnection(..., postgres) for DB status checks. |
| mgradm/cmd/backup/db/enable.go | Use NewUserConnection(..., postgres) for DB backup enable flow. |
| mgradm/cmd/backup/db/disable.go | Use NewUserConnection(..., postgres) for DB backup disable flow. |
| mgradm/cmd/backup/db/rebase.go | Use NewUserConnection(..., postgres) for DB backup rebase flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



What does this PR change?
Main motivation for this is to fix backup db functionality with 5.2 pg_hba which has
peerinstead of blindtrustfor local connections. That means we need to switch to postgres before calling the psql.This PR adds:
suand Copy will change ownership to the user.mgrctl copy myfile server:now assumes target file is alsomyfile. And similarly when copying into the directory.Codespace
Check if you already have a running container clicking on
Test coverage
Unit tests were added
DONE
Links
Issue(s): #
Changelogs
Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository
If you don't need a changelog check, please mark this checkbox:
If you uncheck the checkbox after the PR is created, you will need to re-run
changelog_test(see below)Before you merge
Check How to branch and merge properly!