Skip to content
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

disable healthchecks automatically on non systemd systems #16749

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions libpod/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,27 +432,3 @@ func (c *Container) healthCheckStatus() (string, error) {

return results.Status, nil
}

func (c *Container) disableHealthCheckSystemd(isStartup bool) bool {
if os.Getenv("DISABLE_HC_SYSTEMD") == "true" {
return true
}
if isStartup {
if c.config.StartupHealthCheckConfig.Interval == 0 {
return true
}
}
if c.config.HealthCheckConfig.Interval == 0 {
return true
}
return false
}

// Systemd unit name for the healthcheck systemd unit
func (c *Container) hcUnitName(isStartup bool) string {
unitName := c.ID()
if isStartup {
unitName += "-startup"
}
return unitName
}
28 changes: 28 additions & 0 deletions libpod/healthcheck_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build systemd
// +build systemd

package libpod

import (
Expand All @@ -10,6 +13,7 @@ import (
"github.com/containers/podman/v4/pkg/errorhandling"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/systemd"
"github.com/containers/podman/v4/utils"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -132,3 +136,27 @@ func (c *Container) removeTransientFiles(ctx context.Context, isStartup bool) er

return errorhandling.JoinErrors(stopErrors)
}

func (c *Container) disableHealthCheckSystemd(isStartup bool) bool {
if !utils.RunsOnSystemd() || os.Getenv("DISABLE_HC_SYSTEMD") == "true" {
return true
}
if isStartup {
if c.config.StartupHealthCheckConfig.Interval == 0 {
return true
}
}
if c.config.HealthCheckConfig.Interval == 0 {
return true
}
return false
}

// Systemd unit name for the healthcheck systemd unit
func (c *Container) hcUnitName(isStartup bool) string {
unitName := c.ID()
if isStartup {
unitName += "-startup"
}
return unitName
}
24 changes: 24 additions & 0 deletions libpod/healthcheck_nosystemd_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build !systemd
// +build !systemd

package libpod

import (
"context"
)

// createTimer systemd timers for healthchecks of a container
func (c *Container) createTimer(interval string, isStartup bool) error {
return nil
}

// startTimer starts a systemd timer for the healthchecks
func (c *Container) startTimer(isStartup bool) error {
return nil
}

// removeTransientFiles removes the systemd timer and unit files
// for the container
func (c *Container) removeTransientFiles(ctx context.Context, isStartup bool) error {
return nil
}