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

Update frequency of reconcile and parameterize the reconcile settings #697

Merged
merged 1 commit into from
Nov 18, 2024
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
33 changes: 33 additions & 0 deletions api/v1/webspherelibertyapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ type WebSphereLibertyApplicationStatus struct {

// The generation identifier of this WebSphereLibertyApplication instance completely reconciled by the Operator.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// The reconciliation interval in seconds.
ReconcileInterval *int32 `json:"reconcileInterval,omitempty"`
}

// Defines possible status conditions.
Expand All @@ -554,6 +557,9 @@ type StatusCondition struct {
Message string `json:"message,omitempty"`
Status corev1.ConditionStatus `json:"status,omitempty"`
Type StatusConditionType `json:"type,omitempty"`

// The count of the number of reconciles the condition status type has not changed.
UnchangedConditionCount *int32 `json:"unchangedConditionCount,omitempty"`
}

// Defines the type of status condition.
Expand Down Expand Up @@ -1046,6 +1052,14 @@ func (s *WebSphereLibertyApplicationStatus) SetReference(name string, value stri
s.References[name] = value
}

func (s *WebSphereLibertyApplicationStatus) GetReconcileInterval() *int32 {
return s.ReconcileInterval
}

func (s *WebSphereLibertyApplicationStatus) SetReconcileInterval(interval *int32) {
s.ReconcileInterval = interval
}

