Skip to content

Commit e5f6a03

Browse files
committed
re-enable HAC for components other than DB (noobaa#1810)
Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com> (cherry picked from commit 5af50ed)
1 parent 6ea10d4 commit e5f6a03

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

pkg/controller/add_hac.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
func init() {
1010
hacEnabled := os.Getenv("HAC_ENABLED")
11-
if hacEnabled == "true" {
11+
if hacEnabled != "false" {
1212
// AddToManagerFuncs is a list of functions to create controllers and add them to a manager.
1313
AddToManagerFuncs = append(AddToManagerFuncs, hac.Add)
1414
}

pkg/hac/hac.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package hac
55

66
import (
77
"context"
8-
"os"
8+
"strings"
99

1010
"github.com/pkg/errors"
1111
"github.com/sirupsen/logrus"
@@ -44,14 +44,16 @@ func (pd *PodDeleter) DeletePodsOnNode() error {
4444
return errors.Errorf("failed to list noobaa pods on the node %v in namespace %v", pd.NodeName, options.Namespace)
4545
}
4646

47-
// delete the found pods. by default using a 1 second grace period.
48-
var gracePeriod int64 = 1
49-
if os.Getenv("HAC_FORCE_DELETE") == "true" {
50-
// if HAC_FORCE_DELETE is set to true, use a 0 second grace period.
51-
gracePeriod = 0
52-
}
47+
// delete the found pods.
48+
var gracePeriod int64 = 0
49+
5350
deleteOpts := client.DeleteOptions{GracePeriodSeconds: &gracePeriod}
5451
for _, pod := range podList.Items {
52+
// HAC must not touch DB pods - Forceful deletion of DB pods leads to corruption
53+
if strings.HasPrefix(pod.Name, "noobaa-db-pg-") {
54+
log.Infof("HAC skipping %q pod", pod.Name)
55+
continue
56+
}
5557
if err := pd.Client.Delete(context.Background(), &pod, &deleteOpts); err != nil {
5658
log.Warningf("❌ pod %v/%v, node %v: deletion failed: %v", pod.Namespace, pod.Name, pd.NodeName, err)
5759
return err

0 commit comments

Comments
 (0)