-
Notifications
You must be signed in to change notification settings - Fork 19
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
Dedicated container for database #482
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple comments, mostly typos.
Once this is merged, smdba autotune call can be also removed from mgr-setup and others.
) error { | ||
image := pgsqlFlags.Image | ||
currentReplicas := systemd.CurrentReplicaCount(podman.PgsqlService) | ||
log.Debug().Msgf("Current HUB replicas running are %d.", currentReplicas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Debug().Msgf("Current HUB replicas running are %d.", currentReplicas) | |
log.Debug().Msgf("Current pgsql replicas running are %d.", currentReplicas) |
log.Debug().Msgf("Current HUB replicas running are %d.", currentReplicas) | ||
|
||
if pgsqlFlags.Replicas == 0 { | ||
log.Debug().Msg("No pgsql requested.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Debug().Msg("No pgsql requested.") | |
log.Info().Msg(L("No Postgres container requested.")) |
log.Debug().Msg("No pgsql requested.") | ||
} | ||
if !pgsqlFlags.IsChanged { | ||
log.Info().Msgf(L("No changes requested for hub. Keep %d replicas."), currentReplicas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info().Msgf(L("No changes requested for hub. Keep %d replicas."), currentReplicas) | |
log.Info().Msgf(L("No changes requested for pgsql. Keep %d replicas."), currentReplicas) |
if err := cnx.WaitForHealthcheck(); err != nil { | ||
return err | ||
} | ||
// Now the servisce is up and ready, the admin credentials are no longer needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Now the servisce is up and ready, the admin credentials are no longer needed | |
// Now the service is up and ready, the admin credentials are no longer needed |
@@ -0,0 +1,191 @@ | |||
// SPDX-FileCopyrightText: 2024 SUSE LLC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// SPDX-FileCopyrightText: 2024 SUSE LLC | |
// SPDX-FileCopyrightText: 2025 SUSE LLC |
OLD_VERSION={{ .OldVersion }} | ||
NEW_VERSION={{ .NewVersion }} | ||
FAST_UPGRADE=--link | ||
FAST_UPGRADE= #--link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore
@@ -209,3 +209,21 @@ Leave it unset if you want to keep the previous number of replicas. | |||
_ = utils.AddFlagToHelpGroupID(cmd, "saline-replicas", "saline-container") | |||
_ = utils.AddFlagToHelpGroupID(cmd, "saline-port", "saline-container") | |||
} | |||
|
|||
// AddPgsqlFlags adds hub XML-RPC related parameters to cmd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// AddPgsqlFlags adds hub XML-RPC related parameters to cmd. | |
// AddPgsqlFlags adds postgres related parameters to cmd. |
_ = utils.AddFlagToHelpGroupID(cmd, "pgsql-replicas", "pgsql-container") | ||
} | ||
|
||
// AddUpgradePgsqlFlags adds hub XML-RPC related parameters to cmd upgrade. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// AddUpgradePgsqlFlags adds hub XML-RPC related parameters to cmd upgrade. | |
// AddUpgradePgsqlFlags adds postgres related parameters to cmd upgrade. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good, just a few questions on this
if err := EnablePgsql(systemd, 0); err != nil { | ||
return err | ||
} | ||
if err := EnablePgsql(systemd, pgsqlFlags.Replicas); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why first enable with 0 replicas and then with the correct number of replicas?
// This function is meant for installation or migration, to enable or disable the service after, use ScaleService. | ||
func EnablePgsql(systemd podman.Systemd, replicas int) error { | ||
if replicas > 1 { | ||
log.Warn().Msg(L("Multiple Hub XML-RPC container replicas are not currently supported, setting up only one.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Warn().Msg(L("Multiple Hub XML-RPC container replicas are not currently supported, setting up only one.")) | |
log.Warn().Msg(L("Multiple Pgsql container replicas are not supported, setting up only one.")) |
if err != nil { | ||
return err | ||
} | ||
err = podman.RunContainer("uyuni-db-migrate", pgsqlImage, utils.PgsqlRequiredVolumeMounts, []string{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updade command also deals with major version upgrade? I think that at version 5.0 Michele prepared the upgrade process with the upgrade container to allow major upgrades where the database version would. Is this taken into consideration?
Image: image, | ||
} | ||
if err := utils.WriteTemplateToFile( | ||
pgsqlData, podman.GetServicePath(podman.PgsqlService+"@"), 0555, true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses the replica mechanism with 0 or 1. In this case would make sense to have it or should we keep more simple and generate or not the systems configuration. We can allow remote database in the future, but as for first version on 5.1 it would be possible.
Also, in the future when we support remote database and user wants to migrate to there, it would be a documented manual step, since it would have a lot involved.
user, | ||
false, | ||
prepare, | ||
"uyuni-pgsql-server.mgr.internal", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In future we may allow to use external database. for now it should work, But I saw somewhere in the code that users can specify the dbhostname. We should limit that or adapt this part of the code. At this stage we can have it flexible, but users should not be allowed to define an external database fqdn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree: this was already allowed for Amazon databases in 4.3 and we have to keep at least this around. Preventing users from setting an external DB FQDN would be a regression... Also remember that the product supported by SUSE is not the only one around: why preventing Uyuni users to use this?
|
||
{{ if .RunAutotune }} | ||
echo "Running smdba system-check autotuning..." | ||
smdba system-check autotuning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we stop running the autotuning on install and upgrade? We would need a new mechanism or notify the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in the postgres container uyuni-project/uyuni#9469
var PgsqlFlagsTestArgs = []string{ | ||
"--pgsql-image", "pgsqlimg", | ||
"--pgsql-tag", "pgsqltag", | ||
"--pgsql-replicas", "0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we want to expose the replicas in here and at this stage. We may use internally, but for now users should always use pgsql container active. When we have the external database support we may add a parameter that make it clear, like --external-db
which ideally would not deploy the database container (with external database have a service to start the containerized DB can be confusing)
// VarPgsqlVolumeMount defines the /var/lib/pgsql volume mount. | ||
var VarPgsqlVolumeMount = types.VolumeMount{MountPath: "/var/lib/pgsql", Name: "var-pgsql", Size: "50Gi"} | ||
// VarPgsqlDataVolumeMount defines the /var/lib/pgsql/data volume mount. | ||
var VarPgsqlDataVolumeMount = types.VolumeMount{MountPath: "/var/lib/pgsql/data", Name: "var-pgsql", Size: "50Gi"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this version work in the migration from 5.0 to 5.1, since the mounting point will be different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is detected in inspect and eventually fixed in pgsqlMigrationScriptTemplate
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
environment += fmt.Sprintf("Environment=POSTGRES_USER=\"%s\"\n", admin) | ||
} | ||
if password != "" { | ||
environment += fmt.Sprintf("Environment=POSTGRES_PASSWORD=\"%s\"\n", password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use passwords as environment with systemd. We'll need to use a podman secret here
What does this PR change?
Current state:
Works with the image from uyuni-project/uyuni#9469
mgradm install podman --pgsql-image <image> --pgsql-tag <tag>
Uses workarounds for the issues discussed in https://github.com/SUSE/spacewalk/issues/25363
Missing kubernetes.
Test coverage
No tests: add explanation
No tests: already covered
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!