Skip to content

Commit

Permalink
Delete grace period
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoxhaa committed Sep 13, 2024
1 parent 4451ad0 commit db93fed
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 37 deletions.
21 changes: 0 additions & 21 deletions pkg/schema/v1/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"github.com/icinga/icinga-go-library/types"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ktypes "k8s.io/apimachinery/pkg/types"
kcache "k8s.io/client-go/tools/cache"
"reflect"
"time"
)

var NameSpaceKubernetes = uuid.MustParse("3f249403-2bb0-428f-8e91-504d1fd7ddb6")
Expand Down Expand Up @@ -118,25 +116,6 @@ func NewNullableString(s any) sql.NullString {
panic(fmt.Sprintf("invalid type %T", s))
}

func IsWithinGracePeriod(k kmetav1.Object) *string {
const gracePeriod = 5 * time.Minute

deadline := k.GetCreationTimestamp().Add(gracePeriod)
now := time.Now()
if now.Before(deadline) {
key, _ := kcache.MetaNamespaceKeyFunc(k)
reason := fmt.Sprintf(
"%s %s is within grace period until %s, so its state is not yet evaluated.",
types.Name(k),
key,
deadline)

return &reason
}

return nil
}

// Assert interface compliance.
var (
_ kmetav1.Object = (*Meta)(nil)
Expand Down
4 changes: 0 additions & 4 deletions pkg/schema/v1/daemon_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ func (d *DaemonSet) getIcingaState() (IcingaState, string) {
return Unknown, reason
}

if gracePeriodReason := IsWithinGracePeriod(d); gracePeriodReason != nil {
return Ok, *gracePeriodReason
}

switch {
case d.NumberAvailable == 0:
reason := fmt.Sprintf("DaemonSet %s/%s does not have a single pod available which should run on %d desired nodes.", d.Namespace, d.Name, d.DesiredNumberScheduled)
Expand Down
4 changes: 0 additions & 4 deletions pkg/schema/v1/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ func (d *Deployment) Obtain(k8s kmetav1.Object) {
}

func (d *Deployment) getIcingaState() (IcingaState, string) {
if gracePeriodReason := IsWithinGracePeriod(d); gracePeriodReason != nil {
return Ok, *gracePeriodReason
}

for _, condition := range d.Conditions {
if condition.Type == string(kappsv1.DeploymentAvailable) && condition.Status != string(kcorev1.ConditionTrue) {
reason := fmt.Sprintf("Deployment %s/%s is not available: %s.", d.Namespace, d.Name, condition.Message)
Expand Down
4 changes: 0 additions & 4 deletions pkg/schema/v1/replica_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ func (r *ReplicaSet) Obtain(k8s kmetav1.Object) {
}

func (r *ReplicaSet) getIcingaState() (IcingaState, string) {
if gracePeriodReason := IsWithinGracePeriod(r); gracePeriodReason != nil {
return Ok, *gracePeriodReason
}

for _, condition := range r.Conditions {
if condition.Type == string(kappsv1.ReplicaSetReplicaFailure) && condition.Status == string(kcorev1.ConditionTrue) {
reason := fmt.Sprintf("ReplicaSet %s/%s has a failure condition: %s.", r.Namespace, r.Name, condition.Message)
Expand Down
4 changes: 0 additions & 4 deletions pkg/schema/v1/stateful_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ func (s *StatefulSet) Obtain(k8s kmetav1.Object) {
}

func (s *StatefulSet) getIcingaState() (IcingaState, string) {
if gracePeriodReason := IsWithinGracePeriod(s); gracePeriodReason != nil {
return Ok, *gracePeriodReason
}

switch {
case s.AvailableReplicas == 0:
reason := fmt.Sprintf("StatefulSet %s/%s has no replica available from %d desired.", s.Namespace, s.Name, s.DesiredReplicas)
Expand Down

0 comments on commit db93fed

Please sign in to comment.