Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/controllers/container_reconciler_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -3715,6 +3715,8 @@ func (r *containerReconcilerLoop) updateNodeAnnotations(ctx context.Context) err
}
newDrivesStr, _ := json.Marshal(updatedDrivesList)
node.Annotations["weka.io/weka-drives"] = string(newDrivesStr)
// calculate hash, based on o.node.Status.NodeInfo.BootID
node.Annotations["weka.io/sign-drives-hash"] = domain.CalculateNodeDriveSignHash(node)

// Update weka.io/drives extended resource
blockedDrives := []string{}
Expand Down
5 changes: 3 additions & 2 deletions internal/controllers/operations/sign_drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/weka/weka-operator/internal/pkg/domain"
"strings"
"time"

Expand Down Expand Up @@ -155,9 +156,9 @@ func (o *SignDrivesOperation) EnsureContainers(ctx context.Context) error {
}

// if data exists and not force - skip
// TODO: Does it work? repeat runs do create repeate wekacontainers, so sounds like this check is broken
if !o.force {
if node.Annotations["weka.io/weka-drives"] != "" {
targetHash := domain.CalculateNodeDriveSignHash(&node)
if node.Annotations["weka.io/sign-drives-hash"] == targetHash {
skip += 1
continue
}
Expand Down
12 changes: 12 additions & 0 deletions internal/pkg/domain/hashs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package domain

import (
"crypto/sha256"
"fmt"

corev1 "k8s.io/api/core/v1"
)

func CalculateNodeDriveSignHash(node *corev1.Node) string {
return fmt.Sprintf("%x", sha256.Sum256([]byte(node.Status.NodeInfo.BootID)))
}
Loading