Merge pull request #2688 from Poor12/improve-cluster-event

Add the CreateExecutionSpaceSucceed and RemoveExecutionSpaceSucceed event
This commit is contained in:
karmada-bot 2022-11-08 19:45:52 +08:00 committed by GitHub
commit 6502bda995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -1,11 +1,15 @@
package v1alpha1 package v1alpha1
// Define events for execute space objects. // Define events for cluster objects.
const ( const (
// EventReasonCreateExecutionSpaceFailed indicates that create execution space failed. // EventReasonCreateExecutionSpaceFailed indicates that create execution space failed.
EventReasonCreateExecutionSpaceFailed = "CreateExecutionSpaceFailed" EventReasonCreateExecutionSpaceFailed = "CreateExecutionSpaceFailed"
// EventReasonCreateExecutionSpaceSucceed indicates that create execution space succeed.
EventReasonCreateExecutionSpaceSucceed = "CreateExecutionSpaceSucceed"
// EventReasonRemoveExecutionSpaceFailed indicates that remove execution space failed. // EventReasonRemoveExecutionSpaceFailed indicates that remove execution space failed.
EventReasonRemoveExecutionSpaceFailed = "RemoveExecutionSpaceFailed" EventReasonRemoveExecutionSpaceFailed = "RemoveExecutionSpaceFailed"
// EventReasonRemoveExecutionSpaceSucceed indicates that remove execution space succeed.
EventReasonRemoveExecutionSpaceSucceed = "RemoveExecutionSpaceSucceed"
// EventReasonTaintClusterByConditionFailed indicates that taint cluster by condition failed. // EventReasonTaintClusterByConditionFailed indicates that taint cluster by condition failed.
EventReasonTaintClusterByConditionFailed = "TaintClusterByConditionFailed" EventReasonTaintClusterByConditionFailed = "TaintClusterByConditionFailed"
// EventReasonRemoveTargetClusterFailed indicates that failed to remove target cluster from binding. // EventReasonRemoveTargetClusterFailed indicates that failed to remove target cluster from binding.

View File

@ -243,6 +243,8 @@ func (c *Controller) removeCluster(ctx context.Context, cluster *clusterv1alpha1
c.EventRecorder.Event(cluster, corev1.EventTypeWarning, clusterv1alpha1.EventReasonRemoveExecutionSpaceFailed, err.Error()) c.EventRecorder.Event(cluster, corev1.EventTypeWarning, clusterv1alpha1.EventReasonRemoveExecutionSpaceFailed, err.Error())
return controllerruntime.Result{Requeue: true}, err return controllerruntime.Result{Requeue: true}, err
} }
msg := fmt.Sprintf("Removed execution space for cluster(%s).", cluster.Name)
c.EventRecorder.Event(cluster, corev1.EventTypeNormal, clusterv1alpha1.EventReasonRemoveExecutionSpaceSucceed, msg)
if exist, err := c.ExecutionSpaceExistForCluster(cluster.Name); err != nil { if exist, err := c.ExecutionSpaceExistForCluster(cluster.Name); err != nil {
klog.Errorf("Failed to check weather the execution space exist in the given member cluster or not, error is: %v", err) klog.Errorf("Failed to check weather the execution space exist in the given member cluster or not, error is: %v", err)
@ -392,7 +394,9 @@ func (c *Controller) createExecutionSpace(cluster *clusterv1alpha1.Cluster) erro
klog.Errorf("Failed to create execution space for cluster(%s): %v", cluster.Name, err) klog.Errorf("Failed to create execution space for cluster(%s): %v", cluster.Name, err)
return err return err
} }
klog.V(2).Infof("Created execution space(%s) for cluster(%s).", executionSpaceName, cluster.Name) msg := fmt.Sprintf("Created execution space(%s) for cluster(%s).", executionSpaceName, cluster.Name)
klog.V(2).Info(msg)
c.EventRecorder.Event(cluster, corev1.EventTypeNormal, clusterv1alpha1.EventReasonCreateExecutionSpaceSucceed, msg)
} }
return nil return nil