Skip to content

Commit 7d07f71

Browse files
committed
Merge branch 'main' into weblate-main
2 parents e2da13e + b2a5e50 commit 7d07f71

34 files changed

Lines changed: 132 additions & 157 deletions

.tito/packages/uyuni-tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.11-0 ./
1+
5.1.12-0 ./

mgradm/cmd/backup/restore/podman_utils.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"errors"
1212
"io"
1313
"os"
14-
"path"
1514

1615
"github.com/rs/zerolog/log"
1716
"github.com/uyuni-project/uyuni-tools/mgradm/cmd/backup/shared"
@@ -206,39 +205,3 @@ func restorePodmanSecrets(header *tar.Header, tr *tar.Reader, flags *shared.Flag
206205
}
207206
return hasError
208207
}
209-
210-
// handleVolumeHacks handles special import cicrumstances.
211-
// etc-apache2 volume has a trailing mime.type link which podman import reports as an error.
212-
// etc-postfix volume has a trailing cacerts link which podman import reports as an error.
213-
func handleVolumeHacks(volume string, inErr error) error {
214-
// Quick return if everything is ok
215-
// or if something happened and volume was not imported at all
216-
if inErr == nil || !podman.IsVolumePresent(volume) {
217-
return inErr
218-
}
219-
// special handling of apache2 and postfix volume with trailing links
220-
basePath, err := podman.GetPodmanVolumeBasePath()
221-
if err != nil {
222-
log.Debug().Msg("cannot get base volume path")
223-
return inErr
224-
}
225-
switch volume {
226-
case "etc-apache2":
227-
log.Debug().Msg("Special apache2 volume handling")
228-
volumePath := path.Join(basePath, "etc-apache2", "_data")
229-
if err := os.Symlink("../mime.types", path.Join(volumePath, "mime.types")); err != nil {
230-
log.Debug().Err(err).Msgf("cannot create link %s for %s", path.Join(volumePath, "mime.types"), "../mime.types")
231-
return inErr
232-
}
233-
return nil
234-
case "etc-postfix":
235-
log.Debug().Msg("Special postfix volume handling")
236-
volumePath := path.Join(basePath, "etc-postfix", "_data")
237-
if err := os.Symlink("../../ssl/certs", path.Join(volumePath, "ssl", "cacerts")); err != nil {
238-
log.Debug().Err(err).Msgf("cannot create link %s for %s", path.Join(volumePath, "ssl", "cacerts"), "../../ssl/certs")
239-
return inErr
240-
}
241-
return nil
242-
}
243-
return inErr
244-
}

mgradm/cmd/backup/restore/restore.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,14 @@ func gatherImagesToRestore(source string, flags *shared.Flagpole) ([]string, err
208208
}
209209

210210
func restoreVolumes(volumes []string, flags *shared.Flagpole, dryRun bool) error {
211-
var hasError error
212211
for _, volume := range volumes {
213212
volName := strings.TrimSuffix(volume, ".tar")
214213
_, volName = path.Split(volName)
215214
if err := podman.ImportVolume(volName, volume, flags.SkipVerify, dryRun); err != nil {
216-
hasError = utils.JoinErrors(hasError, handleVolumeHacks(volName, err))
215+
return err
217216
}
218217
}
219-
return hasError
218+
return nil
220219
}
221220

