Skip to content

Commit

Permalink
Track notification status
Browse files Browse the repository at this point in the history
Add information about notification status (delivered vs fail to deliver)
in ClusterHealthCheck status.

This will avoid re-sending notifications already delivered unless
something has changed.
  • Loading branch information
gianlucam76 committed Feb 15, 2023
1 parent 0c3cb78 commit ee01bcf
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api/v1alpha1/clusterhealthcheck_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ type Notification struct {
NotificationRef *corev1.ObjectReference `json:"notificationRef,omitempty"`
}

// NotificationStatus specifies status of notifications
// +kubebuilder:validation:Enum:=Delivered;FailedToDeliver
type NotificationStatus string

const (
// NotificationStatusDelivered indicates notification has been delivered
NotificationStatusDelivered = NotificationStatus("Delivered")

// NotificationStatusFailedToDeliver indicates notification was not delivered
// due to an error
NotificationStatusFailedToDeliver = NotificationStatus("FailedToDeliver")
)

type NotificationSummary struct {
// Name of the notification check.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`

// NotificationStatus specifies the notification status
Status NotificationStatus `json:"status"`

// FailureMessage is a human consumable message explaining the
// misconfiguration
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`
}

// ClusterHealthCheckSpec defines the desired state of ClusterHealthCheck
type ClusterHealthCheckSpec struct {
// ClusterSelector identifies clusters to associate to.
Expand All @@ -162,6 +188,10 @@ type ClusterHealthCheckStatus struct {
// ClusterHealthCheck instance
// +optional
ClusterConditions []ClusterCondition `json:"clusterCondition,omitempty"`

// NotificationSummaries contains status information on notifications
// +optional
NotificationSummaries []NotificationSummary `json:"notificationSummaries,omitempty"`
}

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

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

23 changes: 23 additions & 0 deletions config/crd/bases/lib.projectsveltos.io_clusterhealthchecks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,29 @@ spec:
type: string
type: object
type: array
notificationSummaries:
description: NotificationSummaries contains status information on
notifications
items:
properties:
failureMessage:
description: FailureMessage is a human consumable message explaining
the misconfiguration
type: string
name:
description: Name of the notification check.
type: string
status:
description: NotificationStatus specifies the notification status
enum:
- Delivered
- FailedToDeliver
type: string
required:
- name
- status
type: object
type: array
type: object
type: object
served: true
Expand Down
23 changes: 23 additions & 0 deletions lib/crd/clusterhealthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,29 @@ spec:
type: string
type: object
type: array
notificationSummaries:
description: NotificationSummaries contains status information on
notifications
items:
properties:
failureMessage:
description: FailureMessage is a human consumable message explaining
the misconfiguration
type: string
name:
description: Name of the notification check.
type: string
status:
description: NotificationStatus specifies the notification status
enum:
- Delivered
- FailedToDeliver
type: string
required:
- name
- status
type: object
type: array
type: object
type: object
served: true
Expand Down

0 comments on commit ee01bcf

Please sign in to comment.