Skip to content

Commit dd6f75f

Browse files
danegstaCopilot
andcommitted
Evaluate all container dependencies with shared lifecycle states
Prevent pending prerequisites from hiding later failures or required retries. Share dependency preparation states and condition reasons across resource kinds while retaining dependency diagnostics, terminal latching, and lease settlement. Co-authored-by: Copilot App <[email protected]> Copilot-Session: bbe01c56-5ae4-4f36-8134-93b3b2718fd2
1 parent 7016e43 commit dd6f75f

10 files changed

Lines changed: 414 additions & 253 deletions

‎api/v2/physical_container_types.go‎

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,41 +57,14 @@ const (
5757
)
5858

5959
const (
60-
// PhysicalContainerReasonImageNotFound indicates that the referenced PhysicalContainerImage does not exist.
61-
PhysicalContainerReasonImageNotFound ConditionReason = "ImageNotFound"
60+
// PhysicalContainerReasonDependenciesNotReady indicates that a referenced dependency is missing, terminating, or not ready.
61+
PhysicalContainerReasonDependenciesNotReady ConditionReason = "DependenciesNotReady"
6262

63-
// PhysicalContainerReasonImageNotReady indicates that the referenced PhysicalContainerImage is not ready.
64-
PhysicalContainerReasonImageNotReady ConditionReason = "ImageNotReady"
63+
// PhysicalContainerReasonDependencyLookupFailed indicates that a referenced dependency could not be read.
64+
PhysicalContainerReasonDependencyLookupFailed ConditionReason = "DependencyLookupFailed"
6565

66-
// PhysicalContainerReasonImageLookupFailed indicates that the referenced PhysicalContainerImage could not be read.
67-
PhysicalContainerReasonImageLookupFailed ConditionReason = "ImageLookupFailed"
68-
69-
// PhysicalContainerReasonImageFailed indicates that image acquisition failed terminally.
70-
PhysicalContainerReasonImageFailed ConditionReason = "ImageFailed"
71-
72-
// PhysicalContainerReasonVolumeNotFound indicates that a referenced PhysicalContainerVolume does not exist.
73-
PhysicalContainerReasonVolumeNotFound ConditionReason = "VolumeNotFound"
74-
75-
// PhysicalContainerReasonVolumeNotReady indicates that a referenced PhysicalContainerVolume is not ready.
76-
PhysicalContainerReasonVolumeNotReady ConditionReason = "VolumeNotReady"
77-
78-
// PhysicalContainerReasonVolumeLookupFailed indicates that a referenced PhysicalContainerVolume could not be read.
79-
PhysicalContainerReasonVolumeLookupFailed ConditionReason = "VolumeLookupFailed"
80-
81-
// PhysicalContainerReasonVolumeFailed indicates that a referenced PhysicalContainerVolume failed terminally.
82-
PhysicalContainerReasonVolumeFailed ConditionReason = "VolumeFailed"
83-
84-
// PhysicalContainerReasonNetworkNotFound indicates that a referenced PhysicalContainerNetwork does not exist.
85-
PhysicalContainerReasonNetworkNotFound ConditionReason = "NetworkNotFound"
86-
87-
// PhysicalContainerReasonNetworkNotReady indicates that a referenced PhysicalContainerNetwork is not ready.
88-
PhysicalContainerReasonNetworkNotReady ConditionReason = "NetworkNotReady"
89-
90-
// PhysicalContainerReasonNetworkLookupFailed indicates that a referenced PhysicalContainerNetwork could not be read.
91-
PhysicalContainerReasonNetworkLookupFailed ConditionReason = "NetworkLookupFailed"
92-
93-
// PhysicalContainerReasonNetworkFailed indicates that a referenced PhysicalContainerNetwork failed terminally.
94-
PhysicalContainerReasonNetworkFailed ConditionReason = "NetworkFailed"
66+
// PhysicalContainerReasonDependencyFailed indicates that a referenced dependency failed terminally.
67+
PhysicalContainerReasonDependencyFailed ConditionReason = "DependencyFailed"
9568

9669
// PhysicalContainerReasonCreating indicates that runtime container creation is in progress.
9770
PhysicalContainerReasonCreating ConditionReason = "Creating"

‎controllers/logical_container_controller.go‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,33 +569,52 @@ func (r *LogicalContainerReconciler) resolveLogicalContainerNetworks(
569569
ctx context.Context, container *apiv2.LogicalContainer,
570570
) (bool, []apiv2.ContainerNetworkConnectionConfig, string, error) {
571571
var resolved []apiv2.ContainerNetworkConnectionConfig
572+
var pendingMessage string
573+
var resolutionErr error
572574
for _, requested := range container.Spec.Container.Networks {
573575
network := &apiv2.LogicalContainerNetwork{}
574576
networkName := commonapi.AsNamespacedName(requested.NetworkRef, container.Namespace)
575577
getErr := r.Get(ctx, networkName, network)
576578
if apierrors.IsNotFound(getErr) {
577-
return false, nil, fmt.Sprintf("LogicalContainerNetwork %q does not exist.", networkName), nil
579+
if pendingMessage == "" {
580+
pendingMessage = fmt.Sprintf("LogicalContainerNetwork %q does not exist.", networkName)
581+
}
582+
continue
578583
}
579584
if getErr != nil {
580-
return false, nil, "", fmt.Errorf("get LogicalContainerNetwork %q: %w", networkName, getErr)
581-
}
582-
if !network.DeletionTimestamp.IsZero() {
583-
return false, nil, fmt.Sprintf("LogicalContainerNetwork %q is terminating.", networkName), nil
585+
resolutionErr = errors.Join(resolutionErr, fmt.Errorf("get LogicalContainerNetwork %q: %w", networkName, getErr))
586+
continue
584587
}
585588
if network.Status.Phase == apiv2.LogicalContainerNetworkPhaseFailed {
586589
message := fmt.Sprintf("LogicalContainerNetwork %q failed.", networkName)
587590
if failure := apimeta.FindStatusCondition(network.Status.Conditions, string(apiv2.ConditionReady)); failure != nil {
588591
message = fmt.Sprintf("LogicalContainerNetwork %q reports %s: %s", networkName, failure.Reason, failure.Message)
589592
}
590-
return false, nil, "", fmt.Errorf("%w: %s", errLogicalNetworkFailed, message)
593+
resolutionErr = errors.Join(resolutionErr, fmt.Errorf("%w: %s", errLogicalNetworkFailed, message))
594+
continue
595+
}
596+
if !network.DeletionTimestamp.IsZero() {
597+
if pendingMessage == "" {
598+
pendingMessage = fmt.Sprintf("LogicalContainerNetwork %q is terminating.", networkName)
599+
}
600+
continue
591601
}
592602
if network.Status.PhysicalNetworkRef == "" {
593-
return false, nil, fmt.Sprintf("LogicalContainerNetwork %q has not published its backing physical network reference.", networkName), nil
603+
if pendingMessage == "" {
604+
pendingMessage = fmt.Sprintf("LogicalContainerNetwork %q has not published its backing physical network reference.", networkName)
605+
}
606+
continue
594607
}
595608
resolved = append(resolved, apiv2.ContainerNetworkConnectionConfig{
596609
NetworkRef: network.Status.PhysicalNetworkRef, Aliases: std_slices.Clone(requested.Aliases),
597610
})
598611
}
612+
if resolutionErr != nil {
613+
return false, nil, "", resolutionErr
614+
}
615+
if pendingMessage != "" {
616+
return false, nil, pendingMessage, nil
617+
}
599618
return true, resolved, "", nil
600619
}
601620

0 commit comments

Comments
 (0)