Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RandomSelector = func(ctx context.Context, groupName string, remain int, inventory *kkcorev1.Inventory) []string { var availableHosts []string groups := inventory.Spec.Groups[groupName] if remain > 0 { ungrouped, ok := variable.ConvertGroup(*inventory)[_const.VariableUnGrouped] if !ok { klog.ErrorS(nil, "Failed to get ungrouped hosts") return nil } shuffleHosts(ungrouped) availableHosts = ungrouped[:remain] groups.Hosts = append(groups.Hosts, availableHosts...) if inventory.Spec.Groups == nil { inventory.Spec.Groups = make(map[string]kkcorev1.InventoryGroup, 0) } inventory.Spec.Groups[groupName] = groups } return availableHosts }
RandomSelector is a HostSelectorFunc that randomly selects hosts for a given group. If the number of requested hosts (groupHostNum) is less than the current number of hosts in the group, it shuffles the current hosts and trims the excess hosts. If the number of requested hosts is greater than the current number of hosts in the group, it adds hosts from the ungrouped hosts to meet the requested number. The function modifies the inventory to reflect the changes in the group hosts.
Returns:
HostSelectorFunc: A function that selects hosts for a group based on the specified criteria.
var SequenceSelector = func(ctx context.Context, groupName string, remain int, inventory *kkcorev1.Inventory) []string { var availableHosts []string groups := inventory.Spec.Groups[groupName] if remain > 0 { ungrouped, ok := variable.ConvertGroup(*inventory)[_const.VariableUnGrouped] if !ok { klog.ErrorS(nil, "Failed to get ungrouped hosts") return availableHosts } availableHosts = ungrouped[:remain] groups.Hosts = append(groups.Hosts, availableHosts...) if inventory.Spec.Groups == nil { inventory.Spec.Groups = make(map[string]kkcorev1.InventoryGroup, 0) } inventory.Spec.Groups[groupName] = groups } return availableHosts }
SequenceSelector is a HostSelectorFunc that adjusts the number of hosts in a specified group within the inventory. If the specified number of hosts (groupHostNum) is less than the current number of hosts in the group, it removes the excess hosts. If the specified number is greater, it adds hosts from the ungrouped hosts to the group.
The returned function takes the following parameters: - ctx: The context for the operation. - groupName: The name of the group to adjust. - groupHostNum: The desired number of hosts in the group. - inventory: The inventory object containing the groups and hosts.
Functions ¶
This section is empty.
Types ¶
type HostSelectorFunc ¶
type HostSelectorFunc = func(ctx context.Context, groupName string, groupHostNum int, inventory *kkcorev1.Inventory) []string
HostSelectorFunc is a type alias for a function that selects and synchronizes hosts from the given inventory.
This function is responsible for ensuring that the number of hosts in a specified group within the inventory matches the desired count provided by the groupHosts parameter.
Parameters: - ctx: The context for managing deadlines, cancelation signals, and other request-scoped values. - groupName: The name of the host group within the inventory to be synchronized. - groupHostNum: The number of hosts in the specified group. - inventory: A pointer to the Inventory object (kkcorev1.Inventory) from which hosts will be selected or synchronized.
type InventoryReconciler ¶
type InventoryReconciler struct { ctrlclient.Client record.EventRecorder }
InventoryReconciler reconciles a Inventory object
func (*InventoryReconciler) Name ¶
func (r *InventoryReconciler) Name() string
Name implements controllers.typeController. Subtle: this method shadows the method (*Scheme).Name of InventoryReconciler.Scheme.
func (*InventoryReconciler) Reconcile ¶
func (r *InventoryReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, retErr error)
Reconcile implements controllers.typeController.
func (*InventoryReconciler) SetupWithManager ¶
func (r *InventoryReconciler) SetupWithManager(mgr manager.Manager, o options.ControllerManagerServerOptions) error
SetupWithManager implements controllers.typeController.
type KKClusterReconciler ¶
type KKClusterReconciler struct { *runtime.Scheme ctrlclient.Client record.EventRecorder }
KKClusterReconciler reconciles a KKCluster object
func (*KKClusterReconciler) Name ¶
func (r *KKClusterReconciler) Name() string
Name implements controllers.controller. Subtle: this method shadows the method (*Scheme).Name of KKClusterReconciler.Scheme.
func (*KKClusterReconciler) SetupWithManager ¶
func (r *KKClusterReconciler) SetupWithManager(mgr manager.Manager, o options.ControllerManagerServerOptions) error
SetupWithManager implements controllers.controller.
type KKClusterWebhook ¶
type KKClusterWebhook struct { }
KKClusterWebhook reconciles a KKCluster object
func (*KKClusterWebhook) Name ¶
func (w *KKClusterWebhook) Name() string
Name implements controllers.Controller.
func (*KKClusterWebhook) SetupWithManager ¶
func (w *KKClusterWebhook) SetupWithManager(mgr ctrl.Manager, o options.ControllerManagerServerOptions) error
type KKMachineReconciler ¶
type KKMachineReconciler struct { ctrlclient.Client record.EventRecorder // contains filtered or unexported fields }
KKMachineReconciler reconciles a KKMachine object. One KKMachine should have one Playbook running in time.
func (*KKMachineReconciler) Name ¶
func (r *KKMachineReconciler) Name() string
Name implements controllers.controller.
func (*KKMachineReconciler) Reconcile ¶
func (r *KKMachineReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, retErr error)
Reconcile implements controllers.controller.
func (*KKMachineReconciler) SetupWithManager ¶
func (r *KKMachineReconciler) SetupWithManager(mgr ctrl.Manager, o options.ControllerManagerServerOptions) error
SetupWithManager implements controllers.controller.