deploy

package
v0.7.24 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package deploy contains code which provides information about the cluster and deploying PMEM-CSI inside it.

Index

Constants

This section is empty.

Variables

View Source
var (
	DeploymentResource = schema.GroupVersionResource{
		Group:    api.SchemeGroupVersion.Group,
		Version:  api.SchemeGroupVersion.Version,
		Resource: "deployments",
	}
	Scheme = runtime.NewScheme()
)

Functions

func AddInstallHook

func AddInstallHook(h InstallHook)

AddInstallHook registers a callback which is invoked after a successful driver installation.

func AddUninstallHook

func AddUninstallHook(h UninstallHook)

AddUninstallHook registers a callback which is invoked before a driver removal.

func CheckForLeftoverVolumes

func CheckForLeftoverVolumes(d *Deployment, volBefore map[string][]string)

CheckForLeftovers lists volumes again after test, diff means leftovers.

func CheckPMEM

func CheckPMEM()

CheckPMEM ensures that a test does not permanently use more than half of the available PMEM in each region. We want that to ensure that tests in direct mode still have space to work with.

Volume leaks (in direct mode) or allocating all space for a volume group (in LVM mode) trigger this check.

func CreateDeploymentCR

func CreateDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment

func DefineTests

func DefineTests()

DefineTests must be called to register all tests defined so far via Describe.

func DeleteDeploymentCR

func DeleteDeploymentCR(f *framework.Framework, name string)

func DeploymentFromUnstructured

func DeploymentFromUnstructured(in *unstructured.Unstructured) *api.Deployment

func DeploymentToUnstructured

func DeploymentToUnstructured(in *api.Deployment) *unstructured.Unstructured

func Describe

func Describe(deployment, describe, what string, f func(d *Deployment)) bool

Describe remembers a certain test. The actual registration in Ginkgo happens in DefineTests, ordered such that all tests with the same "deployment" string are defined on after the after with the given "describe" string.

When "describe" is already unique, "what" can be left empty.

func DescribeForAll

func DescribeForAll(what string, f func(d *Deployment)) bool

DescribeForAll registers tests like gomega.Describe does, except that each test will then be invoked for each supported PMEM-CSI deployment which has a functional PMEM-CSI driver.

func DescribeForSome

func DescribeForSome(what string, enabled func(d *Deployment) bool, f func(d *Deployment)) bool

DescribeForSome registers tests like gomega.Describe does, except that each test will then be invoked for those PMEM-CSI deployments which pass the filter function.

func EnsureDeploymentCR

func EnsureDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment

func GetDeploymentCR

func GetDeploymentCR(f *framework.Framework, name string) api.Deployment

func GetHostVolumes

func GetHostVolumes(d *Deployment) map[string][]string

Register list of volumes before test, using out-of-band host commands (i.e. not CSI API).

func HasDriver

func HasDriver(d *Deployment) bool

HasDriver is a filter function for DescribeForSome.

func HasOperator

func HasOperator(d *Deployment) bool

HasOperator is a filter function for DescribeForSome.

func LogError

func LogError(err error, format string, args ...interface{})

LogError will log the message only if err is non-nil. The error must also be part of the arguments if it is to be included in the message.

func RemoveObjects

func RemoveObjects(c *Cluster, deploymentName string) error

RemoveObjects deletes everything that might have been created for a PMEM-CSI driver or operator installation (pods, daemonsets, statefulsets, driver info, storage classes, etc.).

func RunAllTests

func RunAllTests(d *Deployment) bool

RunAllTests is a filter function for DescribeForSome which decides against what we run the full Kubernetes storage test suite. Currently do this for deployments created via .yaml files whereas testing with the operator is excluded. This is meant to keep overall test suite runtime reasonable and avoid duplication.

func UpdateDeploymentCR

func UpdateDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment

func WaitForOperator

func WaitForOperator(c *Cluster, namespace string) *v1.Pod

WaitForOperator ensures that the PMEM-CSI operator is ready for use, which is currently defined as the operator pod in Running phase.

func WaitForPMEMDriver

func WaitForPMEMDriver(c *Cluster, name, namespace string) (metricsURL string)

WaitForPMEMDriver ensures that the PMEM-CSI driver is ready for use, which is defined as: - controller service is up and running - all nodes have registered

Types

type Cluster

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

func NewCluster

func NewCluster(cs kubernetes.Interface, dc dynamic.Interface) (*Cluster, error)

func (*Cluster) ClientSet

func (c *Cluster) ClientSet() kubernetes.Interface

func (*Cluster) GetAppInstance

func (c *Cluster) GetAppInstance(ctx context.Context, app, ip, namespace string) (*v1.Pod, error)

GetAppInstance looks for a pod with a certain app label and a specific host or pod IP. The IP may also be empty.

func (*Cluster) GetDaemonSet

func (c *Cluster) GetDaemonSet(ctx context.Context, setName, namespace string) (*appsv1.DaemonSet, error)

func (*Cluster) GetServicePort

func (c *Cluster) GetServicePort(ctx context.Context, serviceName, namespace string) (int, error)

GetServicePort looks up the node port of a service.

func (*Cluster) GetStatefulSet

func (c *Cluster) GetStatefulSet(ctx context.Context, setName, namespace string) (*appsv1.StatefulSet, error)

func (*Cluster) NodeIP

func (c *Cluster) NodeIP(node int) string

NodeIP returns the IP address of a certain node.

func (*Cluster) NodeServiceAddress

func (c *Cluster) NodeServiceAddress(node int, port int) string

NodeServiceAddress returns the dial address for a certain port on a certain nodes.

func (*Cluster) NumNodes

func (c *Cluster) NumNodes() int

NumNodes returns the total number of nodes in the cluster. Node #0 is the master node, the rest are workers.

func (*Cluster) WaitForAppInstance

func (c *Cluster) WaitForAppInstance(app, ip, namespace string) *v1.Pod

WaitForAppInstance waits for a running pod which matches the app label, optional host or pod IP, and namespace.

func (*Cluster) WaitForDaemonSet

func (c *Cluster) WaitForDaemonSet(setName, namespace string) *appsv1.DaemonSet

func (*Cluster) WaitForServicePort

func (c *Cluster) WaitForServicePort(serviceName, namespace string) int

WaitForServicePort waits for the service to appear and returns its ports.

type Deployment

type Deployment struct {
	// Name string that all objects from the same deployment must
	// have in the DeploymentLabel.
	Name string

	// HasDriver is true if the driver itself is running. The
	// driver is reacting to the usual pmem-csi.intel.com driver
	// name.
	HasDriver bool

	// HasOperator is true if the operator is running.
	HasOperator bool

	// Mode is the driver mode of the deployment.
	Mode api.DeviceMode

	// Namespace where the namespaced objects of the deployment
	// were created.
	Namespace string

	// Testing is true when socat pods are available.
	Testing bool
}

Deployment contains some information about a some deployed PMEM-CSI component(s). Those components can be a full driver installation and/or just the operator.

func EnsureDeployment

func EnsureDeployment(deploymentName string) *Deployment

EnsureDeployment registers a BeforeEach function which will ensure that when a test runs, the desired deployment exists. Deployed drivers are intentionally kept running to speed up the execution of multiple tests that all want the same kind of deployment.

func FindDeployment

func FindDeployment(c *Cluster) (*Deployment, error)

FindDeployment checks whether there is a PMEM-CSI driver and/or operator deployment in the cluster. A deployment is found via its deployment resp. statefulset object, which must have a pmem-csi.intel.com/deployment label.

func Parse

func Parse(deploymentName string) (*Deployment, error)

Parse the deployment name and sets fields accordingly.

func (Deployment) DeploymentMode

func (d Deployment) DeploymentMode() string

func (*Deployment) GetDriverDeployment

func (d *Deployment) GetDriverDeployment() api.Deployment

GetDriverDeployment returns the spec for the driver deployment that is used for deployments like operator-lvm-production.

type InstallHook

type InstallHook func(Deployment *Deployment)

InstallHook is the callback function for AddInstallHook.

type UninstallHook

type UninstallHook func(deploymentName string)

UninstallHook is the callback function for AddUninstallHook.

Jump to

Keyboard shortcuts

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