Skip to content

Commit fd24ec7

Browse files
committed
Removed comments in the controller pdb functions
1 parent 892d37f commit fd24ec7

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

controllers/humiocluster_controller.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,14 +2386,12 @@ func shouldCreatePDBForNodePool(hnp *HumioNodePool) bool {
23862386
func (r *HumioClusterReconciler) reconcilePodDisruptionBudgets(ctx context.Context, humioNodePools HumioNodePoolList) (ctrl.Result, error) {
23872387
r.Log.Info("reconciling pod disruption budgets")
23882388

2389-
// Handle PDBs for all node pools (including the default pool from NodeCount)
23902389
for _, pool := range humioNodePools.Items {
23912390
if err := r.reconcileSinglePDB(ctx, pool); err != nil {
23922391
return ctrl.Result{}, fmt.Errorf("failed to reconcile PDB for node pool %s: %w", pool.GetNodePoolName(), err)
23932392
}
23942393
}
23952394

2396-
// Clean up any orphaned PDBs
23972395
if err := r.cleanupOrphanedPDBs(ctx, humioNodePools); err != nil {
23982396
return ctrl.Result{}, fmt.Errorf("failed to cleanup orphaned PDBs: %w", err)
23992397
}
@@ -2410,7 +2408,6 @@ func (r *HumioClusterReconciler) reconcileSinglePDB(ctx context.Context, pool *H
24102408
return nil
24112409
}
24122410

2413-
// Check if pods exist for this node pool
24142411
pods, err := kubernetes.ListPods(ctx, r, pool.GetNamespace(), pool.GetNodePoolLabels())
24152412
if err != nil {
24162413
return fmt.Errorf("failed to list pods for node pool %s: %w", pool.GetNodePoolName(), err)
@@ -2422,7 +2419,6 @@ func (r *HumioClusterReconciler) reconcileSinglePDB(ctx context.Context, pool *H
24222419
return nil
24232420
}
24242421

2425-
// Build the desired PDB
24262422
desiredPDB, err := r.constructPDB(pool)
24272423
if err != nil {
24282424
return fmt.Errorf("failed to construct PDB for node pool %s: %w", pool.GetNodePoolName(), err)
@@ -2452,7 +2448,6 @@ func (r *HumioClusterReconciler) constructPDB(pool *HumioNodePool) (*policyv1.Po
24522448
},
24532449
}
24542450

2455-
// Apply PDB configuration from the node pool
24562451
pdbConfig := pool.GetPodDisruptionBudget()
24572452
if pdbConfig != nil {
24582453
if pdbConfig.MinAvailable != nil {
@@ -2469,12 +2464,10 @@ func (r *HumioClusterReconciler) constructPDB(pool *HumioNodePool) (*policyv1.Po
24692464
pdb.Spec.UnhealthyPodEvictionPolicy = (*policyv1.UnhealthyPodEvictionPolicyType)(pdbConfig.UnhealthyPodEvictionPolicy)
24702465
}
24712466
} else {
2472-
// Set default MinAvailable if no PDB config provided
24732467
defaultMin := intstr.FromString(defaultMinAvailable)
24742468
pdb.Spec.MinAvailable = &defaultMin
24752469
}
24762470

2477-
// Set controller reference
24782471
clusterRef := &humiov1alpha1.HumioCluster{
24792472
ObjectMeta: metav1.ObjectMeta{
24802473
Name: pool.GetClusterName(),
@@ -2531,27 +2524,23 @@ func (r *HumioClusterReconciler) cleanupOrphanedPDBs(ctx context.Context, humioN
25312524
return nil
25322525
}
25332526

2534-
// Get cluster details from the first node pool
25352527
clusterName := humioNodePools.Items[0].GetClusterName()
25362528
namespace := humioNodePools.Items[0].GetNamespace()
25372529

2538-
// List all existing PDBs for this cluster
25392530
existingPDBs := &policyv1.PodDisruptionBudgetList{}
25402531
if err := r.List(ctx, existingPDBs,
25412532
client.InNamespace(namespace),
25422533
client.MatchingLabels(kubernetes.LabelsForHumio(clusterName))); err != nil {
25432534
return fmt.Errorf("failed to list PDBs: %w", err)
25442535
}
25452536

2546-
// Create a map of valid PDB names based on active node pools
25472537
validPDBs := make(map[string]bool)
25482538
for _, pool := range humioNodePools.Items {
25492539
if shouldCreatePDBForNodePool(pool) {
25502540
validPDBs[fmt.Sprintf("%s%s", pool.GetNodePoolName(), pdbNameSuffix)] = true
25512541
}
25522542
}
25532543

2554-
// Delete orphaned PDBs
25552544
for _, pdb := range existingPDBs.Items {
25562545
if !validPDBs[pdb.Name] {
25572546
r.Log.Info("deleting orphaned PDB", "pdbName", pdb.Name)

0 commit comments

Comments
 (0)