-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented PodDisruptionBudget #896
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve the comments above and fell free to merge afterwards 🚀
} | ||
} else { | ||
// Set default values if not specified in the CR | ||
defaultMinAvailable := intstr.FromInt(2) // Example default: at least 2 pods available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FromInt32 as FromInt is deprecated
}) | ||
|
||
It("Should create PDB with user-specified minAvailable", func() { | ||
minAvailable := intstr.FromInt(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FromInt32 as FromInt is deprecated
}) | ||
|
||
It("Should create PDB with user-specified maxUnavailable", func() { | ||
maxUnavailable := intstr.FromInt(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FromInt32 as FromInt is deprecated
Expect(k8sClient.Get(ctx, key, updatedHumioCluster)).Should(Succeed()) | ||
|
||
// Update HumioCluster with new PDB spec | ||
minAvailable := intstr.FromInt(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FromInt32 as FromInt is deprecated
// Check if the PodDisruptionBudget already exists | ||
foundPdb := &policyv1.PodDisruptionBudget{} | ||
err := r.Client.Get(ctx, types.NamespacedName{Name: pdb.Name, Namespace: pdb.Namespace}, foundPdb) | ||
if err != nil && k8serrors.IsNotFound(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would streamline the error check like this:
if err != nil {
return err
}
if k8serrors.IsNotFound(err) {
// Create the PodDisruptionBudget
r.Log.Info("Creating a new PodDisruptionBudget", "PDB.Namespace", pdb.Namespace, "PDB.Name", pdb.Name)
err = r.Client.Create(ctx, pdb)
if err != nil {
return err
}
return nil
}
Implementing PodDisruptionBugdet to the operator and added unittests.
This implements #104