Skip to content
Open
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
14 changes: 13 additions & 1 deletion cmd/metalprobe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func main() {
var registryClientTimeout time.Duration
var LLDPSyncInterval time.Duration
var LLDPSyncDuration time.Duration
var cleanDisks bool
var diskCleaningMode string

flag.StringVar(&registryURL, "registry-url", "", "Registry URL where the probe will register itself.")
flag.StringVar(&serverUUID, "server-uuid", "", "Agent UUID to register with the registry.")
Expand All @@ -34,6 +36,9 @@ func main() {
"Duration of time to wait between lldpctl runs.")
flag.DurationVar(&LLDPSyncDuration, "lldp-sync-duration", 30*time.Second,
"Timeout for the lldpctl run.")
flag.BoolVar(&cleanDisks, "clean-disks", false, "Enable disk cleaning during discovery.")
flag.StringVar(&diskCleaningMode, "disk-cleaning-mode", "quick",
"Disk cleaning mode: 'quick' or 'secure'.")
Comment thread
coderabbitai[bot] marked this conversation as resolved.

opts := zap.Options{
Development: true,
Expand All @@ -53,11 +58,18 @@ func main() {
os.Exit(1)
}

if diskCleaningMode != "quick" && diskCleaningMode != "secure" {
setupLog.Error(nil, "Invalid disk cleaning mode",
"mode", diskCleaningMode, "valid", []string{"quick", "secure"})
os.Exit(1)
}

ctx := ctrl.SetupSignalHandler()

setupLog.Info("starting registry agent")

agent := probe.NewAgent(setupLog, serverUUID, registryURL, duration, registryClientTimeout,
LLDPSyncInterval, LLDPSyncDuration)
LLDPSyncInterval, LLDPSyncDuration, cleanDisks, diskCleaningMode)
if err := agent.Start(ctx); err != nil {
setupLog.Error(err, "problem running probe agent")
os.Exit(1)
Expand Down
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ spec:
- /manager
args:
- --leader-elect
- --enable-disk-cleaning=false
- --disk-cleaning-mode=quick
image: controller:latest
name: manager
ports:
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (
ConditionReady = "Ready"
// ConditionRetryOfFailedResourceIssued indicates a retry of a failed resource has been issued.
ConditionRetryOfFailedResourceIssued = "RetryOfFailedResourceIssued"
// ConditionDiskCleaningCompleted indicates that disk cleaning was completed
ConditionDiskCleaningCompleted = "DiskCleaningCompleted"
)

// Shared reason strings used across multiple controllers.
Expand Down
1 change: 1 addition & 0 deletions internal/controller/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ func (r *ServerReconciler) applyDefaultIgnitionForServer(ctx context.Context, se
log.V(1).Info("Applied SSH keypair secret", "SSHKeyPair", sshKeyPairNamespacedName)

probeFlags := fmt.Sprintf("--registry-url=%s --server-uuid=%s", registryURL, server.Spec.SystemUUID)

ignitionData, err := r.generateDefaultIgnitionDataForServer(probeFlags, sshPublicKey, password)
if err != nil {
return fmt.Errorf("failed to generate default ignitionSecret data: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ var _ = Describe("Server Controller", func() {
))

By("Starting the probe agent")
probeAgent := probe.NewAgent(GinkgoLogr, server.Spec.SystemUUID, registryURL, 100*time.Millisecond, 1*time.Second, 50*time.Millisecond, 250*time.Millisecond)
probeAgent := probe.NewAgent(GinkgoLogr, server.Spec.SystemUUID, registryURL, 100*time.Millisecond, 1*time.Second, 50*time.Millisecond, 250*time.Millisecond, false, "quick")
go func() {
defer GinkgoRecover()
Expect(probeAgent.Start(ctx)).To(Succeed(), "failed to start probe agent")
Expand Down Expand Up @@ -444,7 +444,7 @@ var _ = Describe("Server Controller", func() {
))

By("Starting the probe agent")
probeAgent := probe.NewAgent(GinkgoLogr, server.Spec.SystemUUID, registryURL, 50*time.Millisecond, 1*time.Second, 50*time.Millisecond, 250*time.Millisecond)
probeAgent := probe.NewAgent(GinkgoLogr, server.Spec.SystemUUID, registryURL, 50*time.Millisecond, 1*time.Second, 50*time.Millisecond, 250*time.Millisecond, false, "quick")
go func() {
defer GinkgoRecover()
Expect(probeAgent.Start(ctx)).To(Succeed(), "failed to start probe agent")
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func SetupTest(redfishMockServers []netip.AddrPort) *corev1.Namespace {
PowerPollingTimeout: 200 * time.Millisecond,
BasicAuth: true,
},
DiscoveryTimeout: 30 * time.Second, // Set a short discovery timeout for testing
DiscoveryTimeout: 30 * time.Second,
DiscoveryIgnitionPath: filepath.Join("..", "..", "config", "manager", "ignition-template.yaml"),
}).SetupWithManager(k8sManager)).To(Succeed())

Expand Down
17 changes: 17 additions & 0 deletions internal/probe/diskcleaning_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

//go:build darwin

package probe

import (
"context"
"fmt"

"github.com/go-logr/logr"
)

func cleanDisks(_ context.Context, _ logr.Logger, _ string) error {
return fmt.Errorf("disk cleaning is only supported on Linux")
}
Loading
Loading