222221
func restoreImages(images []string, dryRun bool) error {

mgradm/cmd/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77
import (
88
"os"
99
"path"
10+
"strings"
1011

1112
"github.com/rs/zerolog/log"
1213
"github.com/spf13/cobra"
@@ -64,9 +65,8 @@ func NewUyuniadmCommand() (*cobra.Command, error) {
6465
if cmd.Name() != "completion" {
6566
utils.LogInit(true)
6667
utils.SetLogLevel(globalFlags.LogLevel)
67-
log.Info().Msgf(L("Welcome to %s"), name)
68+
log.Info().Msgf(L("Starting %s"), strings.Join(os.Args, " "))
6869
log.Info().Msgf(L("Use of this software implies acceptance of the End User License Agreement."))
69-
log.Info().Msgf(L("Executing command: %s"), cmd.Name())
7070
}
7171
}
7272

mgradm/cmd/install/podman/utils.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,6 @@ func installForPodman(
117117
return err
118118
}
119119

120-
if err := coco.SetupCocoContainer(
121-
systemd, authFile, flags.Image.Registry, flags.Coco, flags.Image,
122-
flags.Installation.DB,
123-
); err != nil {
124-
return err
125-
}
126-
127-
if err := hub.SetupHubXmlrpc(
128-
systemd, authFile, flags.Image.Registry, flags.Image.PullPolicy, flags.Image.Tag, flags.HubXmlrpc,
129-
); err != nil {
130-
return err
131-
}
132-
133-
if err := saline.SetupSalineContainer(
134-
systemd, authFile, flags.Image.Registry, flags.Saline, flags.Image, flags.Installation.TZ,
135-
); err != nil {
136-
return err
137-
}
138-
139120
cnx := shared.NewConnection("podman", shared_podman.ServerContainerName, "")
140121
if err := podman.WaitForSystemStart(systemd, cnx, preparedImage, flags.Installation.TZ,
141122
flags.Installation.Debug.Java, flags.Mirror, flags.Podman.Args); err != nil {
@@ -155,6 +136,25 @@ func installForPodman(
155136
if err := shared_podman.EnablePodmanSocket(); err != nil {
156137
return utils.Error(err, L("cannot enable podman socket"))
157138
}
139+
140+
if err := coco.SetupCocoContainer(
141+
systemd, authFile, flags.Image.Registry, flags.Coco, flags.Image,
142+
flags.Installation.DB,
143+
); err != nil {
144+
return err
145+
}
146+
147+
if err := hub.SetupHubXmlrpc(
148+
systemd, authFile, flags.Image.Registry, flags.Image.PullPolicy, flags.Image.Tag, flags.HubXmlrpc,
149+
); err != nil {
150+
return err
151+
}
152+
153+
if err := saline.SetupSalineContainer(
154+
systemd, authFile, flags.Image.Registry, flags.Saline, flags.Image, flags.Installation.TZ,
155+
); err != nil {
156+
return err
157+
}
158158
return nil
159159
}
160160

mgradm/cmd/install/shared/flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,7 @@ func AddInstallFlags(cmd *cobra.Command) {
5252
_ = utils.AddFlagToHelpGroupID(cmd, "admin-firstName", "first-user")
5353
_ = utils.AddFlagToHelpGroupID(cmd, "admin-lastName", "first-user")
5454
_ = utils.AddFlagToHelpGroupID(cmd, "organization", "first-user")
55+
56+
cmd.Flags().String("ssl-password", "", L("Password for the CA key to generate"))
57+
_ = utils.AddFlagToHelpGroupID(cmd, "ssl-password", "ssl")
5558
}

mgradm/cmd/migrate/shared/flags.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import (
88
"github.com/spf13/cobra"
99
adm_utils "github.com/uyuni-project/uyuni-tools/mgradm/shared/utils"
1010
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
11+
"github.com/uyuni-project/uyuni-tools/shared/utils"
1112
)
1213

1314
// AddMigrateFlags add migration flags to a command.
1415
func AddMigrateFlags(cmd *cobra.Command) {
15-
cmd.Flags().Bool("prepare", false, L("Prepare the mgration - copy the data without stopping the source server."))
16+
cmd.Flags().Bool("prepare", false, L("Prepare the migration - copy the data without stopping the source server."))
1617

1718
cmd.Flags().String("user", "root",
1819
L("User on the source server. Non-root user must have passwordless sudo privileges (NOPASSWD tag in /etc/sudoers)."),
@@ -23,4 +24,7 @@ func AddMigrateFlags(cmd *cobra.Command) {
2324
adm_utils.AddUpgradeCocoFlag(cmd)
2425
adm_utils.AddUpgradeHubXmlrpcFlags(cmd)
2526
adm_utils.AddUpgradeSalineFlag(cmd)
27+
28+
cmd.Flags().String("ssl-password", "", L("Current Server CA password"))
29+
_ = utils.AddFlagToHelpGroupID(cmd, "ssl-password", "ssl")
2630
}

mgradm/cmd/upgrade/shared/flags.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package shared
77
import (
88
"github.com/spf13/cobra"
99
adm_utils "github.com/uyuni-project/uyuni-tools/mgradm/shared/utils"
10+
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
11+
"github.com/uyuni-project/uyuni-tools/shared/utils"
1012
)
1113

1214
// AddUpgradeFlags add upgrade flags to a command.
@@ -17,6 +19,9 @@ func AddUpgradeFlags(cmd *cobra.Command) {
1719
adm_utils.AddUpgradeCocoFlag(cmd)
1820
adm_utils.AddUpgradeHubXmlrpcFlags(cmd)
1921
adm_utils.AddUpgradeSalineFlag(cmd)
22+
23+
cmd.Flags().String("ssl-password", "", L("Current Server CA password"))
24+
_ = utils.AddFlagToHelpGroupID(cmd, "ssl-password", "ssl")
2025
}
2126

2227
// AddUpgradeListFlags add upgrade list flags to a command.

mgradm/shared/podman/podman.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func Upgrade(
371371
oldPgVersion, newPgVersion,
372372
)
373373
if err := RunPgsqlVersionUpgrade(
374-
authFile, registry, pgsqlFlags.Image, upgradeImage, strconv.Itoa(oldPgVersion),
374+
authFile, registry, image, upgradeImage, strconv.Itoa(oldPgVersion),
375375
strconv.Itoa(newPgVersion),
376376
); err != nil {
377377
return utils.Errorf(err, L("cannot run PostgreSQL version upgrade script"))
@@ -416,7 +416,16 @@ func Upgrade(
416416
if err := updateServerSystemdService(); err != nil {
417417
return err
418418
}
419+
419420
log.Info().Msg(L("Waiting for the server to start…"))
421+
cnx := shared.NewConnection("podman", podman.ServerContainerName, "")
422+
if err := systemd.StartService(podman.ServerService); err != nil {
423+
return utils.Error(err, L("cannot start service"))
424+
}
425+
426+
if err := cnx.WaitForHealthcheck(); err != nil {
427+
log.Warn().Err(err)
428+
}
420429

421430
inspectedDB := adm_utils.DBFlags{
422431
Name: inspectedValues.DBName,
@@ -466,7 +475,7 @@ func WaitForSystemStart(
466475
return utils.Error(err, L("cannot enable service"))
467476
}
468477

469-
return cnx.WaitForServer()
478+
return cnx.WaitForHealthcheck()
470479
}
471480

472481
// Migrate will migrate a server to the image given as attribute.

mgradm/shared/podman/ssl.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func reuseExistingCertificatesFromMounts(image string, tempDir string, isDatabas
211211
rootCA, err := shared_podman.ReadFromContainer(containerName, image, volumes, nil,
212212
caCheckPath)
213213
if err != nil {
214-
log.Debug().Err(err).Msgf("CA file %s not found", caCheckPath)
214+
log.Info().Msgf(L("CA file %s not found. New CA and certificates will be created."), caCheckPath)
215215
return false, nil
216216
}
217217

@@ -223,7 +223,7 @@ func reuseExistingCertificatesFromMounts(image string, tempDir string, isDatabas
223223
cert, err := shared_podman.ReadFromContainer(containerName, image, volumes, nil,
224224
crtCheckPath)
225225
if err != nil {
226-
log.Debug().Err(err).Msgf("Cert file %s not found", crtCheckPath)
226+
log.Info().Msgf(L("Cert file %s not found. A new certificate will be created."), crtCheckPath)
227227
return false, nil
228228
}
229229
if err = os.WriteFile(serverCert, cert, 0444); err != nil {
@@ -234,7 +234,7 @@ func reuseExistingCertificatesFromMounts(image string, tempDir string, isDatabas
234234
keyData, err := shared_podman.ReadFromContainer(containerName, image, volumes, nil,
235235
keyCheckPath)
236236
if err != nil {
237-
log.Debug().Err(err).Msgf("Cert Key file %s not found", keyCheckPath)
237+
log.Info().Msgf(L("Cert key file %s not found. A new certificate will be created."), keyCheckPath)
238238
return false, nil
239239
}
240240
if err = os.WriteFile(serverKey, keyData, 0400); err != nil {
@@ -302,7 +302,7 @@ func generateServerCertificate(image string, sslFlags *adm_utils.InstallSSLFlags
302302
"HOSTNAME": fqdn,
303303
}
304304
if err := runSSLContainer(sslSetupServerScript, tempDir, image, tz, env); err != nil {
305-
return utils.Error(err, L("Server SSL certificates generation failed"))
305+
return utils.Error(err, L("Failed to generate server SSL certificates. Please check the input parameters."))
306306
}
307307

308308
log.Info().Msg(L("Server SSL certificates generated"))
@@ -339,7 +339,7 @@ func generateDatabaseCertificate(image string, sslFlags *adm_utils.InstallSSLFla
339339
"HOSTNAME": fqdn,
340340
}
341341
if err := runSSLContainer(sslSetupDatabaseScript, tempDir, image, tz, env); err != nil {
342-
return utils.Error(err, L("Database SSL certificates generation failed"))
342+
return utils.Error(err, L("Failed to generate server Database SSL certificates. Please check the input parameters."))
343343
}
344344

345345
log.Info().Msg(L("Database SSL certificates generated"))

0 commit comments

Comments
 (0)