Skip to content

Commit

Permalink
[Fix] - sts will never be created (OT-CONTAINER-KIT#663)
Browse files Browse the repository at this point in the history
* Fix err would be set nil

Signed-off-by: drivebyer <[email protected]>

* nolint for shadow

Signed-off-by: drivebyer <[email protected]>

---------

Signed-off-by: drivebyer <[email protected]>
Signed-off-by: Matt Robinson <[email protected]>
  • Loading branch information
drivebyer authored and mattrobinsonsre committed Jul 11, 2024
1 parent 809ce33 commit ac161b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion k8sutils/poddisruption.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func CreateOrUpdatePodDisruptionBudget(pdbDef *policyv1.PodDisruptionBudget) err
logger := pdbLogger(pdbDef.Namespace, pdbDef.Name)
storedPDB, err := GetPodDisruptionBudget(pdbDef.Namespace, pdbDef.Name)
if err != nil {
if err = patch.DefaultAnnotator.SetLastAppliedAnnotation(pdbDef); err != nil {
if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(pdbDef); err != nil { //nolint
logger.Error(err, "Unable to patch redis PodDisruptionBudget with comparison object")
return err
}
Expand Down
2 changes: 1 addition & 1 deletion k8sutils/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func CreateOrUpdateService(namespace string, serviceMeta metav1.ObjectMeta, owne
storedService, err := getService(namespace, serviceMeta.Name)
if err != nil {
if errors.IsNotFound(err) {
if err = patch.DefaultAnnotator.SetLastAppliedAnnotation(serviceDef); err != nil {
if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(serviceDef); err != nil { //nolint
logger.Error(err, "Unable to patch redis service with compare annotations")
}
return createService(namespace, serviceDef)
Expand Down
4 changes: 2 additions & 2 deletions k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func CreateOrUpdateStateFul(namespace string, stsMeta metav1.ObjectMeta, params
storedStateful, err := GetStatefulSet(namespace, stsMeta.Name)
statefulSetDef := generateStatefulSetsDef(stsMeta, params, ownerDef, initcontainerParams, containerParams, getSidecars(sidecars))
if err != nil {
if err = patch.DefaultAnnotator.SetLastAppliedAnnotation(statefulSetDef); err != nil {
if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(statefulSetDef); err != nil { //nolint
logger.Error(err, "Unable to patch redis statefulset with comparison object")
return err
}
Expand Down Expand Up @@ -663,7 +663,7 @@ func updateStatefulSet(namespace string, stateful *appsv1.StatefulSet, recreateS
}
logger.V(1).Info("recreating StatefulSet because the update operation wasn't possible", "reason", strings.Join(failMsg, ", "))
propagationPolicy := metav1.DeletePropagationForeground
if err = generateK8sClient().AppsV1().StatefulSets(namespace).Delete(context.TODO(), stateful.GetName(), metav1.DeleteOptions{PropagationPolicy: &propagationPolicy}); err != nil {
if err := generateK8sClient().AppsV1().StatefulSets(namespace).Delete(context.TODO(), stateful.GetName(), metav1.DeleteOptions{PropagationPolicy: &propagationPolicy}); err != nil { //nolint
return errors.Wrap(err, "failed to delete StatefulSet to avoid forbidden action")
}
}
Expand Down

0 comments on commit ac161b6

Please sign in to comment.