Skip to content

Commit

Permalink
Add event for cluster controller
Browse files Browse the repository at this point in the history
Signed-off-by: pigletfly <[email protected]>
  • Loading branch information
pigletfly committed Oct 19, 2021
1 parent b961a7e commit 3e1d447
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/controllers/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const (
// sleep between retrying cluster health updates.
MonitorRetrySleepTime = 20 * time.Millisecond
// HealthUpdateRetry controls the number of retries of writing cluster health update.
HealthUpdateRetry = 5
HealthUpdateRetry = 5
eventReasonCreateExecutionNamespaceFailed = "CreateExecutionNamespaceFailed"
eventReasonRemoveExecutionNamespaceFailed = "RemoveExecutionNamespaceFailed"
)

// Controller is to sync Cluster.
Expand Down Expand Up @@ -113,6 +115,7 @@ func (c *Controller) syncCluster(cluster *clusterv1alpha1.Cluster) (controllerru
// create execution space
err := c.createExecutionSpace(cluster)
if err != nil {
c.EventRecorder.Event(cluster, corev1.EventTypeWarning, fmt.Sprintf("Failed %s", eventReasonRemoveExecutionNamespaceFailed), err.Error())
return controllerruntime.Result{Requeue: true}, err
}

Expand All @@ -127,6 +130,7 @@ func (c *Controller) removeCluster(cluster *clusterv1alpha1.Cluster) (controller
}
if err != nil {
klog.Errorf("Failed to remove execution space %v, err is %v", cluster.Name, err)
c.EventRecorder.Event(cluster, corev1.EventTypeWarning, fmt.Sprintf("Failed %s", eventReasonCreateExecutionNamespaceFailed), err.Error())
return controllerruntime.Result{Requeue: true}, err
}

Expand Down

0 comments on commit 3e1d447

Please sign in to comment.