Skip to content

Enhance connections and fix online db - #764

Merged
mcalmer merged 6 commits into
uyuni-project:mainfrom
aaannz:enhance_cnx
Apr 14, 2026
Merged

Enhance connections and fix online db#764
mcalmer merged 6 commits into
uyuni-project:mainfrom
aaannz:enhance_cnx

Conversation

@aaannz

@aaannz aaannz commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR change?

Main motivation for this is to fix backup db functionality with 5.2 pg_hba which has peer instead of blind trust for local connections. That means we need to switch to postgres before calling the psql.

This PR adds:

  • ability to use connection under a set user - Exec will be wrapped by su and Copy will change ownership to the user.
  • ability to use connection also to the host. This can streamline some implementation details where we can use the same code for containers and host alike
  • copy can now infer target filename similarly like scp. mgrctl copy myfile server: now assumes target file is also myfile. And similarly when copying into the directory.

Codespace

Check if you already have a running container clicking on Running CodeSpace

Create CodeSpace About billing for Github Codespaces CodeSpace Billing Summary CodeSpace Limit

Test coverage

  • Unit tests were added

  • DONE

Links

Issue(s): #

  • DONE

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:

  • No changelog needed

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!

aaannz added 3 commits April 14, 2026 12:52
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 "/".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 wrap Exec() with su when configured.
  • Add "host" backend support for Exec(), Copy(), and existence checks.
  • Improve Copy() to infer destination filenames for server: 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.

Comment thread shared/connection.go
Comment thread shared/connection.go
Comment thread shared/connection.go Outdated
Comment thread shared/connection_test.go
Comment thread shared/connection_test.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread shared/connection.go Outdated
Comment thread shared/connection_test.go
Comment thread mgradm/cmd/backup/db/rebase.go Outdated
Comment thread mgradm/cmd/backup/db/enable.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread shared/connection.go Outdated
@aaannz
aaannz marked this pull request as ready for review April 14, 2026 13:05
@sonarqubecloud

Copy link
Copy Markdown

@aaannz
aaannz requested a review from mbussolotto April 14, 2026 13:05
@mcalmer
mcalmer merged commit 763789b into uyuni-project:main Apr 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants