deploy

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

View Source
const (
	SocatPort = 9735
)

Variables

View Source
var (
	DeploymentResource = schema.GroupVersionResource{
		Group:    api.SchemeGroupVersion.Group,
		Version:  api.SchemeGroupVersion.Version,
		Resource: "pmemcsideployments",
	}
	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 CheckPMEMDriver added in v0.8.0

func CheckPMEMDriver(c *Cluster, deployment *Deployment)

CheckPMEMDriver does some sanity checks for a running 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.PmemCSIDeployment

func DeploymentToUnstructured

func DeploymentToUnstructured(in *api.PmemCSIDeployment) *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 EnsureDeploymentNow added in v0.8.0

func EnsureDeploymentNow(f *framework.Framework, deployment *Deployment)

EnsureDeploymentNow checks the currently running driver and replaces it if necessary.

func GetDeploymentCR

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

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 LookupCSIAddresses added in v0.8.0

func LookupCSIAddresses(c *Cluster, namespace string) (nodeAddress, controllerAddress string, err error)

LookupCSIAddresses returns controller and node addresses for gRPC dial. Only works for testing deployments.

func RemoveObjects

func RemoveObjects(c *Cluster, deployment *Deployment) 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 WaitForOLM added in v0.8.0

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

WaitForOLM watis till the "olm-operator" Pod in given namspace is ready else fails with exception.

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, d *Deployment) (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 - for testing deployments: TCP CSI endpoints are ready

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, appLabels labels.Set, ip, namespace string) (*v1.Pod, error)

GetAppInstance looks for a pod with certain labels 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 gRPC 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(appLabels labels.Set, 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 {
	// HasDriver is true if the driver itself is running.
	HasDriver bool

	// The CSI driver name that the driver is using. Usually
	// pmem-csi.intel.com.
	DriverName string

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

	// HasOLM is true if the OLM(OperatorLifecycleManager) is running.
	HasOLM bool

	// HasController is true if the controller part with the webhooks is enabled.
	HasController 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

	// A version of the format X.Y when installing an older
	// release from the release-X.Y branch.
	Version string
}

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.

The driver should never restart. A restart would indicate some (potentially intermittent) issue.

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 MustParse added in v0.8.0

func MustParse(deploymentName string) *Deployment

MustParse calls Parse and panics when the name is not valid.

func Parse

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

Parse the deployment name and sets fields accordingly.

func (Deployment) DeleteAllPods added in v0.8.0

func (d Deployment) DeleteAllPods(c *Cluster) error

DeleteAllPods deletes all currently running pods that belong to the deployment.

func (Deployment) DeploymentMode

func (d Deployment) DeploymentMode() string

func (*Deployment) GetDriverDeployment

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

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

func (Deployment) Label added in v0.8.0

func (d Deployment) Label() string

Label returns the label used for objects belonging to the deployment. It's the same as the name minus the version. The reason for not including the version in the label value is that previous releases did not have that either. We have to stay consistent with that for up- and downgrade testing.

func (Deployment) Name

func (d Deployment) Name() string

Name returns a string that encodes all attributes in the format expected by Parse.

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