utils

package
v1.5.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabelsToNode

func AddLabelsToNode(c clientset.Interface, nodeName string, labels map[string]string) error

func DoCleanupNode

func DoCleanupNode(client clientset.Interface, nodeName string, strategy PrepareNodeStrategy) error

func DoPrepareNode

func DoPrepareNode(client clientset.Interface, node *api.Node, strategy PrepareNodeStrategy) error

func FailedContainers added in v1.4.5

func FailedContainers(pod *api.Pod) map[string]ContainerFailures

FailedContainers inspects all containers in a pod and returns failure information for containers that have failed or been restarted. A map is returned where the key is the containerID and the value is a struct containing the restart and failure information

func MakePodSpec

func MakePodSpec() api.PodSpec

func MakeTempDirOrDie

func MakeTempDirOrDie(prefix string, baseDir string) string

func PodNotReady added in v1.4.5

func PodNotReady(p *api.Pod) (bool, error)

PodNotReady checks whether pod p's has a ready condition of status false.

func PodReady added in v1.4.5

func PodReady(pod *api.Pod) bool

podReady returns whether pod has a condition of Ready with a status of true. TODO: should be replaced with api.IsPodReady

func PodRunningReady added in v1.4.5

func PodRunningReady(p *api.Pod) (bool, error)

PodRunningReady checks whether pod p's phase is running and it has a ready condition of status true.

func PodRunningReadyOrSucceeded added in v1.4.5

func PodRunningReadyOrSucceeded(p *api.Pod) (bool, error)

func RemoveLabelOffNode

func RemoveLabelOffNode(c clientset.Interface, nodeName string, labelKeys []string) error

RemoveLabelOffNode is for cleaning up labels temporarily added to node, won't fail if target label doesn't exist or has been removed.

func RunDeployment

func RunDeployment(config DeploymentConfig) error

RunDeployment Launches (and verifies correctness) of a Deployment and will wait for all pods it spawns to become "Running". It's the caller's responsibility to clean up externally (i.e. use the namespace lifecycle for handling Cleanup).

func RunRC

func RunRC(config RCConfig) error

RunRC Launches (and verifies correctness) of a Replication Controller and will wait for all pods it spawns to become "Running". It's the caller's responsibility to clean up externally (i.e. use the namespace lifecycle for handling Cleanup).

func RunReplicaSet

func RunReplicaSet(config ReplicaSetConfig) error

RunReplicaSet launches (and verifies correctness) of a ReplicaSet and waits until all the pods it launches to reach the "Running" state. It's the caller's responsibility to clean up externally (i.e. use the namespace lifecycle for handling Cleanup).

func StartPods

func StartPods(c clientset.Interface, replicas int, namespace string, podNamePrefix string,
	pod api.Pod, waitForRunning bool, logFunc func(fmt string, args ...interface{})) error

Simplified version of RunRC, that does not create RC, but creates plain Pods. Optionally waits for pods to start running (if waitForRunning == true). The number of replicas must be non-zero.

func TerminatedContainers added in v1.4.5

func TerminatedContainers(pod *api.Pod) map[string]string

TerminatedContainers inspects all containers in a pod and returns a map of "container name: termination reason", for all currently terminated containers.

func VerifyLabelsRemoved

func VerifyLabelsRemoved(c clientset.Interface, nodeName string, labelKeys []string) error

VerifyLabelsRemoved checks if Node for given nodeName does not have any of labels from labelKeys. Return non-nil error if it does.

func WaitForPodsWithLabelRunning

func WaitForPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector) error

Wait up to 10 minutes for all matching pods to become Running and at least one matching pod exists.

Types

type ContainerFailures added in v1.4.5

type ContainerFailures struct {
	Restarts int
	// contains filtered or unexported fields
}

type CountToPodStrategy

type CountToPodStrategy struct {
	Count    int
	Strategy TestPodCreateStrategy
}

type CountToStrategy

type CountToStrategy struct {
	Count    int
	Strategy PrepareNodeStrategy
}

type DeploymentConfig

type DeploymentConfig struct {
	RCConfig
}

type LabelNodePrepareStrategy

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

func NewLabelNodePrepareStrategy

func NewLabelNodePrepareStrategy(labelKey string, labelValue string) *LabelNodePrepareStrategy

func (*LabelNodePrepareStrategy) CleanupNode

func (s *LabelNodePrepareStrategy) CleanupNode(node *api.Node) *api.Node

func (*LabelNodePrepareStrategy) PreparePatch

func (s *LabelNodePrepareStrategy) PreparePatch(*api.Node) []byte

type PodDiff

type PodDiff map[string]*podInfo

PodDiff is a map of pod name to podInfos

func Diff

func Diff(oldPods []*api.Pod, curPods []*api.Pod) PodDiff

Diff computes a PodDiff given 2 lists of pods.

func (PodDiff) String

func (p PodDiff) String(ignorePhases sets.String) string

Print formats and prints the give PodDiff.

type PodStore

type PodStore struct {
	cache.Store

	Reflector *cache.Reflector
	// contains filtered or unexported fields
}

Convenient wrapper around cache.Store that returns list of api.Pod instead of interface{}.

func NewPodStore

func NewPodStore(c clientset.Interface, namespace string, label labels.Selector, field fields.Selector) *PodStore

func (*PodStore) List

func (s *PodStore) List() []*api.Pod

func (*PodStore) Stop

func (s *PodStore) Stop()

type PrepareNodeStrategy

type PrepareNodeStrategy interface {
	PreparePatch(node *api.Node) []byte
	CleanupNode(node *api.Node) *api.Node
}

type RCConfig

type RCConfig struct {
	Client         clientset.Interface
	Image          string
	Command        []string
	Name           string
	Namespace      string
	PollInterval   time.Duration
	Timeout        time.Duration
	PodStatusFile  *os.File
	Replicas       int
	CpuRequest     int64 // millicores
	CpuLimit       int64 // millicores
	MemRequest     int64 // bytes
	MemLimit       int64 // bytes
	ReadinessProbe *api.Probe
	DNSPolicy      *api.DNSPolicy

	// Env vars, set the same for every pod.
	Env map[string]string

	// Extra labels added to every pod.
	Labels map[string]string

	// Node selector for pods in the RC.
	NodeSelector map[string]string

	// Ports to declare in the container (map of name to containerPort).
	Ports map[string]int
	// Ports to declare in the container as host and container ports.
	HostPorts map[string]int

	Volumes      []api.Volume
	VolumeMounts []api.VolumeMount

	// Pointer to a list of pods; if non-nil, will be set to a list of pods
	// created by this RC by RunRC.
	CreatedPods *[]*api.Pod

	// Maximum allowable container failures. If exceeded, RunRC returns an error.
	// Defaults to replicas*0.1 if unspecified.
	MaxContainerFailures *int

	// If set to false starting RC will print progress, otherwise only errors will be printed.
	Silent bool

	// If set this function will be used to print log lines instead of glog.
	LogFunc func(fmt string, args ...interface{})
	// If set those functions will be used to gather data from Nodes - in integration tests where no
	// kubelets are running those variables should be nil.
	NodeDumpFunc      func(c clientset.Interface, nodeNames []string, logFunc func(fmt string, args ...interface{}))
	ContainerDumpFunc func(c clientset.Interface, ns string, logFunc func(ftm string, args ...interface{}))
}

func (*RCConfig) RCConfigLog

func (rc *RCConfig) RCConfigLog(fmt string, args ...interface{})

type RCStartupStatus

type RCStartupStatus struct {
	Expected              int
	Terminating           int
	Running               int
	RunningButNotReady    int
	Waiting               int
	Pending               int
	Unknown               int
	Inactive              int
	FailedContainers      int
	Created               []*api.Pod
	ContainerRestartNodes sets.String
}

func ComputeRCStartupStatus

func ComputeRCStartupStatus(pods []*api.Pod, expected int) RCStartupStatus

func (*RCStartupStatus) String

func (s *RCStartupStatus) String(name string) string

type ReplicaSetConfig

type ReplicaSetConfig struct {
	RCConfig
}

type TestNodePreparer

type TestNodePreparer interface {
	PrepareNodes() error
	CleanupNodes() error
}

type TestPodCreateStrategy

type TestPodCreateStrategy func(client clientset.Interface, namespace string, podCount int) error

func NewCustomCreatePodStrategy

func NewCustomCreatePodStrategy(podTemplate *api.Pod) TestPodCreateStrategy

func NewSimpleCreatePodStrategy

func NewSimpleCreatePodStrategy() TestPodCreateStrategy

func NewSimpleWithControllerCreatePodStrategy

func NewSimpleWithControllerCreatePodStrategy(controllerName string) TestPodCreateStrategy

type TestPodCreator

type TestPodCreator struct {
	Client clientset.Interface
	// namespace -> count -> strategy
	Config *TestPodCreatorConfig
}

func NewTestPodCreator

func NewTestPodCreator(client clientset.Interface, config *TestPodCreatorConfig) *TestPodCreator

func (*TestPodCreator) CreatePods

func (c *TestPodCreator) CreatePods() error

type TestPodCreatorConfig

type TestPodCreatorConfig map[string][]CountToPodStrategy

func NewTestPodCreatorConfig

func NewTestPodCreatorConfig() *TestPodCreatorConfig

func (*TestPodCreatorConfig) AddStrategy

func (c *TestPodCreatorConfig) AddStrategy(
	namespace string, podCount int, strategy TestPodCreateStrategy)

type TrivialNodePrepareStrategy

type TrivialNodePrepareStrategy struct{}

func (*TrivialNodePrepareStrategy) CleanupNode

func (*TrivialNodePrepareStrategy) CleanupNode(node *api.Node) *api.Node

func (*TrivialNodePrepareStrategy) PreparePatch

func (*TrivialNodePrepareStrategy) PreparePatch(*api.Node) []byte

Jump to

Keyboard shortcuts

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