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

Reorganize events code and add execution event #800

Merged
merged 1 commit into from
Oct 18, 2021

Conversation

wawa0210
Copy link
Member

@wawa0210 wawa0210 commented Oct 11, 2021

Signed-off-by: wawa0210 [email protected]

What type of PR is this?

/kind feature

What this PR does / why we need it:

Part of #398

  • organize the events, intro version management
  • Add execution Event

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Instrumentation: Introduced events(`SyncFailed` and `SyncSucceed`) to the Work object.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 11, 2021
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 11, 2021
@wawa0210
Copy link
Member Author

/ping @RainbowMango

@XiShanYongYe-Chang
Copy link
Member

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 12, 2021
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this.
Only some nits.
I'll re-organize the event to pkg/apis/ after this PR.


// Define event type used by karmada system.
const (
//EventReasonCleanupWorkFailed indicates that Cleanup work failed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better if comments start with a whitespace. like:

Suggested change
//EventReasonCleanupWorkFailed indicates that Cleanup work failed.
// EventReasonCleanupWorkFailed indicates that Cleanup work failed.

EventReasonSyncWorkSucceed = "SyncWorkSucceed"
//EventReasonAggregateStatusFailed indicates that aggregate status failed.
EventReasonAggregateStatusFailed = "AggregateStatusFailed"
//EventReasonAggregateStatusFailed indicates that aggregate status succeed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why golint missed this check.

Suggested change
//EventReasonAggregateStatusFailed indicates that aggregate status succeed.
// EventReasonAggregateStatusSucceed indicates that aggregate status succeeds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check later why golint missed these checks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a big deal. Just thought weird.
By the way, we have deprecated golint by #806 and using revive now.

klog.Errorf("Stop sync work(%s/%s) for cluster(%s) as cluster not ready.", work.Namespace, work.Name, cluster.Name)
msg := fmt.Sprintf("Stop sync work(%s/%s) for cluster(%s) as cluster not ready.", work.Namespace, work.Name, cluster.Name)
klog.Errorf(msg)
c.EventRecorder.Event(work, corev1.EventTypeNormal, util.EventReasonSyncWorkFailed, msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can define a separated event for Work(not reuse RB/CRB).

like EventReasonApplyWorkFailed = ApplyFailed

@RainbowMango
Copy link
Member

/assign

@RainbowMango
Copy link
Member

I’m thinking the way organize the events:

  • pkg/apis/work/v1alpha1/events.go: for Work
  • pkg/apis/work/v1alpha2/events.go: for RB/CRB

In the events.go file, the events sorted by types:

// Define events for ResourceBinding and ClusterResourceBinding objects.
const (
	// xxxx
)

// Define events for Work objects.
const (
	// xxxx
)

@wawa0210 Just echo my thought here, I'm ok if you do it in this PR.

@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 16, 2021
@wawa0210 wawa0210 requested a review from RainbowMango October 16, 2021 13:05
@wawa0210 wawa0210 changed the title Add execution Event [draft] Refactor events Oct 16, 2021
@wawa0210 wawa0210 changed the title [draft] Refactor events [draft] Reorganize events code and add execution event Oct 16, 2021
EventReasonSyncWorkSucceed = "SyncWorkSucceed"
//EventReasonAggregateStatusFailed indicates that aggregate status failed.
EventReasonAggregateStatusFailed = "AggregateStatusFailed"
//EventReasonAggregateStatusFailed indicates that aggregate status succeed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//EventReasonAggregateStatusFailed indicates that aggregate status succeed.
// EventReasonAggregateStatusSucceed indicates that aggregate status succeed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, comments should start with a whitespace.

klog.Errorf("Stop sync work(%s/%s) for cluster(%s) as cluster not ready.", work.Namespace, work.Name, cluster.Name)
msg := fmt.Sprintf("Stop sync work(%s/%s) for cluster(%s) as cluster not ready.", work.Namespace, work.Name, cluster.Name)
klog.Errorf(msg)
c.EventRecorder.Event(work, corev1.EventTypeNormal, workv1alpha1.EventReasonSyncWorkFailed, msg)
Copy link
Member

@RainbowMango RainbowMango Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here if cluster not ready means the binding hasn't been scheduled yet, nothing to do with a failed.
I don't think we need an event here.

klog.Errorf("Failed to sync work(%s) to cluster(%s): %v", work.Name, cluster.Name, err)
msg := fmt.Sprintf("Failed to sync work(%s) to cluster(%s): %v", work.Name, cluster.Name, err)
klog.Errorf(msg)
c.EventRecorder.Event(work, corev1.EventTypeNormal, workv1alpha1.EventReasonSyncWorkFailed, msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corev1.EventTypeNormal??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@RainbowMango
Copy link
Member

Please remove draft from title if you are ready to move forward.

@wawa0210 wawa0210 changed the title [draft] Reorganize events code and add execution event Reorganize events code and add execution event Oct 18, 2021
@wawa0210 wawa0210 requested a review from RainbowMango October 18, 2021 02:11
EventReasonSyncWorkSucceed = "SyncWorkSucceed"
// EventReasonAggregateStatusFailed indicates that aggregate status failed.
EventReasonAggregateStatusFailed = "AggregateStatusFailed"
// EventReasonAggregateStatusFailed indicates that aggregate status succeed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment...

Suggested change
// EventReasonAggregateStatusFailed indicates that aggregate status succeed.
// EventReasonAggregateStatusSucceed indicates that aggregate status succeed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: wawa0210 <[email protected]>
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2021
@RainbowMango RainbowMango added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 18, 2021
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: RainbowMango

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot merged commit 15d0af0 into karmada-io:master Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants