Documentation ¶
Index ¶
- Constants
- func ContainsAlreadyExistsSubstring(err error) bool
- func ContainsNoMatchSubstring(err error) bool
- func GenerateAffinityGroupName(csm infrav1.CloudStackMachine, capiMachine *clusterv1.Machine, ...) (string, error)
- func GetManagementOwnerRef(capiMachine *clusterv1.Machine) *meta.OwnerReference
- func GetOwnerOfKind(ctx context.Context, c clientPkg.Client, owned clientPkg.Object, ...) error
- func IsOwnerDeleted(ctx context.Context, client clientPkg.Client, capiMachine *clusterv1.Machine) (bool, error)
- func WithClusterSuffix(name string, clusterName string) string
- type CloudClientExtension
- type CloudClientImplementation
- type CloudStackBaseContext
- type CloudStackReconcilerMethod
- type ConcreteRunner
- type ReconcilerBase
- type ReconciliationRunner
- func (r *ReconciliationRunner) CheckIfPaused() (ctrl.Result, error)
- func (r *ReconciliationRunner) CheckOwnedCRDsForReadiness(gvks ...schema.GroupVersionKind) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) CheckOwnedObjectsDeleted(gvks ...schema.GroupVersionKind) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) CheckPresent(objs map[string]client.Object) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) CreateFailureDomain(fdSpec infrav1.CloudStackFailureDomainSpec) error
- func (r *ReconciliationRunner) CreateFailureDomains(fdSpecs []infrav1.CloudStackFailureDomainSpec) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) DeleteOwnedObjects(gvks ...schema.GroupVersionKind) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) Else(fn CloudStackReconcilerMethod) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) ForRequest(req ctrl.Request) *ReconciliationRunner
- func (r *ReconciliationRunner) GenerateIsolatedNetwork(name string, fdNameFunc func() string) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetCAPICluster() (ctrl.Result, error)
- func (r *ReconciliationRunner) GetCSCluster() (ctrl.Result, error)
- func (r *ReconciliationRunner) GetFailureDomainByName(nameFunc func() string, fd *infrav1.CloudStackFailureDomain) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetFailureDomains(fds *infrav1.CloudStackFailureDomainList) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetFailureDomainsAndRequeueIfMissing(fds *infrav1.CloudStackFailureDomainList) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetObjectByName(name string, target client.Object, nameGetter ...func() string) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetOrCreateAffinityGroup(name string, affinityType string, ag *infrav1.CloudStackAffinityGroup, ...) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetOwnerOfKind(owner client.Object) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetParent(child client.Object, parent client.Object) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) GetReconciliationSubject() (res ctrl.Result, reterr error)
- func (r *ReconciliationRunner) IsoNetMetaName(name string) string
- func (r *ReconciliationRunner) LogReconciliationSubject() (ctrl.Result, error)
- func (r *ReconciliationRunner) NewChildObjectMeta(name string) metav1.ObjectMeta
- func (r *ReconciliationRunner) PatchChangesBackToAPI() (res ctrl.Result, retErr error)
- func (r *ReconciliationRunner) RemoveExtraneousFailureDomains(fds *infrav1.CloudStackFailureDomainList) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) RequeueIfCloudStackClusterNotReady() (ctrl.Result, error)
- func (r *ReconciliationRunner) RequeueIfMissingBaseCRs() (ctrl.Result, error)
- func (r *ReconciliationRunner) RequeueWithMessage(msg string, keysAndValues ...interface{}) (ctrl.Result, error)
- func (r *ReconciliationRunner) ReturnWrappedError(err error, msg string) (ctrl.Result, error)
- func (r *ReconciliationRunner) RunBaseReconciliationStages() (res ctrl.Result, retErr error)
- func (r *ReconciliationRunner) RunIf(conditional func() bool, fn CloudStackReconcilerMethod) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) RunReconciliationStages(fns ...CloudStackReconcilerMethod) (ctrl.Result, error)
- func (r *ReconciliationRunner) SetReconciliationSubjectToConcreteSubject(subject client.Object) CloudStackReconcilerMethod
- func (r *ReconciliationRunner) SetReturnEarly()
- func (r *ReconciliationRunner) SetupLogger() (res ctrl.Result, retErr error)
- func (r *ReconciliationRunner) SetupPatcher() (res ctrl.Result, retErr error)
- func (r *ReconciliationRunner) ShouldReturn(rslt ctrl.Result, err error) bool
- func (r *ReconciliationRunner) UsingBaseReconciler(base ReconcilerBase) *ReconciliationRunner
- func (r *ReconciliationRunner) WithAdditionalCommonStages(fns ...CloudStackReconcilerMethod) *ReconciliationRunner
- func (r *ReconciliationRunner) WithRequestCtx(ctx context.Context) *ReconciliationRunner
Constants ¶
const DestoryVMRequeueInterval = 10 * time.Second
const RequeueTimeout = 5 * time.Second
Variables ¶
This section is empty.
Functions ¶
func GenerateAffinityGroupName ¶
func GenerateAffinityGroupName(csm infrav1.CloudStackMachine, capiMachine *clusterv1.Machine, capiCluster *clusterv1.Cluster) (string, error)
The computed affinity group name relevant to this machine.
func GetManagementOwnerRef ¶
func GetManagementOwnerRef(capiMachine *clusterv1.Machine) *meta.OwnerReference
GetManagementOwnerRef returns the reference object pointing to the CAPI machine's manager.
func GetOwnerOfKind ¶
func GetOwnerOfKind(ctx context.Context, c clientPkg.Client, owned clientPkg.Object, owner clientPkg.Object) error
GetOwnerOfKind returns the Cluster object owning the current resource of passed kind.
func IsOwnerDeleted ¶
func IsOwnerDeleted(ctx context.Context, client clientPkg.Client, capiMachine *clusterv1.Machine) (bool, error)
IsOwnerDeleted returns a boolean if the owner of the CAPI machine has been deleted.
func WithClusterSuffix ¶
WithClusterSuffix appends a hyphen and the cluster name to a name if not already present.
Types ¶
type CloudClientExtension ¶
type CloudClientExtension interface { RegisterExtension(*ReconciliationRunner) CloudClientExtension AsFailureDomainUser(*infrav1.CloudStackFailureDomainSpec) CloudStackReconcilerMethod }
type CloudClientImplementation ¶
type CloudClientImplementation struct { CloudClientExtension *ReconciliationRunner }
func (*CloudClientImplementation) AsFailureDomainUser ¶
func (c *CloudClientImplementation) AsFailureDomainUser(fdSpec *infrav1.CloudStackFailureDomainSpec) CloudStackReconcilerMethod
AsFailureDomainUser uses the credentials specified in the failure domain to set the ReconciliationSubject's CSUser client.
func (*CloudClientImplementation) RegisterExtension ¶
func (c *CloudClientImplementation) RegisterExtension(r *ReconciliationRunner) CloudClientExtension
type CloudStackBaseContext ¶
type CloudStackBaseContext struct { Log logr.Logger RequestCtx context.Context Request ctrl.Request CAPICluster *clusterv1.Cluster CSCluster *infrav1.CloudStackCluster Patcher *patch.Helper }
CloudStackBaseContext is the base CloudStack data structure created/copied for each reconciliation request to avoid concurrent member access.
type CloudStackReconcilerMethod ¶
CloudStackReconcilerMethod is the method type used in RunReconciliationStages. Additional arguments can be added by wrapping this type in another function affectively currying them.
type ConcreteRunner ¶
type ReconcilerBase ¶
type ReconcilerBase struct { BaseLogger logr.Logger Scheme *runtime.Scheme K8sClient client.Client CSClient cloud.Client Recorder record.EventRecorder CloudClientExtension }
ReconcilerBase is the base set of components we use in k8s reconcilers. These are items that are not copied for each reconciliation request, and must be written to with caution.
func (*ReconcilerBase) InitFromMgr ¶
func (r *ReconcilerBase) InitFromMgr(mgr ctrl.Manager, client cloud.Client)
InitFromMgr just initiates a ReconcilerBase using given manager's fields/methods.
type ReconciliationRunner ¶
type ReconciliationRunner struct { *ReconcilerBase CloudClientExtension CloudStackBaseContext ReconciliationSubject client.Object // Underlying crd interface. ConditionalResult bool // Stores a conidtinal result for stringing if else type methods. ReconcileDelete CloudStackReconcilerMethod Reconcile CloudStackReconcilerMethod CSUser cloud.Client ControllerKind string // contains filtered or unexported fields }
ReconciliationRunner is the base structure used to run reconciliation methods and implements several.
func NewRunner ¶
func NewRunner(concreteRunner ConcreteRunner, subject client.Object, kind string) *ReconciliationRunner
NewRunner creates a new ReconciliationRunner pointing to the concrete reconciliation subject.
func (*ReconciliationRunner) CheckIfPaused ¶
func (r *ReconciliationRunner) CheckIfPaused() (ctrl.Result, error)
CheckIfPaused returns with requeue later set if paused.
func (*ReconciliationRunner) CheckOwnedCRDsForReadiness ¶
func (r *ReconciliationRunner) CheckOwnedCRDsForReadiness(gvks ...schema.GroupVersionKind) CloudStackReconcilerMethod
CheckOwnedCRDsForReadiness queries for the readiness of CRDs of GroupVersionKind passed.
func (*ReconciliationRunner) CheckOwnedObjectsDeleted ¶
func (r *ReconciliationRunner) CheckOwnedObjectsDeleted(gvks ...schema.GroupVersionKind) CloudStackReconcilerMethod
CheckOwnedObjectsDeleted queries for the presence of owned objects and requeues if any are still present. Primarily used to prevent deletions of owners before dependents.
func (*ReconciliationRunner) CheckPresent ¶
func (r *ReconciliationRunner) CheckPresent(objs map[string]client.Object) CloudStackReconcilerMethod
CheckPresent checks that each object given was fetched.
func (*ReconciliationRunner) CreateFailureDomain ¶
func (r *ReconciliationRunner) CreateFailureDomain(fdSpec infrav1.CloudStackFailureDomainSpec) error
CreateFailureDomain creates a specified CloudStackFailureDomain CRD owned by the ReconcilationSubject.
func (*ReconciliationRunner) CreateFailureDomains ¶
func (r *ReconciliationRunner) CreateFailureDomains(fdSpecs []infrav1.CloudStackFailureDomainSpec) CloudStackReconcilerMethod
CreateFailureDomains creates a CloudStackFailureDomain CRD for each of the ReconcilationSubject's FailureDomains.
func (*ReconciliationRunner) DeleteOwnedObjects ¶
func (r *ReconciliationRunner) DeleteOwnedObjects(gvks ...schema.GroupVersionKind) CloudStackReconcilerMethod
CheckOwnedObjectsDeleted queries for the presence of owned objects and requeues if any are still present. Primarily used to prevent deletions of owners before dependents.
func (*ReconciliationRunner) Else ¶
func (r *ReconciliationRunner) Else(fn CloudStackReconcilerMethod) CloudStackReconcilerMethod
Else can be used to run a different stage if a previous conditional was false.
func (*ReconciliationRunner) ForRequest ¶
func (r *ReconciliationRunner) ForRequest(req ctrl.Request) *ReconciliationRunner
ForRequest sets the reconciliation request.
func (*ReconciliationRunner) GenerateIsolatedNetwork ¶
func (r *ReconciliationRunner) GenerateIsolatedNetwork(name string, fdNameFunc func() string) CloudStackReconcilerMethod
GenerateIsolatedNetwork of the passed name that's owned by the ReconciliationSubject.
func (*ReconciliationRunner) GetCAPICluster ¶
func (r *ReconciliationRunner) GetCAPICluster() (ctrl.Result, error)
GetCAPICluster gets the CAPI cluster the reconciliation subject belongs to.
func (*ReconciliationRunner) GetCSCluster ¶
func (r *ReconciliationRunner) GetCSCluster() (ctrl.Result, error)
GetCSCluster gets the CAPI cluster the reconciliation subject belongs to.
func (*ReconciliationRunner) GetFailureDomainByName ¶
func (r *ReconciliationRunner) GetFailureDomainByName(nameFunc func() string, fd *infrav1.CloudStackFailureDomain) CloudStackReconcilerMethod
GetFailureDomainByName gets a single FailureDomain by name and requeues if it's not found.
func (*ReconciliationRunner) GetFailureDomains ¶
func (r *ReconciliationRunner) GetFailureDomains(fds *infrav1.CloudStackFailureDomainList) CloudStackReconcilerMethod
GetFailureDomains gets CloudStackFailureDomains owned by a CloudStackCluster.
func (*ReconciliationRunner) GetFailureDomainsAndRequeueIfMissing ¶
func (r *ReconciliationRunner) GetFailureDomainsAndRequeueIfMissing(fds *infrav1.CloudStackFailureDomainList) CloudStackReconcilerMethod
GetFailureDomainsAndRequeueIfMissing gets CloudStackFailureDomains owned by a CloudStackCluster and requeues if none are found.
func (*ReconciliationRunner) GetObjectByName ¶
func (r *ReconciliationRunner) GetObjectByName(name string, target client.Object, nameGetter ...func() string) CloudStackReconcilerMethod
GetObjectByName gets an object by name and type of object. The namespace is assumed to be the same as the ReconciliationSubject. Not found is not considered an error. Check the object after.
func (*ReconciliationRunner) GetOrCreateAffinityGroup ¶
func (r *ReconciliationRunner) GetOrCreateAffinityGroup( name string, affinityType string, ag *infrav1.CloudStackAffinityGroup, fd *infrav1.CloudStackFailureDomain) CloudStackReconcilerMethod
GetOrCreateAffinityGroup of the passed name that's owned by the failure domain of the reconciliation subject and the control plane that manages it.
func (*ReconciliationRunner) GetOwnerOfKind ¶
func (r *ReconciliationRunner) GetOwnerOfKind(owner client.Object) CloudStackReconcilerMethod
GetOwnerOfKind uses the ReconciliationSubject's owner references to get the owner object of kind passed.
func (*ReconciliationRunner) GetParent ¶
func (r *ReconciliationRunner) GetParent(child client.Object, parent client.Object) CloudStackReconcilerMethod
GetParent returns the object owning the current resource of passed kind.
func (*ReconciliationRunner) GetReconciliationSubject ¶
func (r *ReconciliationRunner) GetReconciliationSubject() (res ctrl.Result, reterr error)
GetReconcilationSubject gets the reconciliation subject of type defined by the concrete reconciler. It also sets up a patch helper at this point.
func (*ReconciliationRunner) IsoNetMetaName ¶
func (r *ReconciliationRunner) IsoNetMetaName(name string) string
func (*ReconciliationRunner) LogReconciliationSubject ¶
func (r *ReconciliationRunner) LogReconciliationSubject() (ctrl.Result, error)
func (*ReconciliationRunner) NewChildObjectMeta ¶
func (r *ReconciliationRunner) NewChildObjectMeta(name string) metav1.ObjectMeta
NewChildObjectMeta creates a meta object with ownership reference and labels matching the current cluster.
func (*ReconciliationRunner) PatchChangesBackToAPI ¶
func (r *ReconciliationRunner) PatchChangesBackToAPI() (res ctrl.Result, retErr error)
PatchChangesBackToAPI patches changes to the ReconciliationSubject back to the appropriate API.
func (*ReconciliationRunner) RemoveExtraneousFailureDomains ¶
func (r *ReconciliationRunner) RemoveExtraneousFailureDomains(fds *infrav1.CloudStackFailureDomainList) CloudStackReconcilerMethod
RemoveExtraneousFailureDomains deletes failure domains no longer listed under the CloudStackCluster's spec.
func (*ReconciliationRunner) RequeueIfCloudStackClusterNotReady ¶
func (r *ReconciliationRunner) RequeueIfCloudStackClusterNotReady() (ctrl.Result, error)
RequeueIfCloudStackClusterNotReady requeues the reconciliation request if the CloudStackCluster is not ready.
func (*ReconciliationRunner) RequeueIfMissingBaseCRs ¶
func (r *ReconciliationRunner) RequeueIfMissingBaseCRs() (ctrl.Result, error)
RequeueIfMissingBaseCRs checks that the ReconciliationSubject, CAPI Cluster, and CloudStackCluster objects were actually fetched and reques if not. The base reconciliation stages will continue even if not so as to allow deletion.
func (*ReconciliationRunner) RequeueWithMessage ¶
func (r *ReconciliationRunner) RequeueWithMessage(msg string, keysAndValues ...interface{}) (ctrl.Result, error)
RequeueWithMessage is a convenience method to log requeue message and then return a result with RequeueAfter set.
func (*ReconciliationRunner) ReturnWrappedError ¶
ReturnWrappedError is a convenience method to log requeue message and then return a result with RequeueAfter set.
func (*ReconciliationRunner) RunBaseReconciliationStages ¶
func (r *ReconciliationRunner) RunBaseReconciliationStages() (res ctrl.Result, retErr error)
RunBaseReconciliationStages runs the base reconciliation stages which are to setup the logger, get the reconciliation subject, get CAPI and CloudStackClusters, and call either r.Reconcile or r.ReconcileDelete.
func (*ReconciliationRunner) RunIf ¶
func (r *ReconciliationRunner) RunIf(conditional func() bool, fn CloudStackReconcilerMethod) CloudStackReconcilerMethod
RunIf accepts a conditional method and CloudStackReconcilerMethod and runs the CloudStackBaseContext if the conditional method is true.
func (*ReconciliationRunner) RunReconciliationStages ¶
func (r *ReconciliationRunner) RunReconciliationStages(fns ...CloudStackReconcilerMethod) (ctrl.Result, error)
RunReconciliationStages runs CloudStackReconcilerMethods in order and exits if an error or requeue condition is set. On exit patches changes back to API.
func (*ReconciliationRunner) SetReconciliationSubjectToConcreteSubject ¶
func (r *ReconciliationRunner) SetReconciliationSubjectToConcreteSubject(subject client.Object) CloudStackReconcilerMethod
SetReconciliationSubjectToConcreteSubject sets reconciliation subject to passed concrete object.
func (*ReconciliationRunner) SetReturnEarly ¶
func (r *ReconciliationRunner) SetReturnEarly()
SetReturnEarly sets the runner to return early. This causes the runner to break from running further reconciliation stages and return whatever result the current method returns.
func (*ReconciliationRunner) SetupLogger ¶
func (r *ReconciliationRunner) SetupLogger() (res ctrl.Result, retErr error)
SetupLogger sets up the reconciler's logger to log with name and namespace values.
func (*ReconciliationRunner) SetupPatcher ¶
func (r *ReconciliationRunner) SetupPatcher() (res ctrl.Result, retErr error)
SetupPatcher initializes the patcher with the ReconciliationSubject. This must be done before changes to the ReconciliationSubject for changes to be patched back later.
func (*ReconciliationRunner) ShouldReturn ¶
func (r *ReconciliationRunner) ShouldReturn(rslt ctrl.Result, err error) bool
RunReconciliationStage runs a CloudStackReconcilerMethod and returns a boolean to indicate whether that stage would have returned a result that cuts the process short or not.
func (*ReconciliationRunner) UsingBaseReconciler ¶
func (r *ReconciliationRunner) UsingBaseReconciler(base ReconcilerBase) *ReconciliationRunner
UsingBaseReconciler sets up the reconciler to use base reconciler data and either default or alternative feature implementations.
func (*ReconciliationRunner) WithAdditionalCommonStages ¶
func (r *ReconciliationRunner) WithAdditionalCommonStages(fns ...CloudStackReconcilerMethod) *ReconciliationRunner
WithAdditionalCommonStages adds reconciliation stages to the base set of reconciliation stages ran before both Reconcile() and ReconcileDelete().
func (*ReconciliationRunner) WithRequestCtx ¶
func (r *ReconciliationRunner) WithRequestCtx(ctx context.Context) *ReconciliationRunner
WithRequestCtx sets the request context.