Skip to content

Commit 66af7ed

Browse files
authored
Merge pull request #589 from mbussolotto/health
during upgrade, pgsql service needs to be started before healtcheck (bsc#1243402)
2 parents 1a1924d + 46be190 commit 66af7ed

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

mgradm/shared/pgsql/pgsql.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func SetupPgsql(
4949
}
5050
cnx := shared.NewConnection("podman", podman.DBContainerName, "")
5151
if err := cnx.WaitForHealthcheck(); err != nil {
52-
return err
52+
return utils.Errorf(err, L("%s fails healtcheck"), podman.DBContainerName)
5353
}
5454

5555
return nil
@@ -81,8 +81,16 @@ func Upgrade(
8181
return err
8282
}
8383

84+
if err := systemd.StartService(podman.DBService); err != nil {
85+
return err
86+
}
87+
8488
cnx := shared.NewConnection("podman", podman.DBContainerName, "")
85-
return cnx.WaitForHealthcheck()
89+
if err := cnx.WaitForHealthcheck(); err != nil {
90+
return utils.Errorf(err, L("%s fails healtcheck"), podman.DBContainerName)
91+
}
92+
93+
return nil
8694
}
8795

8896
// GeneratePgsqlSystemdService creates the DB container systemd files.

shared/podman/systemd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ func (s SystemdImpl) ServiceIsEnabled(name string) bool {
5858
// DisableService disables a service
5959
// name is the name of the service without the '.service' part.
6060
func (s SystemdImpl) DisableService(name string) error {
61+
if !s.ServiceIsEnabled(name) {
62+
log.Debug().Msgf("%s is already disabled.", name)
63+
return nil
64+
}
6165
if err := utils.RunCmd("systemctl", "disable", "--now", name); err != nil {
6266
return utils.Errorf(err, L("failed to disable %s systemd service"), name)
6367
}
@@ -232,6 +236,10 @@ func (s SystemdImpl) StopService(service string) error {
232236

233237
// EnableService enables and starts a systemd service.
234238
func (s SystemdImpl) EnableService(service string) error {
239+
if s.ServiceIsEnabled(service) {
240+
log.Debug().Msgf("%s is already enabled.", service)
241+
return nil
242+
}
235243
if err := utils.RunCmd("systemctl", "enable", "--now", service); err != nil {
236244
return utils.Errorf(err, L("failed to enable %s systemd service"), service)
237245
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- during upgrade, pgsql service needs to be started before healtcheck (bsc#1243402)

0 commit comments

Comments
 (0)