Allow libcontainerd to build properly on FreeBSD

This includes some changes where the libcontainer code is simply running the
same stubs that it would have previously been running on Solaris

Signed-off-by: R Tyler Croy <tyler@monkeypox.org>
This commit is contained in:
R Tyler Croy 2017-08-15 09:34:31 +08:00
parent c3c988bc0a
commit ed1efb503d
6 changed files with 153 additions and 2 deletions

View File

@ -0,0 +1,104 @@
package libcontainerd
import (
"golang.org/x/net/context"
containerd "github.com/docker/containerd/api/grpc/types"
)
type client struct {
clientCommon
// Platform specific properties below here.
remote *remote
q queue
exitNotifiers map[string]*exitNotifier
liveRestore bool
}
// GetServerVersion returns the connected server version information
func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
if err != nil {
return nil, err
}
sv := &ServerVersion{
GetServerVersionResponse: *resp,
}
return sv, nil
}
func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process, attachStdio StdioCallback) (int, error) {
return -1, nil
}
func (clnt *client) SignalProcess(containerID string, pid string, sig int) error {
return nil
}
func (clnt *client) Resize(containerID, processFriendlyName string, width, height int) error {
return nil
}
func (clnt *client) Pause(containerID string) error {
return nil
}
func (clnt *client) Resume(containerID string) error {
return nil
}
func (clnt *client) Stats(containerID string) (*Stats, error) {
return nil, nil
}
func (clnt *client) getExitNotifier(containerID string) *exitNotifier {
clnt.mapMutex.RLock()
defer clnt.mapMutex.RUnlock()
return clnt.exitNotifiers[containerID]
}
func (clnt *client) getOrCreateExitNotifier(containerID string) *exitNotifier {
clnt.mapMutex.Lock()
defer clnt.mapMutex.Unlock()
w, ok := clnt.exitNotifiers[containerID]
if !ok {
w = &exitNotifier{c: make(chan struct{}), client: clnt}
clnt.exitNotifiers[containerID] = w
}
return w
}
// Restore is the handler for restoring a container
func (clnt *client) Restore(containerID string, attachStdio StdioCallback, options ...CreateOption) error {
return nil
}
func (clnt *client) GetPidsForContainer(containerID string) ([]int, error) {
return nil, nil
}
// Summary returns a summary of the processes running in a container.
func (clnt *client) Summary(containerID string) ([]Summary, error) {
return nil, nil
}
// UpdateResources updates resources for a running container.
func (clnt *client) UpdateResources(containerID string, resources Resources) error {
// Updating resource isn't supported on Solaris
// but we should return nil for enabling updating container
return nil
}
func (clnt *client) CreateCheckpoint(containerID string, checkpointID string, checkpointDir string, exit bool) error {
return nil
}
func (clnt *client) DeleteCheckpoint(containerID string, checkpointID string, checkpointDir string) error {
return nil
}
func (clnt *client) ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error) {
return nil, nil
}

View File

@ -1,3 +1,5 @@
// +build solaris,freebsd +build !linux
package libcontainerd
func setOOMScore(pid, score int) error {

View File

@ -1,4 +1,4 @@
// +build linux solaris
// +build linux solaris freebsd
package libcontainerd

View File

@ -1,4 +1,4 @@
// +build linux solaris
// +build linux solaris freebsd
package libcontainerd

View File

@ -0,0 +1,43 @@
package libcontainerd
import (
containerd "github.com/docker/containerd/api/grpc/types"
"github.com/opencontainers/runtime-spec/specs-go"
)
// Process contains information to start a specific application inside the container.
type Process struct {
// Terminal creates an interactive terminal for the container.
Terminal bool `json:"terminal"`
// User specifies user information for the process.
User *specs.User `json:"user"`
// Args specifies the binary and arguments for the application to execute.
Args []string `json:"args"`
// Env populates the process environment for the process.
Env []string `json:"env,omitempty"`
// Cwd is the current working directory for the process and must be
// relative to the container's root.
Cwd *string `json:"cwd"`
// Capabilities are linux capabilities that are kept for the container.
Capabilities []string `json:"capabilities,omitempty"`
}
// Stats contains a stats properties from containerd.
type Stats struct{}
// Summary contains a container summary from containerd
type Summary struct{}
// StateInfo contains description about the new state container has entered.
type StateInfo struct {
CommonStateInfo
// Platform specific StateInfo
OOMKilled bool
}
// Resources defines updatable container resource values.
type Resources struct{}
// Checkpoints contains the details of a checkpoint
type Checkpoints containerd.ListCheckpointResponse

View File

@ -1,3 +1,5 @@
// +build solaris,freebsd +build !linux
package libcontainerd
import (