diff --git a/pkg/schema/v1/replica_set.go b/pkg/schema/v1/replica_set.go index 056c5efa..2f8025ca 100644 --- a/pkg/schema/v1/replica_set.go +++ b/pkg/schema/v1/replica_set.go @@ -10,6 +10,7 @@ import ( kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ktypes "k8s.io/apimachinery/pkg/types" "strings" + "time" ) type ReplicaSet struct { @@ -136,6 +137,18 @@ func (r *ReplicaSet) getIcingaState() (IcingaState, string) { } } + // Check if the ReplicaSet was created within the last 5 minutes + createdTime := r.GetCreationTimestamp() + gracePeriodDeadline := createdTime.Add(5 * time.Minute) + now := time.Now() + + // Wait for the grace period to end + if now.Before(gracePeriodDeadline) { + timeLeft := gracePeriodDeadline.Sub(now) + reason := fmt.Sprintf("ReplicaSet %s/%s is within the grace period. Time left: %s", r.Namespace, r.Name, timeLeft.Round(time.Second)) + return Ok, reason + } + switch { case r.AvailableReplicas < 1: reason := fmt.Sprintf("ReplicaSet %s/%s has no available replicas", r.Namespace, r.Name)