Documentation ¶
Index ¶
- Constants
- Variables
- func AddControllerMetricsTransportWrapper(cfg *rest.Config, controllerName string, remote bool)
- func AddFinalizer(object metav1.Object, finalizer string)
- func AddTypeMeta(objects []runtime.RawExtension, scheme *runtime.Scheme) ([]runtime.RawExtension, error)
- func BuildClusterAPIClientFromKubeconfig(kubeconfigData, controllerName string) (client.Client, error)
- func BuildDynamicClientFromKubeconfig(kubeconfigData, controllerName string) (dynamic.Interface, error)
- func CalculateJobSpecHash(job *batchv1.Job) (string, error)
- func DNSZoneName(cdName string) string
- func DeleteFinalizer(object metav1.Object, finalizer string)
- func FindClusterDeploymentCondition(conditions []hivev1.ClusterDeploymentCondition, ...) *hivev1.ClusterDeploymentCondition
- func FindClusterProvisionCondition(conditions []hivev1.ClusterProvisionCondition, ...) *hivev1.ClusterProvisionCondition
- func FindDNSZoneCondition(conditions []hivev1.DNSZoneCondition, ...) *hivev1.DNSZoneCondition
- func FindSyncCondition(conditions []hivev1.SyncCondition, conditionType hivev1.SyncConditionType) *hivev1.SyncCondition
- func FixupKubeconfig(data []byte) ([]byte, error)
- func FixupKubeconfigSecretData(data map[string][]byte) ([]byte, error)
- func GetChecksumOfObject(object interface{}) (string, error)
- func GetChecksumOfObjects(objects ...interface{}) (string, error)
- func GetConcurrentReconciles() int
- func GetKubeClient(scheme *runtime.Scheme) (client.Client, error)
- func HasFinalizer(object metav1.Object, finalizer string) bool
- func HasUnreachableCondition(cd *hivev1.ClusterDeployment) bool
- func IsFailed(job *batchv1.Job) bool
- func IsFinished(job *batchv1.Job) bool
- func IsSuccessful(job *batchv1.Job) bool
- func LoadSecretData(c client.Client, secretName, namespace, dataKey string) (string, error)
- func LogLevel(err error) log.Level
- func MergeJsons(globalPullSecret string, localPullSecret string, cdLog log.FieldLogger) (string, error)
- func NewClientWithMetricsOrDie(mgr manager.Manager, ctrlrName string) client.Client
- func SetClusterDeploymentCondition(conditions []hivev1.ClusterDeploymentCondition, ...) []hivev1.ClusterDeploymentCondition
- func SetClusterDeploymentConditionWithChangeCheck(conditions []hivev1.ClusterDeploymentCondition, ...) ([]hivev1.ClusterDeploymentCondition, bool)
- func SetClusterProvisionCondition(conditions []hivev1.ClusterProvisionCondition, ...) []hivev1.ClusterProvisionCondition
- func SetDNSZoneCondition(conditions []hivev1.DNSZoneCondition, ...) []hivev1.DNSZoneCondition
- func SetSyncCondition(conditions []hivev1.SyncCondition, conditionType hivev1.SyncConditionType, ...) []hivev1.SyncCondition
- func SetupAdditionalCA() error
- func SetupClusterInstallServiceAccount(c client.Client, namespace string, logger log.FieldLogger) error
- func UpdateConditionAlways(_, _, _, _ string) bool
- func UpdateConditionIfReasonOrMessageChange(oldReason, oldMessage, newReason, newMessage string) bool
- func UpdateConditionNever(_, _, _, _ string) bool
- func WrapEventHandlerWithLogging(eventHandler handler.EventHandler, logger log.FieldLogger) handler.EventHandler
- type ControlleeExpectations
- type ControllerMetricsTripper
- type Expectations
- func (r *Expectations) CreationObserved(controllerKey string)
- func (r *Expectations) DeleteExpectations(controllerKey string)
- func (r *Expectations) DeletionObserved(controllerKey string)
- func (r *Expectations) ExpectCreations(controllerKey string, adds int) error
- func (r *Expectations) ExpectDeletions(controllerKey string, dels int) error
- func (r *Expectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
- func (r *Expectations) LowerExpectations(controllerKey string, add, del int)
- func (r *Expectations) RaiseExpectations(controllerKey string, add, del int)
- func (r *Expectations) SatisfiedExpectations(controllerKey string) bool
- func (r *Expectations) SetExpectations(controllerKey string, add, del int) error
- type ExpectationsInterface
- type UpdateConditionCheck
Constants ¶
const ( // ExpectationsTimeout defines the length of time that a dormant // controller will wait for an expectation to be satisfied. It is // specifically targeted at the case where some problem prevents an update // of expectations, without it the controller could stay asleep forever. This should // be set based on the expected latency of watch events. ExpectationsTimeout = 5 * time.Minute )
const ( // ServiceAccountName will be a service account that can run the installer and then // upload artifacts to the cluster's namespace. ServiceAccountName = "cluster-installer" )
Variables ¶
var ExpKeyFunc = func(obj interface{}) (string, error) { if e, ok := obj.(*ControlleeExpectations); ok { return e.key, nil } return "", fmt.Errorf("Could not find key for obj %#v", obj) }
ExpKeyFunc to parse out the key from a ControlleeExpectation
Functions ¶
func AddControllerMetricsTransportWrapper ¶
AddControllerMetricsTransportWrapper adds a transport wrapper to the given rest config which exposes metrics based on the requests being made.
func AddFinalizer ¶
AddFinalizer adds a finalizer to the given object
func AddTypeMeta ¶
func AddTypeMeta(objects []runtime.RawExtension, scheme *runtime.Scheme) ([]runtime.RawExtension, error)
AddTypeMeta adds type metadata to objects in a list of RawExtension TypeMeta is needed for proper serialization/deserialization
func BuildClusterAPIClientFromKubeconfig ¶
func BuildClusterAPIClientFromKubeconfig(kubeconfigData, controllerName string) (client.Client, error)
BuildClusterAPIClientFromKubeconfig will return a kubeclient with metrics using the provided kubeconfig. Controller name is required for metrics purposes.
func BuildDynamicClientFromKubeconfig ¶
func BuildDynamicClientFromKubeconfig(kubeconfigData, controllerName string) (dynamic.Interface, error)
BuildDynamicClientFromKubeconfig returns a dynamic client with metrics, using the provided kubeconfig. Controller name is required for metrics purposes.
func CalculateJobSpecHash ¶
CalculateJobSpecHash returns a hash of the job.Spec.
func DNSZoneName ¶
DNSZoneName returns the predictable name for a DNSZone for the given ClusterDeployment.
func DeleteFinalizer ¶
DeleteFinalizer removes a finalizer from the given object
func FindClusterDeploymentCondition ¶
func FindClusterDeploymentCondition(conditions []hivev1.ClusterDeploymentCondition, conditionType hivev1.ClusterDeploymentConditionType) *hivev1.ClusterDeploymentCondition
FindClusterDeploymentCondition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil.
func FindClusterProvisionCondition ¶
func FindClusterProvisionCondition(conditions []hivev1.ClusterProvisionCondition, conditionType hivev1.ClusterProvisionConditionType) *hivev1.ClusterProvisionCondition
FindClusterProvisionCondition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil.
func FindDNSZoneCondition ¶
func FindDNSZoneCondition(conditions []hivev1.DNSZoneCondition, conditionType hivev1.DNSZoneConditionType) *hivev1.DNSZoneCondition
FindDNSZoneCondition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil.
func FindSyncCondition ¶
func FindSyncCondition(conditions []hivev1.SyncCondition, conditionType hivev1.SyncConditionType) *hivev1.SyncCondition
FindSyncCondition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil.
func FixupKubeconfig ¶
FixupKubeconfig adds additional certificate authorities to a given kubeconfig
func FixupKubeconfigSecretData ¶
FixupKubeconfigSecretData adds additional certificate authorities to the kubeconfig in the argument data map. It first looks for the raw secret key. If not found, it uses the default kubeconfig key.
func GetChecksumOfObject ¶
GetChecksumOfObject returns the md5sum hash of the object passed in.
func GetChecksumOfObjects ¶
GetChecksumOfObjects returns the md5sum hash of the objects passed in.
func GetConcurrentReconciles ¶
func GetConcurrentReconciles() int
GetConcurrentReconciles returns the number of goroutines each controller should use for parallel processing of their queue. For now this is a static value of 5. In future this may be read from an env var set by the operator, and driven by HiveConfig.
func GetKubeClient ¶
GetKubeClient creates a new Kubernetes dynamic client.
func HasFinalizer ¶
HasFinalizer returns true if the given object has the given finalizer
func HasUnreachableCondition ¶
func HasUnreachableCondition(cd *hivev1.ClusterDeployment) bool
HasUnreachableCondition returns true if the cluster deployment has the unreachable condition set to true.
func IsFinished ¶
IsFinished returns true if the job completed (succeeded or failed)
func IsSuccessful ¶
IsSuccessful returns true if the job was successful
func LoadSecretData ¶
LoadSecretData loads a given secret key and returns it's data as a string.
func MergeJsons ¶
func MergeJsons(globalPullSecret string, localPullSecret string, cdLog log.FieldLogger) (string, error)
MergeJsons will merge the global and local pull secret and return it
func NewClientWithMetricsOrDie ¶
NewClientWithMetricsOrDie creates a new controller-runtime client with a wrapper which increments metrics for requests by controller name, HTTP method, URL path, and whether or not the request was to a remote cluster.. The client will re-use the managers cache. This should be used in all Hive controllers.
func SetClusterDeploymentCondition ¶
func SetClusterDeploymentCondition( conditions []hivev1.ClusterDeploymentCondition, conditionType hivev1.ClusterDeploymentConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) []hivev1.ClusterDeploymentCondition
SetClusterDeploymentCondition sets a condition on a ClusterDeployment resource's status
func SetClusterDeploymentConditionWithChangeCheck ¶
func SetClusterDeploymentConditionWithChangeCheck( conditions []hivev1.ClusterDeploymentCondition, conditionType hivev1.ClusterDeploymentConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) ([]hivev1.ClusterDeploymentCondition, bool)
SetClusterDeploymentConditionWithChangeCheck sets a condition on a ClusterDeployment resource's status. It returns the conditions as well a boolean indicating whether there was a change made to the conditions.
func SetClusterProvisionCondition ¶
func SetClusterProvisionCondition( conditions []hivev1.ClusterProvisionCondition, conditionType hivev1.ClusterProvisionConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) []hivev1.ClusterProvisionCondition
SetClusterProvisionCondition sets a condition on a ClusterProvision resource's status
func SetDNSZoneCondition ¶
func SetDNSZoneCondition( conditions []hivev1.DNSZoneCondition, conditionType hivev1.DNSZoneConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) []hivev1.DNSZoneCondition
SetDNSZoneCondition sets a condition on a DNSZone resource's status
func SetSyncCondition ¶
func SetSyncCondition( conditions []hivev1.SyncCondition, conditionType hivev1.SyncConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) []hivev1.SyncCondition
SetSyncCondition sets a condition on a SyncSet or resource's status
func SetupAdditionalCA ¶
func SetupAdditionalCA() error
SetupAdditionalCA reads a file referenced by the ADDITIONAL_CA environment variable that contains an additional CA. This should only be called once on initialization
func SetupClusterInstallServiceAccount ¶
func SetupClusterInstallServiceAccount(c client.Client, namespace string, logger log.FieldLogger) error
SetupClusterInstallServiceAccount ensures a service account exists which can upload the required artifacts after running the installer in a pod. (metadata, admin kubeconfig)
func UpdateConditionAlways ¶
UpdateConditionAlways returns true. The condition will always be updated.
func UpdateConditionIfReasonOrMessageChange ¶
func UpdateConditionIfReasonOrMessageChange(oldReason, oldMessage, newReason, newMessage string) bool
UpdateConditionIfReasonOrMessageChange returns true if there is a change in the reason or the message of the condition.
func UpdateConditionNever ¶
UpdateConditionNever return false. The condition will never be updated, unless there is a change in the status of the condition.
func WrapEventHandlerWithLogging ¶
func WrapEventHandlerWithLogging(eventHandler handler.EventHandler, logger log.FieldLogger) handler.EventHandler
WrapEventHandlerWithLogging wraps the specified event handler inside a new event handler that will log when events are handled and items are added to the queue.
Types ¶
type ControlleeExpectations ¶
type ControlleeExpectations struct {
// contains filtered or unexported fields
}
ControlleeExpectations track controllee creates/deletes.
func (*ControlleeExpectations) Add ¶
func (e *ControlleeExpectations) Add(add, del int64)
Add increments the add and del counters.
func (*ControlleeExpectations) Fulfilled ¶
func (e *ControlleeExpectations) Fulfilled() bool
Fulfilled returns true if this expectation has been fulfilled.
func (*ControlleeExpectations) GetExpectations ¶
func (e *ControlleeExpectations) GetExpectations() (int64, int64)
GetExpectations returns the add and del expectations of the controllee.
type ControllerMetricsTripper ¶
type ControllerMetricsTripper struct { http.RoundTripper Controller string Remote bool }
ControllerMetricsTripper is a RoundTripper implementation which tracks our metrics for client requests.
type Expectations ¶
Expectations is a cache mapping controllers to what they expect to see before being woken up for a sync.
func NewExpectations ¶
func NewExpectations(logger log.FieldLogger) *Expectations
NewExpectations returns a store for Expectations.
func (*Expectations) CreationObserved ¶
func (r *Expectations) CreationObserved(controllerKey string)
CreationObserved atomically decrements the `add` expectation count of the given controller.
func (*Expectations) DeleteExpectations ¶
func (r *Expectations) DeleteExpectations(controllerKey string)
DeleteExpectations deletes the expectations of the given controller from the TTLStore.
func (*Expectations) DeletionObserved ¶
func (r *Expectations) DeletionObserved(controllerKey string)
DeletionObserved atomically decrements the `del` expectation count of the given controller.
func (*Expectations) ExpectCreations ¶
func (r *Expectations) ExpectCreations(controllerKey string, adds int) error
ExpectCreations sets the expectations to expect the specified number of additions for the controller with the specified key.
func (*Expectations) ExpectDeletions ¶
func (r *Expectations) ExpectDeletions(controllerKey string, dels int) error
ExpectDeletions sets the expectations to expect the specified number of deletions for the controller with the specified key.
func (*Expectations) GetExpectations ¶
func (r *Expectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
GetExpectations returns the ControlleeExpectations of the given controller.
func (*Expectations) LowerExpectations ¶
func (r *Expectations) LowerExpectations(controllerKey string, add, del int)
LowerExpectations decrements the expectation counts of the given controller.
func (*Expectations) RaiseExpectations ¶
func (r *Expectations) RaiseExpectations(controllerKey string, add, del int)
RaiseExpectations increments the expectation counts of the given controller.
func (*Expectations) SatisfiedExpectations ¶
func (r *Expectations) SatisfiedExpectations(controllerKey string) bool
SatisfiedExpectations returns true if the required adds/dels for the given controller have been observed. Add/del counts are established by the controller at sync time, and updated as controllees are observed by the controller manager.
func (*Expectations) SetExpectations ¶
func (r *Expectations) SetExpectations(controllerKey string, add, del int) error
SetExpectations registers new expectations for the given controller. Forgets existing expectations.
type ExpectationsInterface ¶
type ExpectationsInterface interface { GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error) SatisfiedExpectations(controllerKey string) bool DeleteExpectations(controllerKey string) SetExpectations(controllerKey string, add, del int) error ExpectCreations(controllerKey string, adds int) error ExpectDeletions(controllerKey string, dels int) error CreationObserved(controllerKey string) DeletionObserved(controllerKey string) RaiseExpectations(controllerKey string, add, del int) LowerExpectations(controllerKey string, add, del int) }
ExpectationsInterface is an interface that allows users to set and wait on expectations. Only abstracted out for testing. Warning: if using KeyFunc it is not safe to use a single ExpectationsInterface with different types of controllers, because the keys might conflict across types.
type UpdateConditionCheck ¶
UpdateConditionCheck tests whether a condition should be updated from the old condition to the new condition. Returns true if the condition should be updated.