Support edge nodes report events#5811
Conversation
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| appcorev1 "k8s.io/client-go/applyconfigurations/core/v1" | ||
| fakecorev1 "k8s.io/client-go/kubernetes/typed/core/v1/fake" |
There was a problem hiding this comment.
Please sort these import.
| @@ -0,0 +1,95 @@ | |||
| package client | |||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| appcorev1 "k8s.io/client-go/applyconfigurations/core/v1" |
There was a problem hiding this comment.
ditto, sort the import.
|
|
||
| func (m *metaManager) process(message model.Message) { | ||
| operation := message.GetOperation() | ||
| if _, resType, _ := parseResource(&message); resType == model.ResourceTypeEvent { |
There was a problem hiding this comment.
Could we use processInsert and processUpdate func?
| @@ -325,6 +326,8 @@ type EdgeControllerBuffer struct { | |||
| type EdgeControllerLoad struct { | |||
| // UpdatePodStatusWorkers indicates the load of update pod status workers | |||
There was a problem hiding this comment.
You need add a comment for HandleEventWorkers
| @@ -252,6 +252,7 @@ type EdgeController struct { | |||
| type EdgeControllerBuffer struct { | |||
| // UpdatePodStatus indicates the buffer of pod status | |||
There was a problem hiding this comment.
You need add a comment for HandleEvent
4c5fb19 to
ebc96e6
Compare
|
build fail, @llmmqq8023 you may need fix it before merge |
Signed-off-by: llmmqq8023 <273337875@qq.com> cloud Signed-off-by: llmmqq8023 <273337875@qq.com> cloud Signed-off-by: llmmqq8023 <273337875@qq.com>
Signed-off-by: llmmqq8023 <273337875@qq.com>
Signed-off-by: llmmqq8023 <273337875@qq.com> Modified comments and other content Signed-off-by: llmmqq8023 <273337875@qq.com> Revert "不需要推送" This reverts commit edcf206. Modified comments and other content Signed-off-by: llmmqq8023 <273337875@qq.com>
Thank you for pointing out the build issue. I have made the necessary fixes, please try it again~ |
| evt := &v1.Event{} | ||
| err = json.Unmarshal(data, evt) | ||
| if err != nil { | ||
| klog.Errorf("Error marshaling createEvent msg content %v", err) |
There was a problem hiding this comment.
this is Unmarshal action,not marshal action.
You may need to modify the error description to something like this
| case msg := <-uc.eventChan: | ||
| data, err := msg.GetContentData() | ||
| if err != nil { | ||
| klog.Errorf("Get event data err: %v", err) |
There was a problem hiding this comment.
printing msg.GetID() in error log is a good practice.
you may need add it in your error log.
| } | ||
| _, err = uc.kubeClient.CoreV1().Events(evt.Namespace).CreateWithEventNamespace(evt) | ||
| if err != nil { | ||
| klog.Errorf("CreateWithEventNamespace error, event: %v, err: %v", evt, err) |
There was a problem hiding this comment.
Unless you know what you're doing, printing all the information of a structure is a recommended action.
You may need to select the attributes worth printing.
There are several similar issues, if you agree with the review, you may want to check and correct them yourself.
| evt := &v1.Event{} | ||
| err = json.Unmarshal(data, evt) | ||
| if err != nil { | ||
| klog.Errorf("Error marshaling updateEvent msg content %v", err) |
There was a problem hiding this comment.
don't use %v for err var.
There was a problem hiding this comment.
Could you please explain more about why cannot use %v to log err?
There was a problem hiding this comment.
After checking, my comment was wrong,
%v works better for nil.
see https://stackoverflow.com/questions/61283248/format-errors-in-go-s-v-or-w
please close it.
| DefaultCertificateSigningRequestWorkers = 4 | ||
|
|
||
| DefaultUpdatePodStatusBuffer = 1024 | ||
| DefaultProcessEventBuffer = 1024 |
There was a problem hiding this comment.
Please allow me to be curious,
@wbc6080 Do we need to keep common/constants/default.go and staging/src/github.com/kubeedge/api/apis/common/constants/default.go consistent?
If not, can the unused variables be removed?
| } | ||
|
|
||
| // Create logs the event creation request. | ||
| func (e *EventsBridge) Create(ctx context.Context, event *corev1.Event, opts metav1.CreateOptions) (*corev1.Event, error) { |
There was a problem hiding this comment.
about the comment Create logs the event creation request.
I don't think the function is responsible for logging; its responsibility is as a bridge or proxy, forwarding requests to the meta.
| } | ||
|
|
||
| func (e *events) CreateWithEventNamespace(event *corev1.Event) (*corev1.Event, error) { | ||
| resource := fmt.Sprintf("%s/%s/%s", e.namespace, model.ResourceTypeEvent, event.Name) |
There was a problem hiding this comment.
The same confusion, whether to use NameSpace in Core1.Event within functions ending with WithEventNamespace
But unlike the previous one, which was so certain, the decision on which namespace to use here needs to be made on your own.
There was a problem hiding this comment.
Yes, it should be changed to:
| resource := fmt.Sprintf("%s/%s/%s", e.namespace, model.ResourceTypeEvent, event.Name) | |
| resource := fmt.Sprintf("%s/%s/%s", event.namespace, model.ResourceTypeEvent, event.Name) |
| return event, nil | ||
| } | ||
|
|
||
| type PatchInfo struct { |
There was a problem hiding this comment.
I see the repeat define PatchInfo in MetaManager and EdgeController.
Could you check if it's possible to extract this into the API package to reduce duplication?
| } | ||
| } | ||
|
|
||
| type PatchInfo struct { |
There was a problem hiding this comment.
| type PatchInfo struct { | |
| type EventPatchInfo struct { |
| evt := &v1.Event{} | ||
| err = json.Unmarshal(data, evt) | ||
| if err != nil { | ||
| klog.Errorf("Error marshaling updateEvent msg content %v", err) |
There was a problem hiding this comment.
Could you please explain more about why cannot use %v to log err?
| } | ||
|
|
||
| func (e *events) CreateWithEventNamespace(event *corev1.Event) (*corev1.Event, error) { | ||
| resource := fmt.Sprintf("%s/%s/%s", e.namespace, model.ResourceTypeEvent, event.Name) |
There was a problem hiding this comment.
Yes, it should be changed to:
| resource := fmt.Sprintf("%s/%s/%s", e.namespace, model.ResourceTypeEvent, event.Name) | |
| resource := fmt.Sprintf("%s/%s/%s", event.namespace, model.ResourceTypeEvent, event.Name) |
|
Please solve the error of golint and UT |
Signed-off-by: llmmqq8023 <273337875@qq.com> solve the error of golint and UT Signed-off-by: llmmqq8023 <273337875@qq.com> solve the error of golint and UT Signed-off-by: llmmqq8023 <273337875@qq.com>
wbc6080
left a comment
There was a problem hiding this comment.
Please make the lint check pass
…n "sendEvent". Signed-off-by: llmmqq8023 <273337875@qq.com>
| // ImagePrePullController | ||
| DefaultImagePrePullJobStatusBuffer = 1024 | ||
| DefaultImagePrePullJobEventBuffer = 1 | ||
| DefaultImagePrePullJobWorkers = 1 |
There was a problem hiding this comment.
These contants need to be removed. It seems a misoperation importing these constants when you rebase the master branch
| // EdgeControllerLoad indicates the EdgeController load | ||
| type EdgeControllerLoad struct { | ||
| // HandleEventWorkers indicates the load of handle event workers | ||
| // default 1 |
There was a problem hiding this comment.
https://github.com/kubeedge/kubeedge/pull/5811/files#diff-85964fa94ec623fce7d82bcc2717627f112d94a8649758f9d52544a01af876aeR44 Please keep consistent with DefaultProcessEventWorkers
| // SendEvents indicates whether to send events to cloud, | ||
| // if set to false, events will not be sent to cloud. | ||
| // default true | ||
| SendEvent bool `json:"sendEvent"` |
There was a problem hiding this comment.
In order to allow users to smoothly upgrade and adapt to new versions, I think it is more appropriate to disable this feature by default in the next two release.
Signed-off-by: llmmqq8023 <273337875@qq.com>
| // SendEvents indicates whether to send events to cloud, | ||
| // if set to true, events will be sent to cloud. | ||
| // default false | ||
| SendEvent bool `json:"sendEvent"` |
There was a problem hiding this comment.
There was a problem hiding this comment.
ReportEventshould be better?
+1
Signed-off-by: llmmqq8023 <273337875@qq.com>
fisherxu
left a comment
There was a problem hiding this comment.
Plz fix the lint check error, and you can also run make lint in your local host to check, thanks :) @llmmqq8023
| "k8s.io/client-go/kubernetes/fake" | ||
| "testing" | ||
| "time" | ||
| ) |
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| appcorev1 "k8s.io/client-go/applyconfigurations/core/v1" | ||
| "testing" |
| // EdgeControllerLoad indicates the EdgeController load | ||
| type EdgeControllerLoad struct { | ||
| // ProcessEventWorkers indicates the load of process event workers | ||
| // default 1 |
There was a problem hiding this comment.
| // default 1 | |
| // default 4 |
according your code, the default value should be 4
Signed-off-by: llmmqq8023 <273337875@qq.com> modify imports Signed-off-by: llmmqq8023 <273337875@qq.com> change an annotation of "default" Signed-off-by: llmmqq8023 <273337875@qq.com>
4ff0af6 to
02b5af9
Compare
| } | ||
|
|
||
| func TestEventReport(t *testing.T) { | ||
|
|
There was a problem hiding this comment.
remove unnecessary blank line
Signed-off-by: llmmqq8023 <273337875@qq.com> add copyright for _test.go Signed-off-by: llmmqq8023 <273337875@qq.com>
cd1f75f to
67aa477
Compare
Shelley-BaoYue
left a comment
There was a problem hiding this comment.
/lgtm
cc @fisherxu @WillardHu @wbc6080
fisherxu
left a comment
There was a problem hiding this comment.
/approve
Thanks for the great work!
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fisherxu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |


What type of PR is this?
/kind feature
What this PR does / why we need it:
Support edge nodes report events
Proposal: #5722
Issue: #5595