package cluster import ( "context" "fmt" "strings" "time" ) // TestHookMaybeAutoQuarantineSchedulingStorms runs one orchestration or CLI step. // Signature: (o *Orchestrator) TestHookMaybeAutoQuarantineSchedulingStorms(ctx context.Context, lastAttempt *time.Time). // Why: exposes the scheduling-storm trigger guard to the split top-level test module. func (o *Orchestrator) TestHookMaybeAutoQuarantineSchedulingStorms(ctx context.Context, lastAttempt *time.Time) { o.maybeAutoQuarantineSchedulingStorms(ctx, lastAttempt) } // TestHookQuarantineSchedulingStormWorkloads runs one orchestration or CLI step. // Signature: (o *Orchestrator) TestHookQuarantineSchedulingStormWorkloads(ctx context.Context) error. // Why: exposes the scheduling-storm auto-heal body to the split top-level test module. func (o *Orchestrator) TestHookQuarantineSchedulingStormWorkloads(ctx context.Context) error { return o.quarantineSchedulingStormWorkloads(ctx) } // TestHookSchedulingStormOwnerWorkload runs one orchestration or CLI step. // Signature: TestHookSchedulingStormOwnerWorkload(namespace string, ownerKind string, ownerName string, rsOwnerKind string, rsOwnerName string) (string, bool). // Why: exposes owner-resolution behavior without leaking internal workload types. func TestHookSchedulingStormOwnerWorkload( namespace string, ownerKind string, ownerName string, rsOwnerKind string, rsOwnerName string, ) (string, bool) { var pod podResource pod.Metadata.Namespace = strings.TrimSpace(namespace) pod.Metadata.OwnerReferences = []ownerReference{{ Kind: strings.TrimSpace(ownerKind), Name: strings.TrimSpace(ownerName), }} rsOwners := map[string]ownerReference{} if rsName := strings.TrimSpace(ownerName); rsName != "" && strings.TrimSpace(ownerKind) == "ReplicaSet" { rsOwners[pod.Metadata.Namespace+"/"+rsName] = ownerReference{ Kind: strings.TrimSpace(rsOwnerKind), Name: strings.TrimSpace(rsOwnerName), } } workload, ok := schedulingStormOwnerWorkload(pod, rsOwners) if !ok { return "", false } return fmt.Sprintf("%s/%s/%s", workload.Namespace, workload.Kind, workload.Name), true } // TestHookEventObservationCount runs one orchestration or CLI step. // Signature: TestHookEventObservationCount(count int, seriesCount int) int. // Why: exposes event-count normalization used by scheduling-storm detection. func TestHookEventObservationCount(count int, seriesCount int) int { return eventObservationCount(eventResource{ Count: count, Series: eventSeries{ Count: seriesCount, }, }) } // TestHookEventLastObservedAt runs one orchestration or CLI step. // Signature: TestHookEventLastObservedAt(seriesLastObserved time.Time, lastTimestamp time.Time, eventTime time.Time, creationTimestamp time.Time) time.Time. // Why: exposes event-time fallback behavior used by scheduling-storm detection. func TestHookEventLastObservedAt( seriesLastObserved time.Time, lastTimestamp time.Time, eventTime time.Time, creationTimestamp time.Time, ) time.Time { return eventLastObservedAt(eventResource{ LastTimestamp: lastTimestamp, EventTime: eventTime, Series: eventSeries{ LastObservedTime: seriesLastObserved, }, Metadata: struct { Namespace string `json:"namespace"` CreationTimestamp time.Time `json:"creationTimestamp"` }{ CreationTimestamp: creationTimestamp, }, }) }