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

fix edgemesh-agent proxy fetching protocol bug #175

Merged
merged 1 commit into from Nov 17, 2021

Conversation

king-jingxiang
Copy link

Signed-off-by: JingXiang jingxiang@leinao.ai
#173

@kubeedge-bot
Copy link
Collaborator

Welcome @king-jingxiang! It looks like this is your first PR to kubeedge/edgemesh 🎉

@kubeedge-bot kubeedge-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 10, 2021
protocol = strings.Split(p.Name, "-")[0]
pro := strings.Split(p.Name, "-")
if len(pro) >= 2 {
protocol = pro[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to consider the validity of the value pro. EdgeMesh only support http, tcp now. If the value of pro is not valid, we can fetch the p.Protocol or just set the tcp

Copy link
Author

Choose a reason for hiding this comment

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

yes, the value of pro needs to check. And the websocketgrpc protocol have any plan to support it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Websocket is support by http protocol, link. The grpc will support if it is necessary.

@khalid-huang
Copy link
Contributor

@Poorunga

@@ -176,6 +176,10 @@ func getPortAndProtocol(svc *v1.Service, svcPort int) (targetPort int, protocol
for _, p := range svc.Spec.Ports {
if p.Protocol == "TCP" && int(p.Port) == svcPort {
protocol = strings.Split(p.Name, "-")[0]
if protocol != "http" {
Copy link
Contributor

Choose a reason for hiding this comment

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

关于protocol的提取,从代码的可扩展性出发,我们是不是考虑如下的策略会比较好:

  1. 默认从port.Name提取第一个字段,校验这个字段是不是合法有效的协议;如果不是合法的协议我们就从port.Protocol获取,如果port.Protocol没有值,我们就默认使用TCP
  2. 关于合法有效的定义,为了可扩展性,可以让每个协议实现的时候都把自己注册到一个合法有效的协议列表;然后校验协议的有效性的时候,判断协议是不是在这个列表里面

Copy link
Author

Choose a reason for hiding this comment

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

k8s service支持的port.Protocol有以下几种,在创建svc时不设置Protocol,默认会被赋值为TCP。从name中提取的应用层协议,类型会有很多,而且目前仅支持http,对于其它类型的协议会导致连接问题,应用层的协议需要维护一个列表进行校验吗?

const (
	// ProtocolTCP is the TCP protocol.
	ProtocolTCP Protocol = "TCP"
	// ProtocolUDP is the UDP protocol.
	ProtocolUDP Protocol = "UDP"
	// ProtocolSCTP is the SCTP protocol.
	ProtocolSCTP Protocol = "SCTP"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

name其实可以是四层协议,比如“tcp-0”,我们要优先从name里面提出出合法有效的协议名称。为了把这个过程做成可扩展的,这个名称我理解要从/pkg/chassis/protocol里面注册出来,比如pkg/chassis/protocol/protocol.go里面的Protocol接口可以定义一个register方法,然后他的实现类都去实现这个方法,把自己的协议名称都注册到一个数组里面。在做协议合法有效校验的时候,就校验协议名称是不是在这个数组里面就可以了。这是我个人的看法,我们可以讨论下有没有更好的方法实现这个

Copy link
Author

Choose a reason for hiding this comment

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

参照于istio支持的协议,有以下协议可能作为svc port name的前缀 http,http2,https,tcp,tls,grpc,grpc-web,mongo,mysql,redis,udp

Copy link
Author

Choose a reason for hiding this comment

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

你好,按照之前说的,我又修改了一下,麻烦帮忙看一下这么修改可以吗

Copy link
Contributor

Choose a reason for hiding this comment

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

提了一点小建议,其他我这边觉得ok,多谢你的贡献

@kubeedge-bot kubeedge-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 16, 2021
@khalid-huang
Copy link
Contributor

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 16, 2021
@khalid-huang
Copy link
Contributor

/close

@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@khalid-huang
Copy link
Contributor

/reopen

@kubeedge-bot kubeedge-bot reopened this Nov 16, 2021
@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Reopened this PR.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@khalid-huang
Copy link
Contributor

khalid-huang commented Nov 16, 2021

I do not know why ci do not start at first. I reopen the pr and the ci has started. Please make sure all the ci items pass.
And we recommand compressing all commits into one, you can refer link.

@@ -21,6 +21,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/kubeedge/edgemesh/agent/pkg/chassis/protocol"
Copy link
Member

Choose a reason for hiding this comment

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

go语言包的引入顺序请遵守以下规则:

  1. 内置包
  2. 第三方包
  3. 项目内部包

Copy link
Author

Choose a reason for hiding this comment

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

ok.

@kubeedge-bot kubeedge-bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 16, 2021
@khalid-huang
Copy link
Contributor

这里的commit信息,建议做下删减
image
可以参考下
image

@king-jingxiang
Copy link
Author

改好了

@khalid-huang
Copy link
Contributor

/close

@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Poorunga
Copy link
Member

/reopen

@kubeedge-bot
Copy link
Collaborator

@Poorunga: Reopened this PR.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kubeedge-bot kubeedge-bot reopened this Nov 16, 2021
@khalid-huang
Copy link
Contributor

你可以使用go fmt处理下这个文件,go fmt agent/pkg/chassis/protocol/protocol.go

@khalid-huang
Copy link
Contributor

/close

@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@khalid-huang
Copy link
Contributor

/reopen

@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Reopened this PR.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kubeedge-bot kubeedge-bot reopened this Nov 16, 2021
@Poorunga
Copy link
Member

@king-jingxiang CI已经通过了,还有两件事:
1.文件edgemesh/agent/pkg/proxy/iptables.go里面item.DeepCopy一共有两处需要修改的地方,请再修改一下
2.将多个commit合并成1个

@king-jingxiang
Copy link
Author

@king-jingxiang CI已经通过了,还有两件事: 1.文件edgemesh/agent/pkg/proxy/iptables.go里面item.DeepCopy一共有两处需要修改的地方,请再修改一下 2.将多个commit合并成1个

好的,我再修改一下,当时看kube-dns只有一个svc,就没有改那个

Signed-off-by: JingXiang <jingxiang@leinao.ai>
@khalid-huang
Copy link
Contributor

/close

@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@khalid-huang
Copy link
Contributor

/reopen

@kubeedge-bot
Copy link
Collaborator

@khalid-jobs: Reopened this PR.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kubeedge-bot kubeedge-bot reopened this Nov 17, 2021
@khalid-huang
Copy link
Contributor

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 17, 2021
@Poorunga
Copy link
Member

/approve

@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Poorunga

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

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 17, 2021
@kubeedge-bot kubeedge-bot merged commit d952173 into kubeedge:main Nov 17, 2021
@king-jingxiang king-jingxiang deleted the leinao-fix-protocol-pr branch November 26, 2021 06:05
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. 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.

None yet

4 participants