Skip to content
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
8 changes: 8 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in

[func GetVolumes(args: []string, all: bool) Volume](#GetVolumes)

[func HealthCheckRun(nameOrID: string) string](#HealthCheckRun)

[func HistoryImage(name: string) ImageHistory](#HistoryImage)

[func ImageExists(name: string) int](#ImageExists)
Expand Down Expand Up @@ -681,6 +683,12 @@ GetVersion returns version and build information of the podman service

method GetVolumes(args: [[]string](#[]string), all: [bool](https://godoc.org/builtin#bool)) [Volume](#Volume)</div>
GetVolumes gets slice of the volumes on a remote host
### <a name="HealthCheckRun"></a>func HealthCheckRun
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">

method HealthCheckRun(nameOrID: [string](https://godoc.org/builtin#string)) [string](https://godoc.org/builtin#string)</div>
HealthCheckRun executes defined container's healthcheck command
and returns the container's health status.
### <a name="HistoryImage"></a>func HistoryImage
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">

Expand Down
7 changes: 0 additions & 7 deletions cmd/podman/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,3 @@ func getSystemSubCommands() []*cobra.Command {
_migrateCommand,
}
}

// Commands that the local client implements
func getHealthcheckSubCommands() []*cobra.Command {
return []*cobra.Command{
_healthcheckrunCommand,
}
}
5 changes: 0 additions & 5 deletions cmd/podman/commands_remoteclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,3 @@ func getTrustSubCommands() []*cobra.Command {
func getSystemSubCommands() []*cobra.Command {
return []*cobra.Command{}
}

// Commands that the remoteclient implements
func getHealthcheckSubCommands() []*cobra.Command {
return []*cobra.Command{}
}
5 changes: 3 additions & 2 deletions cmd/podman/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ var healthcheckCommand = cliconfig.PodmanCommand{
}

// Commands that are universally implemented
var healthcheckCommands []*cobra.Command
var healthcheckCommands = []*cobra.Command{
_healthcheckrunCommand,
}

func init() {
healthcheckCommand.AddCommand(healthcheckCommands...)
healthcheckCommand.AddCommand(getHealthcheckSubCommands()...)
healthcheckCommand.SetUsageTemplate(UsageTemplate())
rootCmd.AddCommand(healthcheckCommand.Command)
}
4 changes: 4 additions & 0 deletions cmd/podman/varlink/io.podman.varlink
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ method GetContainersByStatus(status: []string) -> (containerS: []Container)

method Top (nameOrID: string, descriptors: []string) -> (top: []string)

# HealthCheckRun executes defined container's healthcheck command
# and returns the container's health status.
method HealthCheckRun (nameOrID: string) -> (healthCheckStatus: string)

# GetContainer returns information about a single container. If a container
# with the given id doesn't exist, a [ContainerNotFound](#ContainerNotFound)
# error will be returned. See also [ListContainers](ListContainers) and
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/runtime_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/containers/image/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/remoteclientconfig"
"github.com/containers/libpod/cmd/podman/varlink"
iopodman "github.com/containers/libpod/cmd/podman/varlink"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/events"
Expand Down Expand Up @@ -812,7 +812,7 @@ func IsImageNotFound(err error) bool {

// HealthCheck executes a container's healthcheck over a varlink connection
func (r *LocalRuntime) HealthCheck(c *cliconfig.HealthCheckValues) (string, error) {
return "", define.ErrNotImplemented
return iopodman.HealthCheckRun().Call(r.Conn, c.InputArgs[0])
}

// Events monitors libpod/podman events over a varlink connection
Expand Down
15 changes: 14 additions & 1 deletion pkg/varlinkapi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/cmd/podman/varlink"
iopodman "github.com/containers/libpod/cmd/podman/varlink"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/logs"
Expand Down Expand Up @@ -864,3 +864,16 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO

return ecErr.Error
}

//HealthCheckRun executes defined container's healthcheck command and returns the container's health status.
func (i *LibpodAPI) HealthCheckRun(call iopodman.VarlinkCall, nameOrID string) error {
hcStatus, err := i.Runtime.HealthCheck(nameOrID)
if err != nil && hcStatus != libpod.HealthCheckFailure {
return call.ReplyErrorOccurred(err.Error())
}
status := libpod.HealthCheckUnhealthy
if hcStatus == libpod.HealthCheckSuccess {
status = libpod.HealthCheckHealthy
}
return call.ReplyHealthCheckRun(status)
}
2 changes: 0 additions & 2 deletions test/e2e/healthcheck_run_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build !remoteclient

package integration

import (
Expand Down