Skip to content

Commit

Permalink
Merge pull request #342 from gianlucam76/down
Browse files Browse the repository at this point in the history
(feat) Set connection status in SveltosCluster
  • Loading branch information
gianlucam76 authored Aug 5, 2024
2 parents 0659845 + 9957346 commit c2e7e25
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 0 deletions.
21 changes: 21 additions & 0 deletions api/v1alpha1/sveltoscluster_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ type ActiveWindow struct {
To string `json:"to"`
}

// ConnectionStatus specifies whether connecting to managed cluster is healthy or not
// +kubebuilder:validation:Enum:=Healthy;Down
type ConnectionStatus string

type TokenRequestRenewalOption struct {
// RenewTokenRequestInterval is the interval at which to renew the TokenRequest
RenewTokenRequestInterval metav1.Duration `json:"renewTokenRequestInterval"`
Expand Down Expand Up @@ -66,7 +70,14 @@ type SveltosClusterSpec struct {
// ActiveWindow is an optional field for automatically pausing and unpausing
// the cluster.
// If not specified, the cluster will not be paused or unpaused automatically.
// +optional
ActiveWindow *ActiveWindow `json:"activeWindow,omitempty"`

// ConsecutiveFailureThreshold is the maximum number of consecutive connection
// failures before setting the problem status in Status.ConnectionStatus
// +kubebuilder:default:=3
// +optional
ConsecutiveFailureThreshold int `json:"consecutiveFailureThreshold,omitempty"`
}

// SveltosClusterStatus defines the status of SveltosCluster
Expand All @@ -79,6 +90,11 @@ type SveltosClusterStatus struct {
// +optional
Ready bool `json:"ready,omitempty"`

// ConnectionStatus indicates whether connection from the management cluster
// to the managed cluster is healthy
// +optional
ConnectionStatus ConnectionStatus `json:"connectionStatus,omitempty"`

// FailureMessage is a human consumable message explaining the
// misconfiguration
// +optional
Expand All @@ -96,6 +112,11 @@ type SveltosClusterStatus struct {
// Information when next pause cluster is scheduled
// +optional
NextPause *metav1.Time `json:"nextPause,omitempty"`

// connectionFailures is the number of consecutive failed attempts to connect
// to the remote cluster.
// +optional
ConnectionFailures int `json:"connectionFailures,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/zz_generated.conversion.go

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

20 changes: 20 additions & 0 deletions api/v1beta1/sveltoscluster_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ type ActiveWindow struct {
To string `json:"to"`
}

// ConnectionStatus specifies whether connecting to managed cluster is healthy or not
// +kubebuilder:validation:Enum:=Healthy;Down
type ConnectionStatus string

type TokenRequestRenewalOption struct {
// RenewTokenRequestInterval is the interval at which to renew the TokenRequest
RenewTokenRequestInterval metav1.Duration `json:"renewTokenRequestInterval"`
Expand Down Expand Up @@ -67,6 +71,12 @@ type SveltosClusterSpec struct {
// the cluster.
// If not specified, the cluster will not be paused or unpaused automatically.
ActiveWindow *ActiveWindow `json:"activeWindow,omitempty"`

// ConsecutiveFailureThreshold is the maximum number of consecutive connection
// failures before setting the problem status in Status.ConnectionStatus
// +kubebuilder:default:=3
// +optional
ConsecutiveFailureThreshold int `json:"consecutiveFailureThreshold,omitempty"`
}

// SveltosClusterStatus defines the status of SveltosCluster
Expand All @@ -79,6 +89,11 @@ type SveltosClusterStatus struct {
// +optional
Ready bool `json:"ready,omitempty"`

// ConnectionStatus indicates whether connection from the management cluster
// to the managed cluster is healthy
// +optional
ConnectionStatus ConnectionStatus `json:"connectionStatus,omitempty"`

// FailureMessage is a human consumable message explaining the
// misconfiguration
// +optional
Expand All @@ -96,6 +111,11 @@ type SveltosClusterStatus struct {
// Information when next pause cluster is scheduled
// +optional
NextPause *metav1.Time `json:"nextPause,omitempty"`

// connectionFailures is the number of consecutive failed attempts to connect
// to the remote cluster.
// +optional
ConnectionFailures int `json:"connectionFailures,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
38 changes: 38 additions & 0 deletions config/crd/bases/lib.projectsveltos.io_sveltosclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ spec:
- from
- to
type: object
consecutiveFailureThreshold:
default: 3
description: |-
ConsecutiveFailureThreshold is the maximum number of consecutive connection
failures before setting the problem status in Status.ConnectionStatus
type: integer
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -104,6 +110,19 @@ spec:
status:
description: SveltosClusterStatus defines the status of SveltosCluster
properties:
connectionFailures:
description: |-
connectionFailures is the number of consecutive failed attempts to connect
to the remote cluster.
type: integer
connectionStatus:
description: |-
ConnectionStatus indicates whether connection from the management cluster
to the managed cluster is healthy
enum:
- Healthy
- Down
type: string
failureMessage:
description: |-
FailureMessage is a human consumable message explaining the
Expand Down Expand Up @@ -190,6 +209,12 @@ spec:
- from
- to
type: object
consecutiveFailureThreshold:
default: 3
description: |-
ConsecutiveFailureThreshold is the maximum number of consecutive connection
failures before setting the problem status in Status.ConnectionStatus
type: integer
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -224,6 +249,19 @@ spec:
status:
description: SveltosClusterStatus defines the status of SveltosCluster
properties:
connectionFailures:
description: |-
connectionFailures is the number of consecutive failed attempts to connect
to the remote cluster.
type: integer
connectionStatus:
description: |-
ConnectionStatus indicates whether connection from the management cluster
to the managed cluster is healthy
enum:
- Healthy
- Down
type: string
failureMessage:
description: |-
FailureMessage is a human consumable message explaining the
Expand Down
38 changes: 38 additions & 0 deletions lib/crd/sveltosclusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ spec:
- from
- to
type: object
consecutiveFailureThreshold:
default: 3
description: |-
ConsecutiveFailureThreshold is the maximum number of consecutive connection
failures before setting the problem status in Status.ConnectionStatus
type: integer
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -122,6 +128,19 @@ spec:
status:
description: SveltosClusterStatus defines the status of SveltosCluster
properties:
connectionFailures:
description: |-
connectionFailures is the number of consecutive failed attempts to connect
to the remote cluster.
type: integer
connectionStatus:
description: |-
ConnectionStatus indicates whether connection from the management cluster
to the managed cluster is healthy
enum:
- Healthy
- Down
type: string
failureMessage:
description: |-
FailureMessage is a human consumable message explaining the
Expand Down Expand Up @@ -208,6 +227,12 @@ spec:
- from
- to
type: object
consecutiveFailureThreshold:
default: 3
description: |-
ConsecutiveFailureThreshold is the maximum number of consecutive connection
failures before setting the problem status in Status.ConnectionStatus
type: integer
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -242,6 +267,19 @@ spec:
status:
description: SveltosClusterStatus defines the status of SveltosCluster
properties:
connectionFailures:
description: |-
connectionFailures is the number of consecutive failed attempts to connect
to the remote cluster.
type: integer
connectionStatus:
description: |-
ConnectionStatus indicates whether connection from the management cluster
to the managed cluster is healthy
enum:
- Healthy
- Down
type: string
failureMessage:
description: |-
FailureMessage is a human consumable message explaining the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ spec:
- from
- to
type: object
consecutiveFailureThreshold:
default: 3
description: |-
ConsecutiveFailureThreshold is the maximum number of consecutive connection
failures before setting the problem status in Status.ConnectionStatus
type: integer
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -103,6 +109,19 @@ spec:
status:
description: SveltosClusterStatus defines the status of SveltosCluster
properties:
connectionFailures:
description: |-
connectionFailures is the number of consecutive failed attempts to connect
to the remote cluster.
type: integer
connectionStatus:
description: |-
ConnectionStatus indicates whether connection from the management cluster
to the managed cluster is healthy
enum:
- Healthy
- Down
type: string
failureMessage:
description: |-
FailureMessage is a human consumable message explaining the
Expand Down Expand Up @@ -189,6 +208,12 @@ spec:
- from
- to
type: object
consecutiveFailureThreshold:
default: 3
description: |-
ConsecutiveFailureThreshold is the maximum number of consecutive connection
failures before setting the problem status in Status.ConnectionStatus
type: integer
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -223,6 +248,19 @@ spec:
status:
description: SveltosClusterStatus defines the status of SveltosCluster
properties:
connectionFailures:
description: |-
connectionFailures is the number of consecutive failed attempts to connect
to the remote cluster.
type: integer
connectionStatus:
description: |-
ConnectionStatus indicates whether connection from the management cluster
to the managed cluster is healthy
enum:
- Healthy
- Down
type: string
failureMessage:
description: |-
FailureMessage is a human consumable message explaining the
Expand Down

0 comments on commit c2e7e25

Please sign in to comment.