server

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 40 Imported by: 0

README

Running podman E2E tests locally

You can find tests in server_podman_test.go. Test framework allows you to safely test itzo (with podman runtime) locally. It should massively speed up development, as it means that you no longer need to spin up whole cluster + kip + actual VM with itzo.
Before running those you need to:

  1. Ensure that podman.socket is open for superuser by running sudo systemctl start podman.socket (this will create socket in /run/podman/podman.socket)
  2. Ensure that sudo podman pod ps doesn't return itzpod - that's a constant that we use for pod created by itzo.
  3. Executing of those test may take longer as they're E2E; using podman API we create, run, stop and remove pods and containers here. All podman resources should be removed after each test by removeContainersAndPods function.

Those tests don't run by default. To run them, you need to set podman flag to true, e.g.: sudo go test ./pkg/server/ -v -args -podman=true. You need to run it as superuser, because itzo expects podman socket in /run/podman/podman.socket (for now it isn't configurable)

Documentation

Index

Constants

View Source
const (
	UpdateTypeNoChanges       = "no_changes"
	UpdateTypePodRestart      = "pod_restart"
	UpdateTypePodCreate       = "pod_created"
	UpdateTypeUnitsChange     = "units_changed"
	UseOverlayfsAnnotationKey = "pod.elotl.co/image-overlay-rootfs"
)
View Source
const (
	MULTIPART_PACKAGE = "package"
	ITZO_DIR          = "/tmp/itzo"
	CERTS_DIR         = ITZO_DIR
	DEFAULT_ROOTDIR   = ITZO_DIR + "/units"
	ITZO_VERSION      = "1.0"
	FILE_BYTES_LIMIT  = 4096
)

Variables

This section is empty.

Functions

func DeployPackage

func DeployPackage(filename, rootdir, pkgname string) (err error)

func KillChildren added in v1.2.0

func KillChildren()

This will ensure all the helper processes and their children get terminated before the main process exits.

func MergeSecretsIntoSpec

func MergeSecretsIntoSpec(secrets map[string]map[string][]byte, units []api.Unit)

Modifies the PodSpec and inserts secrets into the spec

Types

type EnvStore

type EnvStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A 2d map protected by a mutex.

func (*EnvStore) Add

func (e *EnvStore) Add(unit, key, value string)

func (*EnvStore) Delete

func (e *EnvStore) Delete(unit, key string)

func (*EnvStore) Get

func (e *EnvStore) Get(unit, key string) (value string, exists bool)

func (*EnvStore) Items

func (e *EnvStore) Items(unit string) [][2]string
type Link struct {
	// contains filtered or unexported fields
}

type ParameterError

type ParameterError struct {
	// contains filtered or unexported fields
}

Some kind of invalid input from the user. Useful here to decide when to return a 4xx vs a 5xx.

func (*ParameterError) Error

func (pe *ParameterError) Error() string

type PodController

type PodController struct {
	// contains filtered or unexported fields
}

I know how to do one thing: Make Controllers. A ton of controllers...

func NewPodController

func NewPodController(rootdir string, runtimeName string) (*PodController, error)

func (*PodController) CreatePod added in v1.2.0

func (pc *PodController) CreatePod(spec *api.PodSpec) error

func (*PodController) GetLogBuffer added in v1.2.0

func (pc *PodController) GetLogBuffer(options runtime.LogOptions) (*logbuf.LogBuffer, error)

TODO

func (*PodController) GetPid added in v1.2.0

func (pc *PodController) GetPid(unitName string) (int, bool)

func (*PodController) GetStatus

func (pc *PodController) GetStatus() ([]api.UnitStatus, []api.UnitStatus, error)

func (*PodController) GetUnitName

func (pc *PodController) GetUnitName(unitName string) (string, error)

func (*PodController) ReadSystemMetrics added in v1.2.0

func (pc *PodController) ReadSystemMetrics(ifname string) api.ResourceMetrics

Metrics

These methods are just passthrough to the underlying runtime implementation

func (*PodController) ReadUnitMetrics added in v1.2.0

func (pc *PodController) ReadUnitMetrics(ifname string) api.ResourceMetrics

func (*PodController) RestartPod added in v1.2.0

func (pc *PodController) RestartPod(spec, status *api.PodSpec) error

returns: units to start, init units to start

func (*PodController) RestartUnits added in v1.2.0

func (pc *PodController) RestartUnits(spec, status *api.PodSpec) ([]api.Unit, error)

func (*PodController) SetPodNetwork

func (pc *PodController) SetPodNetwork(netNS, podIP string)

func (*PodController) Start

func (pc *PodController) Start()

func (*PodController) SyncPodUnits

func (pc *PodController) SyncPodUnits(spec *api.PodSpec, status *api.PodSpec, allCreds map[string]api.RegistryCredentials) string

func (*PodController) UnitRunning added in v1.2.0

func (pc *PodController) UnitRunning(unit string) bool

func (*PodController) UpdatePod

func (pc *PodController) UpdatePod(params *api.PodParameters) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(rootdir string, runtime string) *Server

func NewTestServer added in v1.2.0

func NewTestServer(store EnvStore, rootdir string, podCtl *PodController) Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string, disableTLS bool)

func (*Server) RunLogTailer

func (s *Server) RunLogTailer(w http.ResponseWriter, r *http.Request, unitName string, withMetadata bool, logBuffer *logbuf.LogBuffer)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL