deploy

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 44 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 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.

They are placed inside a "Deploy" node because:

  • The order of specs inside a node is not randomized by default, which is what we want, in contrast to the top-level nodes, which always get randomized (https://github.com/onsi/ginkgo/issues/966#issuecomment-1110046593).
  • It is easier to focus on specific tests with, for example, "Deploy operator". "^operator" does not work because the internal test name string has some builtin, hidden string at the beginning (something like "top level").

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 one after the after with the given "describe" string.

An empty deployment is valid. Those tests will run after the ones which use deployments. Their callback is passed a nil Deployment.

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 GetMetrics added in v1.0.0

func GetMetrics(ctx context.Context, c *Cluster, url string) (map[string]*cm.MetricFamily, error)

GetMetricsPortForward retrieves metrics from given metricsURL by Pod's container port forwarding. The metricsURL could be retrieved using deploy.GetMetricsURL() and must be in the form of 'scheme://pod_namespace.pod_name:container_port/metric_endpoint>'.

func GetMetricsURLs added in v1.0.0

func GetMetricsURLs(ctx context.Context, c *Cluster, namespace string, podLabels labels.Set) ([]string, error)

GetMetricsURLs retrieves the metrics URLs provided by all pods that match with the label set passed in podLabelSet.

func GetOperatorMetrics added in v1.0.0

func GetOperatorMetrics(ctx context.Context, cluster *Cluster, d *Deployment) (map[string]*cm.MetricFamily, error)

func GetOperatorMetricsURL added in v1.0.0

func GetOperatorMetricsURL(ctx context.Context, cluster *Cluster, d *Deployment) (string, error)

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(ctx context.Context, c *Cluster, namespace string) (nodeAddress, controllerAddress string, err error)

LookupCSIAddresses returns controller and node addresses for pod/dial.go (<namespace>.<pod>:<port>). 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 ResetPMEM added in v1.0.0

func ResetPMEM(ctx context.Context, node string) error

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 StopOperator added in v1.0.0

func StopOperator(d *Deployment) error

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, controllerReplicas int32) (metricsURLs []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, cfg *rest.Config) (*Cluster, error)

func (*Cluster) ClientSet

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

func (*Cluster) Config added in v1.0.0

func (c *Cluster) Config() *rest.Config

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) StorageCapacitySupported added in v1.0.0

func (c *Cluster) StorageCapacitySupported() bool

StorageCapacitySupported checks that the v1beta1 CSIStorageCapacity API is supported. It only checks the Kubernetes version.

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(c *Cluster) 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.

func (Deployment) ParseVersion added in v1.1.0

func (d Deployment) ParseVersion() version.Version

type InstallHook

type InstallHook func(Deployment *Deployment)

InstallHook is the callback function for AddInstallHook.

type Namespace added in v1.0.0

type Namespace struct {
	Mode string `json:"mode"`
}

type NdctlOutput added in v1.0.0

type NdctlOutput struct {
	Regions []Region `json:"regions"`
}

func ParseNdctlOutput added in v1.0.0

func ParseNdctlOutput(out []byte) (NdctlOutput, error)

type Region added in v1.0.0

type Region struct {
	Size          int64       `json:"size"`
	AvailableSize int64       `json:"available_size"`
	Namespaces    []Namespace `json:"namespaces"`
}

type UninstallHook

type UninstallHook func(deploymentName string)

UninstallHook is the callback function for AddUninstallHook.

type Volumes added in v1.0.0

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

func GetHostVolumes

func GetHostVolumes(d *Deployment) Volumes

GetHostVolumes list all volumes (LVM and namespaces) on all nodes.

func (Volumes) CheckForLeaks added in v1.0.0

func (v Volumes) CheckForLeaks()

CheckForLeftovers lists volumes again after test, diff means leftovers.

Jump to

Keyboard shortcuts

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