// GetMinReplicas returns minimum replicas
func (a *WebSphereLibertyApplicationAutoScaling) GetMinReplicas() *int32 {
return a.MinReplicas
Expand Down Expand Up @@ -1511,6 +1525,7 @@ func (s *WebSphereLibertyApplicationStatus) SetCondition(c common.StatusConditio
condition.SetMessage(c.GetMessage())
condition.SetStatus(c.GetStatus())
condition.SetType(c.GetType())
condition.SetUnchangedConditionCount(c.GetUnchangedConditionCount())
if !found {
s.Conditions = append(s.Conditions, *condition)
}
Expand All @@ -1532,6 +1547,24 @@ func (s *WebSphereLibertyApplicationStatus) UnsetCondition(c common.StatusCondit
}
}

func (sc *StatusCondition) GetUnchangedConditionCount() *int32 {
return sc.UnchangedConditionCount
}

func (sc *StatusCondition) SetUnchangedConditionCount(count *int32) {
sc.UnchangedConditionCount = count
}

func (s *WebSphereLibertyApplicationStatus) UnsetUnchangedConditionCount(conditionType common.StatusConditionType) {
// Reset unchanged count for other status conditions
var emptyCount *int32
for i := range s.Conditions {
if s.Conditions[i].GetType() != conditionType && s.Conditions[i].GetUnchangedConditionCount() != nil {
s.Conditions[i].SetUnchangedConditionCount(emptyCount)
}
}
}

func convertToCommonStatusConditionType(c StatusConditionType) common.StatusConditionType {
switch c {
case StatusConditionTypeReconciled:
Expand Down
10 changes: 10 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ metadata:
capabilities: Auto Pilot
categories: Application Runtime
containerImage: icr.io/cpopen/websphere-liberty-operator:daily
createdAt: "2024-09-20T15:49:35Z"
createdAt: "2024-11-18T19:19:31Z"
description: Deploy and manage containerized Liberty applications
features.operators.openshift.io/disconnected: "true"
olm.skipRange: '>=1.0.0 <1.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8111,6 +8111,11 @@ spec:
type:
description: Defines the type of status condition.
type: string
unchangedConditionCount:
description: The count of the number of reconciles the condition
status type has not changed.
format: int32
type: integer
type: object
type: array
x-kubernetes-list-type: atomic
Expand All @@ -8137,6 +8142,10 @@ spec:
instance completely reconciled by the Operator.
format: int64
type: integer
reconcileInterval:
description: The reconciliation interval in seconds.
format: int32
type: integer
references:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8107,6 +8107,11 @@ spec:
type:
description: Defines the type of status condition.
type: string
unchangedConditionCount:
description: The count of the number of reconciles the condition
status type has not changed.
format: int32
type: integer
type: object
type: array
x-kubernetes-list-type: atomic
Expand All @@ -8133,6 +8138,10 @@ spec:
instance completely reconciled by the Operator.
format: int64
type: integer
reconcileInterval:
description: The reconciliation interval in seconds.
format: int32
type: integer
references:
additionalProperties:
type: string
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23

require (
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20240920191131-becf646d462a
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240920184731-58836ec570f6
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20241118182902-2340c1cdeff2
github.com/cert-manager/cert-manager v1.13.6
github.com/go-logr/logr v1.3.0
github.com/openshift/api v0.0.0-20230928134114-673ed0cfc7f1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxa
contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ=
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20240920191131-becf646d462a h1:gNQrggTgyHLQJW4TSCZSTkOc6brXj1KMnQyKL3KYXWk=
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20240920191131-becf646d462a/go.mod h1:Hwzj6w2cmV1xNx5Bht8bXDprJLjYMDTF/e8OOLbNjIc=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240920184731-58836ec570f6 h1:ltEk49dxle0XgNgVSGWspfBqcx2nkd1SBMLoWOD1ETA=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240920184731-58836ec570f6/go.mod h1:Q//a3yubxjR3+COorasymYRuuiDPs0Usgl9YuADkD6U=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20241118182902-2340c1cdeff2 h1:dv5rxcqVkCFbWtH4N4U8AA7M284DXhXgC3eEls2KETk=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20241118182902-2340c1cdeff2/go.mod h1:Q//a3yubxjR3+COorasymYRuuiDPs0Usgl9YuADkD6U=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
11 changes: 10 additions & 1 deletion internal/controller/webspherelibertyapplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ func (r *ReconcileWebSphereLiberty) Reconcile(ctx context.Context, request ctrl.
return reconcile.Result{}, err
}

if err = common.Config.CheckValidValue(common.OpConfigReconcileIntervalSeconds, OperatorName); err != nil {
return r.ManageError(err, common.StatusConditionTypeReconciled, instance)
}

if err = common.Config.CheckValidValue(common.OpConfigReconcileIntervalPercentage, OperatorName); err != nil {
return r.ManageError(err, common.StatusConditionTypeReconciled, instance)
}

isKnativeSupported, err := r.IsGroupVersionSupported(servingv1.SchemeGroupVersion.String(), "Service")
if err != nil {
r.ManageError(err, common.StatusConditionTypeReconciled, instance)
Expand Down Expand Up @@ -834,7 +842,8 @@ func (r *ReconcileWebSphereLiberty) Reconcile(ctx context.Context, request ctrl.
}

func (r *ReconcileWebSphereLiberty) isWebSphereLibertyApplicationReady(ba common.BaseComponent) bool {
if r.CheckApplicationStatus(ba) == corev1.ConditionTrue {
_, condition := r.CheckApplicationStatus(ba)
if condition.GetStatus() == corev1.ConditionTrue {
statusCondition := ba.GetStatus().GetCondition(common.StatusConditionTypeReady)
return statusCondition != nil && statusCondition.GetMessage() == common.StatusConditionTypeReadyMessage
}
Expand Down
9 changes: 9 additions & 0 deletions internal/deploy/kubectl/websphereliberty-app-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8110,6 +8110,11 @@ spec:
type:
description: Defines the type of status condition.
type: string
unchangedConditionCount:
description: The count of the number of reconciles the condition
status type has not changed.
format: int32
type: integer
type: object
type: array
x-kubernetes-list-type: atomic
Expand All @@ -8136,6 +8141,10 @@ spec:
instance completely reconciled by the Operator.
format: int64
type: integer
reconcileInterval:
description: The reconciliation interval in seconds.
format: int32
type: integer
references:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8110,6 +8110,11 @@ spec:
type:
description: Defines the type of status condition.
type: string
unchangedConditionCount:
description: The count of the number of reconciles the condition
status type has not changed.
format: int32
type: integer
type: object
type: array
x-kubernetes-list-type: atomic
Expand All @@ -8136,6 +8141,10 @@ spec:
instance completely reconciled by the Operator.
format: int64
type: integer
reconcileInterval:
description: The reconciliation interval in seconds.
format: int32
type: integer
references:
additionalProperties:
type: string
Expand Down