Skip to content
Merged
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
21 changes: 11 additions & 10 deletions internal/controller/swiftstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package controller
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -440,15 +439,18 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request
for _, swiftPod := range podList.Items {
dnsIP := ""
if len(instance.Spec.NetworkAttachments) > 0 {
dnsIP, err = getPodIPInNetwork(swiftPod, instance.Namespace, "storagemgmt")

if err != nil {
previousErr := err
dnsIP, err = getPodIPInNetwork(swiftPod, instance.Namespace, "storage")
for _, network := range []string{"storage", "storagemgmt"} {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cschwede quick question here: I see we invert storage and storagemgmt in the loop compared to the previous code. Is the expectations to normally see an IP address in the storage network and eventually fallback to storagemgt?
If so, it makes sense to me the break on L448 to avoid dnsIP being overwritten in case both storage and storagemgmt are passed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmount Yes, exactly. storage should be the default nowadays, storagemgmt is kept for backward compatibility.

dnsIP, err = getPodIPInNetwork(swiftPod, instance.Namespace, network)
if err != nil {
err = errors.Join(previousErr, err)
return ctrl.Result{}, err
}
if dnsIP != "" {
break
}
}
// If this is reached it means that no IP was found, construct error and return
if dnsIP == "" {
return ctrl.Result{}, fmt.Errorf("%w %s", swift.ErrPodIPAddressRetrieval, swiftPod.Name)
}
}

Expand Down Expand Up @@ -640,7 +642,6 @@ func getPodIPInNetwork(swiftPod corev1.Pod, namespace string, networkAttachment
}
}

// If this is reached it means that no IP was found, construct error and return
err = fmt.Errorf("%w %s in network %s", swift.ErrPodIPAddressRetrieval, swiftPod.Name, networkAttachment)
return "", err
// Network not found on this pod - return empty string, not an error
return "", nil
}