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

support new event version #171

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

Gentleelephant
Copy link
Contributor

  • 支持导出新事件,设置 newEventType 参数为 true 开启,默认为 false
  • 定时获取 cluster name

旧版事件输出

{"metadata":{"name":"ks-apiserver-7b94f9bd6f-vbtfp.17e9145e250bdcef","namespace":"kubesphere-system","uid":"40fa04c5-66f2-4c6e-8201-3b13b17dbc35","resourceVersion":"8460007","creationTimestamp":"2024-08-06T07:52:07Z"},"involvedObject":{"kind":"Pod","namespace":"kubesphere-system","name":"ks-apiserver-7b94f9bd6f-vbtfp","uid":"0ec6bbc8-9ba1-42f9-87b0-0dcfa99c0c57","apiVersion":"v1","resourceVersion":"8305839"},"reason":"FailedScheduling","message":"0/1 nodes are available: 1 node(s) didn't match pod anti-affinity rules.","source":{},"firstTimestamp":null,"lastTimestamp":null,"type":"Warning","eventTime":"2024-08-06T07:52:07.026936Z","series":{"count":1013,"lastObservedTime":"2024-08-07T01:32:29.267628Z"},"action":"Scheduling","reportingComponent":"default-scheduler","reportingInstance":"default-scheduler-i-bhbpy0xx","cluster":"host"}

新版事件输出

{"metadata":{"name":"ks-apiserver-7b94f9bd6f-vbtfp.17e9145e250bdcef","namespace":"kubesphere-system","uid":"40fa04c5-66f2-4c6e-8201-3b13b17dbc35","resourceVersion":"8460007","creationTimestamp":"2024-08-06T07:52:07Z"},"eventTime":"2024-08-06T07:52:07.026936Z","series":{"count":1013,"lastObservedTime":"2024-08-07T01:32:29.267628Z"},"reportingController":"default-scheduler","reportingInstance":"default-scheduler-i-bhbpy0xx","action":"Scheduling","reason":"FailedScheduling","regarding":{"kind":"Pod","namespace":"kubesphere-system","name":"ks-apiserver-7b94f9bd6f-vbtfp","uid":"0ec6bbc8-9ba1-42f9-87b0-0dcfa99c0c57","apiVersion":"v1","resourceVersion":"8305839"},"note":"0/1 nodes are available: 1 node(s) didn't match pod anti-affinity rules.","type":"Warning","deprecatedSource":{},"deprecatedFirstTimestamp":null,"deprecatedLastTimestamp":null,"cluster":"host"}

@Gentleelephant
Copy link
Contributor Author

@benjaminhuo @wanjunlei

@benjaminhuo
Copy link
Member

@junotx @wanjunlei pls help to review

masterURL string
kubeconfig string
configFile string
newEventType bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use eventVersion instead, known values are corev1 and eventsv1


ns, err := client.CoreV1().Namespaces().Get(context.Background(), "kubesphere-system", metav1.GetOptions{})
if err != nil {
klog.Errorf("get namespace kubesphere-system error: %s", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The function needs to exit here, otherwise, ns will be nil and the following code will report an error.

@@ -4,6 +4,10 @@ import (
"context"
"errors"
"fmt"
"github.com/kubesphere/kube-events/pkg/util"
Copy link
Collaborator

Choose a reason for hiding this comment

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

imports not sort

@wanjunlei
Copy link
Collaborator

The ruler should be changed too.

@benjaminhuo
Copy link
Member

image

字段都不太一样了,如果要真正完全支持,还要改 vector 配置 和 WhizardTelemetry 平台服务查 OpenSearch 的代码?

@@ -6,6 +6,11 @@ import (
"fmt"
"sync"

"github.com/kubesphere/kube-events/pkg/util"
v1 "k8s.io/api/events/v1"
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
v1 "k8s.io/api/events/v1"
eventsv1 "k8s.io/api/events/v1"

@Gentleelephant
Copy link
Contributor Author

Gentleelephant commented Aug 12, 2024

image

字段都不太一样了,如果要真正完全支持,还要改 vector 配置 和 WhizardTelemetry 平台服务查 OpenSearch 的代码?

完全适配,以后肯定得改

@junotx
Copy link
Collaborator

junotx commented Aug 12, 2024

the arg name is still newEventType which may be renamed as wanjun comments. the -/. separator instead of hump form is advised

setCluster(client)
c := time.Tick(60 * time.Second)
for {
select {
Copy link
Member

@benjaminhuo benjaminhuo Aug 12, 2024

Choose a reason for hiding this comment

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

成功一次还需要继续 loop 吗
民生银行那个是怎么出错的可以重现吗,他的情况我理解如果第一次没有成功从 annotation获取到 cluster name,retry 到成功就可以了。

会有 cluster 改名的情况吗,很少吧

@wanjunlei @Gentleelephant

@benjaminhuo benjaminhuo merged commit b97c9ce into kubesphere:master Oct 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants