cmd/podman/system: add API server support on FreeBSD

This adds the 'system service' command to the build on FreeBSD and
suppresses the call to servicereaper.Start which is only needed to
support slirp4netns on Linux. A stub for compat.StatsContainer is also
added - stats are still supported via the libpod.StatsContainer API
call.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
Doug Rabson
2022-11-15 15:02:05 +00:00
parent 8ff12e09f0
commit e3f2a97d1f
6 changed files with 41 additions and 6 deletions

View File

@ -1,5 +1,6 @@
//go:build linux && !remote
// +build linux,!remote
//go:build (linux || freebsd) && !remote
// +build linux freebsd
// +build !remote
package system

View File

@ -1,5 +1,6 @@
//go:build linux && !remote
// +build linux,!remote
//go:build (linux || freebsd) && !remote
// +build linux freebsd
// +build !remote
package system
@ -12,7 +13,6 @@ import (
"path/filepath"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/servicereaper"
"github.com/containers/podman/v4/cmd/podman/registry"
api "github.com/containers/podman/v4/pkg/api/server"
"github.com/containers/podman/v4/pkg/domain/entities"
@ -119,7 +119,7 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities
logrus.Debugf("Could not move to subcgroup: %v", err)
}
servicereaper.Start()
maybeStartServiceReaper()
infra.StartWatcher(libpodRuntime)
server, err := api.NewServerWithSettings(libpodRuntime, listener, opts)
if err != nil {

View File

@ -0,0 +1,7 @@
//go:build !linux && !remote
package system
// Currently, we only need servicereaper on Linux to support slirp4netns.
func maybeStartServiceReaper() {
}

View File

@ -0,0 +1,12 @@
//go:build linux && !remote
package system
import (
"github.com/containers/common/pkg/servicereaper"
)
// Currently, we only need servicereaper on Linux to support slirp4netns.
func maybeStartServiceReaper() {
servicereaper.Start()
}

View File

@ -0,0 +1,15 @@
package compat
import (
"fmt"
"net/http"
"time"
"github.com/containers/podman/v4/pkg/api/handlers/utils"
)
const DefaultStatsPeriod = 5 * time.Second
func StatsContainer(w http.ResponseWriter, r *http.Request) {
utils.Error(w, http.StatusBadRequest, fmt.Errorf("compat.StatsContainer not supported on FreeBSD"))
}