Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACM-11453 Fix flaky subscription constraints not satisfiable condition #258

Merged
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions api/v1beta1/operatorpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package v1beta1

import (
"strings"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -209,6 +210,12 @@ type OperatorPolicyStatus struct {
// The list of overlapping OperatorPolicies (as name.namespace) which all manage the same
// subscription, including this policy. When no overlapping is detected, this list will be empty.
OverlappingPolicies []string `json:"overlappingPolicies,omitempty"`

// Timestamp for a possible intervention to help a Subscription stuck with a
// ConstraintsNotSatisfiable condition. Can be in the future, indicating the
// policy is waiting for OLM to resolve the situation. If in the recent past,
// the policy may update the status of the Subscription.
SubscriptionInterventionTime *metav1.Time `json:"subscriptionInterventionTime,omitempty"`
}

// RelatedObjsOfKind iterates over the related objects in the status and returns a map of the index
Expand Down Expand Up @@ -238,6 +245,25 @@ func (status OperatorPolicyStatus) GetCondition(condType string) (int, metav1.Co
return -1, metav1.Condition{}
}

// Returns true if the SubscriptionInterventionTime is far enough in the past
// to be considered expired, and therefore should be removed from the status.
func (status OperatorPolicyStatus) SubscriptionInterventionExpired() bool {
if status.SubscriptionInterventionTime == nil {
return false
}

return status.SubscriptionInterventionTime.Time.Before(time.Now().Add(-10 * time.Second))
}

// Returns true if the SubscriptionInterventionTime is in the future.
func (status OperatorPolicyStatus) SubscriptionInterventionWaiting() bool {
if status.SubscriptionInterventionTime == nil {
return false
}

return status.SubscriptionInterventionTime.Time.After(time.Now())
}

// OperatorPolicy is the schema for the operatorpolicies API. You can use the operator policy to
// manage operators by providing automation for their management and reporting on the status across
// the various operator objects.
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading