Documentation
¶
Index ¶
- Constants
- Variables
- func AddAllLabels(obj Labelable, labels map[string]string) bool
- func AddLabel(obj Labelable, key string, value string) bool
- func AllLines(line string) *string
- func AppendDebugMoverEnvVar(replicationSourceOrDestObj metav1.Object, envVars []corev1.EnvVar) []corev1.EnvVar
- func AppendEnvVarsForClusterWideProxy(envVars []corev1.EnvVar) []corev1.EnvVar
- func AppendRCloneEnvVars(secret *corev1.Secret, envVars []corev1.EnvVar) []corev1.EnvVar
- func CleanupObjects(ctx context.Context, c client.Client, logger logr.Logger, owner client.Object, ...) error
- func CleanupSnapshotsWithLabelCheck(ctx context.Context, c client.Client, logger logr.Logger, owner client.Object, ...) error
- func ConfigMapHasFields(configMap *corev1.ConfigMap, fields ...string) error
- func CreateOrUpdateDeleteOnImmutableErr(ctx context.Context, k8sClient client.Client, obj client.Object, ...) (ctrlutil.OperationResult, error)
- func EnvFromSecret(secretName string, field string, optional bool) corev1.EnvVar
- func FilterLogs(reader io.Reader, lineFilter func(line string) *string) (string, error)
- func GetAndValidateConfigMap(ctx context.Context, cl client.Client, logger logr.Logger, ...) error
- func GetAndValidateSecret(ctx context.Context, cl client.Client, logger logr.Logger, ...) error
- func GetCopyTriggerValue(pvc *corev1.PersistentVolumeClaim) string
- func GetHashedName(name string) string
- func GetJobName(namePrefix string, owner client.Object) string
- func GetLatestCopyTriggerValue(pvc *corev1.PersistentVolumeClaim) string
- func GetLatestCopyTriggerWaitingSinceValue(pvc *corev1.PersistentVolumeClaim) string
- func GetMoverLogMaxBytes() int
- func GetMoverLogTailLines() int64
- func GetNewestPodForJob(ctx context.Context, logger logr.Logger, jobName, jobNamespace string, ...) (*corev1.Pod, error)
- func GetOwnerNameLabelValue(namePrefix string, owner client.Object) string
- func GetPodsForJob(ctx context.Context, logger logr.Logger, jobName, jobNamespace string) (runningPods []corev1.Pod, successfulPods []corev1.Pod, failedPods []corev1.Pod, ...)
- func GetServiceAddress(svc *corev1.Service) string
- func GetServiceName(namePrefix string, owner client.Object) string
- func HasLabel(obj Labelable, key string) bool
- func HasLabelWithValue(obj Labelable, key string, value string) bool
- func InitPodLogsClient(cfg *rest.Config) (*kubernetes.Clientset, error)
- func IsCRDNotPresentError(err error) bool
- func IsMarkedDoNotDelete(snapshot *snapv1.VolumeSnapshot) bool
- func IsMoverLogDebug() bool
- func IsOwnedByVolsync(obj Labelable) bool
- func IsSnapshot(image *corev1.TypedLocalObjectReference) bool
- func KindAndName(scheme *runtime.Scheme, obj client.Object) string
- func MarkDoNotDelete(snapshot *snapv1.VolumeSnapshot) bool
- func MarkForCleanup(owner metav1.Object, obj metav1.Object) bool
- func MarkOldSnapshotForCleanup(ctx context.Context, c client.Client, logger logr.Logger, owner metav1.Object, ...) error
- func PVCUsesCopyTrigger(pvc *corev1.PersistentVolumeClaim) bool
- func ParseMoverImagePullSecrets(moverImagePullSecrets string) map[string]string
- func PrivilegedMoversOk(ctx context.Context, cl client.Client, logger logr.Logger, namespace string) (bool, error)
- func PvcIsBlockMode(pvc *corev1.PersistentVolumeClaim) bool
- func PvcIsReadOnly(pvc *corev1.PersistentVolumeClaim) bool
- func ReconcileBatch(l logr.Logger, reconcileFuncs ...ReconcileFunc) (bool, error)
- func RelinquishOwnedSnapshotsWithDoNotDeleteLabel(ctx context.Context, c client.Client, logger logr.Logger, owner client.Object) error
- func RemoveLabel(obj Labelable, key string) bool
- func RemoveOwnedByVolSync(obj Labelable) bool
- func RemoveOwnerReference(obj metav1.Object, owner client.Object) bool
- func RemoveSnapOwnershipAndLabelsIfRequestedAndUpdate(ctx context.Context, c client.Client, logger logr.Logger, owner client.Object, ...) (bool, error)
- func SecretHasFields(secret *corev1.Secret, fields ...string) error
- func SetLatestCopyStatusCompleted(pvc *corev1.PersistentVolumeClaim) bool
- func SetLatestCopyStatusInProgress(pvc *corev1.PersistentVolumeClaim) bool
- func SetLatestCopyStatusWaitingForTrigger(pvc *corev1.PersistentVolumeClaim) bool
- func SetLatestCopyTriggerValue(pvc *corev1.PersistentVolumeClaim, value string) bool
- func SetLatestCopyTriggerWaitingSinceValueNow(pvc *corev1.PersistentVolumeClaim) bool
- func SetOwnedByVolSync(obj Labelable) bool
- func TruncateString(s string, maxBytes int) string
- func UnMarkForCleanupAndRemoveOwnership(obj metav1.Object, owner client.Object) bool
- func UnmarkForCleanup(obj metav1.Object) bool
- func UpdateMoverStatusFailed(moverStatus *volsyncv1alpha1.MoverStatus, errMessage string)
- func UpdateMoverStatusForFailedJob(ctx context.Context, logger logr.Logger, ...)
- func UpdateMoverStatusForSuccessfulJob(ctx context.Context, logger logr.Logger, ...)
- func UpdatePodTemplateSpecFromMoverConfig(podTemplateSpec *corev1.PodTemplateSpec, ...)
- type AffinityInfo
- type CustomCAObject
- type CustomCAObjectConfigMap
- type CustomCAObjectSecret
- type Labelable
- type ReconcileFunc
- type SAHandler
- type SAHandlerUserSupplied
- type SAHandlerVolSync
Constants ¶
const ( VolsyncLabelPrefix = "volsync.backube" DoNotDeleteLabelKey = VolsyncLabelPrefix + "/do-not-delete" OwnedByLabelKey = "app.kubernetes.io/created-by" OwnedByLabelValue = "volsync" SnapInUseByVolumePopulatorLabelPrefix = VolsyncLabelPrefix + "/volpop-pvc-" )
const ( // Env var - max bytes we will log into the status log MoverLogMaxBytesEnvVar = "MOVER_LOG_MAX_BYTES" DefaultMoverLogMaxBytes int = 1024 // Env var - max lines we will tail from a mover pod to process logs // Set to -1 to tail all lines since the mover pod start MoverLogTailLinesEnvVar = "MOVER_LOG_TAIL_LINES" DefaultMoverLogTailLines int64 = -1 // Env var - Set to "true" to log all lines (up to MOVER_LOG_MAX_LINES) of mover logs MoverLogDebugEnvVar = "MOVER_LOG_DEBUG" )
const ( ErrUnableToSetControllerRef = "unable to set controller reference" JobNameMaxLength = 63 ServiceNameMaxLength = 63 LabelValueMaxLength = 63 )
Define the error messages to be returned by VolSync.
const DefaultSCCName = "volsync-privileged-mover" // #nosec G101 - gosec thinks this is a credential
DefaultSCCName is the default name of the volsync security context constraint
const VolSyncNamespaceEnvVar = "VOLSYNC_NAMESPACE"
Variables ¶
var MoverImagePullSecrets string
Comma separated list of secrets to be copied from the volsync install namespace (typically volsync-system) to the mover's namespace and use for the mover service account - set via cmd line flag in main.go
var SCCName string
SCCName is the name of the SCC to use for the mover Jobs
Functions ¶
func AddAllLabels ¶
Ensures that all labels in the provided map are present and returns True if an update was made
func AddLabel ¶
Ensures that a given key/value label is present and returns True if an update was made
func AppendDebugMoverEnvVar ¶
func AppendDebugMoverEnvVar(replicationSourceOrDestObj metav1.Object, envVars []corev1.EnvVar) []corev1.EnvVar
Will append the MoverDebug Env var if the volsyncv1alpha1.EnableDebugMoverAnnotation annotation is set on the corresponding ReplicationSource or Destination
func AppendRCloneEnvVars ¶
Append k/v from the secret if they start with RCLONE_
func CleanupObjects ¶
func CleanupObjects(ctx context.Context, c client.Client, logger logr.Logger, owner client.Object, types []client.Object) error
CleanupObjects deletes all objects that have been marked. The objects to be cleaned up must have been previously marked via MarkForCleanup() and associated with "owner". The "types" array should contain one object of each type to clean up.
func ConfigMapHasFields ¶
func CreateOrUpdateDeleteOnImmutableErr ¶
func CreateOrUpdateDeleteOnImmutableErr(ctx context.Context, k8sClient client.Client, obj client.Object, log logr.Logger, f ctrlutil.MutateFn) (ctrlutil.OperationResult, error)
If an update causes an immutable error, delete the object and return an error (or potentially an error from the delete if the delete fails). The caller should ensure (usually via a requeue) that createOrUpdate is called on the resource again in order for it to be recreated.
func EnvFromSecret ¶
func FilterLogs ¶
Appies lineFilter to each line
func GetAndValidateConfigMap ¶
func GetAndValidateSecret ¶
func GetCopyTriggerValue ¶
func GetCopyTriggerValue(pvc *corev1.PersistentVolumeClaim) string
func GetHashedName ¶
func GetJobName ¶
Will return a name with prefix + owner.Name unless it's too long, in which case we will return prefix + owner.UID (This assumes namePrefix + UID is shorter than 63 chars)
func GetLatestCopyTriggerValue ¶
func GetLatestCopyTriggerValue(pvc *corev1.PersistentVolumeClaim) string
func GetLatestCopyTriggerWaitingSinceValue ¶
func GetLatestCopyTriggerWaitingSinceValue(pvc *corev1.PersistentVolumeClaim) string
func GetMoverLogMaxBytes ¶
func GetMoverLogMaxBytes() int
func GetMoverLogTailLines ¶
func GetMoverLogTailLines() int64
func GetNewestPodForJob ¶
func GetNewestPodForJob(ctx context.Context, logger logr.Logger, jobName, jobNamespace string, jobFailed bool) (*corev1.Pod, error)
Attempts to get the newest successful pod when jobFailed==false Attempts to get the newest failed pod (or newest running pod if no failed pods) if jobFailed==true
func GetOwnerNameLabelValue ¶
func GetPodsForJob ¶
func GetServiceAddress ¶
GetServiceAddress Returns the address of the given service as a string.
func GetServiceName ¶
Will return a name with prefix + owner.Name unless it's too long, in which case we will return prefix + owner.UID (This assumes namePrefix + UID is shorter than 63 chars)
func InitPodLogsClient ¶
func InitPodLogsClient(cfg *rest.Config) (*kubernetes.Clientset, error)
func IsCRDNotPresentError ¶
Check if error is due to the CRD not being present (API kind/group not available) This has changed recently in controller-runtime v0.15.0, see: https://github.com/kubernetes-sigs/controller-runtime/pull/2116
func IsMarkedDoNotDelete ¶
func IsMarkedDoNotDelete(snapshot *snapv1.VolumeSnapshot) bool
func IsMoverLogDebug ¶
func IsMoverLogDebug() bool
func IsOwnedByVolsync ¶
Returns True if the object contains a label indicating that it was created by VolSync
func IsSnapshot ¶
func IsSnapshot(image *corev1.TypedLocalObjectReference) bool
func MarkDoNotDelete ¶
func MarkDoNotDelete(snapshot *snapv1.VolumeSnapshot) bool
func MarkForCleanup ¶
MarkForCleanup marks the provided "obj" to be deleted at the end of the synchronization iteration.
func PVCUsesCopyTrigger ¶
func PVCUsesCopyTrigger(pvc *corev1.PersistentVolumeClaim) bool
func PrivilegedMoversOk ¶
func PvcIsBlockMode ¶
func PvcIsBlockMode(pvc *corev1.PersistentVolumeClaim) bool
func PvcIsReadOnly ¶
func PvcIsReadOnly(pvc *corev1.PersistentVolumeClaim) bool
func ReconcileBatch ¶
func ReconcileBatch(l logr.Logger, reconcileFuncs ...ReconcileFunc) (bool, error)
reconcileBatch steps through a list of reconcile functions until one returns false or an error.
func RemoveLabel ¶
Removes the given key from the object's labels and returns True if an update was made
func RemoveOwnedByVolSync ¶
Removes the "created by Volsync" label
func SetLatestCopyStatusCompleted ¶
func SetLatestCopyStatusCompleted(pvc *corev1.PersistentVolumeClaim) bool
Returns true if the pvc was updated
func SetLatestCopyStatusInProgress ¶
func SetLatestCopyStatusInProgress(pvc *corev1.PersistentVolumeClaim) bool
Returns true if the pvc was updated
func SetLatestCopyStatusWaitingForTrigger ¶
func SetLatestCopyStatusWaitingForTrigger(pvc *corev1.PersistentVolumeClaim) bool
Returns true if the pvc was updated
func SetLatestCopyTriggerValue ¶
func SetLatestCopyTriggerValue(pvc *corev1.PersistentVolumeClaim, value string) bool
Returns true if the pvc was updated
func SetLatestCopyTriggerWaitingSinceValueNow ¶
func SetLatestCopyTriggerWaitingSinceValueNow(pvc *corev1.PersistentVolumeClaim) bool
Returns true if the pvc was updated
func SetOwnedByVolSync ¶
Sets a label on the object to indicate it was created by VolSync
func TruncateString ¶
func UnmarkForCleanup ¶
UnmarkForCleanup removes any previously applied cleanup label
func UpdateMoverStatusFailed ¶
func UpdateMoverStatusFailed(moverStatus *volsyncv1alpha1.MoverStatus, errMessage string)
Updates mover status to failed and puts the errMessage as the logs
func UpdateMoverStatusForFailedJob ¶
func UpdateMoverStatusForFailedJob(ctx context.Context, logger logr.Logger, moverStatus *volsyncv1alpha1.MoverStatus, jobName, jobNamespace string, logLineFilter func(string) *string)
func UpdateMoverStatusForSuccessfulJob ¶
func UpdateMoverStatusForSuccessfulJob(ctx context.Context, logger logr.Logger, moverStatus *volsyncv1alpha1.MoverStatus, jobName, jobNamespace string, logLineFilter func(string) *string)
func UpdatePodTemplateSpecFromMoverConfig ¶
func UpdatePodTemplateSpecFromMoverConfig(podTemplateSpec *corev1.PodTemplateSpec, moverConfig volsyncv1alpha1.MoverConfig, defaultMoverResources corev1.ResourceRequirements)
Updates to set the securityContext, podLabels on mover pod in the spec and resourceRequirements on the mover containers based on what is set in the MoverConfig
Types ¶
type AffinityInfo ¶
type AffinityInfo struct { NodeSelector map[string]string Tolerations []corev1.Toleration }
func AffinityFromVolume ¶
func AffinityFromVolume(ctx context.Context, c client.Client, logger logr.Logger, pvc *corev1.PersistentVolumeClaim) (*AffinityInfo, error)
Determine the proper affinity to apply based on the current users of a PVC
type CustomCAObject ¶
type CustomCAObject interface { // path should be the relative path to filename (key contents will get projected here) GetVolumeSource(path string) corev1.VolumeSource }
CustomCAObject will generate the appropriate volumesource for attaching to a podspec from a source customca secret or configmap. Use ValidateCustomCA() to validate a CustomCASpec and return a CustomCAObject.
func ValidateCustomCA ¶
func ValidateCustomCA(ctx context.Context, cl client.Client, l logr.Logger, namespace string, customCA volsyncv1alpha1.CustomCASpec) (CustomCAObject, error)
type CustomCAObjectConfigMap ¶
type CustomCAObjectConfigMap struct {
// contains filtered or unexported fields
}
func (*CustomCAObjectConfigMap) GetVolumeSource ¶
func (c *CustomCAObjectConfigMap) GetVolumeSource(path string) corev1.VolumeSource
type CustomCAObjectSecret ¶
type CustomCAObjectSecret struct {
// contains filtered or unexported fields
}
func (*CustomCAObjectSecret) GetVolumeSource ¶
func (c *CustomCAObjectSecret) GetVolumeSource(path string) corev1.VolumeSource
type ReconcileFunc ¶
reconcileFunc is a function that partially reconciles an object. It returns a bool indicating whether reconciling should continue and an error.
type SAHandler ¶
type SAHandlerUserSupplied ¶
type SAHandlerUserSupplied struct { Client client.Client SA *corev1.ServiceAccount }
func (*SAHandlerUserSupplied) Reconcile ¶
func (d *SAHandlerUserSupplied) Reconcile(ctx context.Context, l logr.Logger) (*corev1.ServiceAccount, error)
type SAHandlerVolSync ¶
type SAHandlerVolSync struct { Context context.Context Client client.Client SA *corev1.ServiceAccount Owner metav1.Object Privileged bool PullSecretsMap map[string]string VolSyncNamespace string // contains filtered or unexported fields }
func (*SAHandlerVolSync) Reconcile ¶
func (d *SAHandlerVolSync) Reconcile(ctx context.Context, l logr.Logger) (*corev1.ServiceAccount, error)