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
fix edgemesh-agent proxy fetching protocol bug #175
Conversation
Welcome @king-jingxiang! It looks like this is your first PR to kubeedge/edgemesh 🎉 |
protocol = strings.Split(p.Name, "-")[0] | ||
pro := strings.Split(p.Name, "-") | ||
if len(pro) >= 2 { | ||
protocol = pro[0] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 websocket
、grpc
protocol have any plan to support it?
There was a problem hiding this comment.
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.
@@ -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" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
关于protocol的提取,从代码的可扩展性出发,我们是不是考虑如下的策略会比较好:
- 默认从port.Name提取第一个字段,校验这个字段是不是合法有效的协议;如果不是合法的协议我们就从port.Protocol获取,如果port.Protocol没有值,我们就默认使用TCP
- 关于合法有效的定义,为了可扩展性,可以让每个协议实现的时候都把自己注册到一个合法有效的协议列表;然后校验协议的有效性的时候,判断协议是不是在这个列表里面
There was a problem hiding this comment.
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"
)
There was a problem hiding this comment.
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方法,然后他的实现类都去实现这个方法,把自己的协议名称都注册到一个数组里面。在做协议合法有效校验的时候,就校验协议名称是不是在这个数组里面就可以了。这是我个人的看法,我们可以讨论下有没有更好的方法实现这个
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你好,按照之前说的,我又修改了一下,麻烦帮忙看一下这么修改可以吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提了一点小建议,其他我这边觉得ok,多谢你的贡献
/lgtm |
/close |
@khalid-jobs: Closed this PR. In response to this:
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. |
/reopen |
@khalid-jobs: Reopened this PR. In response to this:
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. |
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. |
@@ -21,6 +21,7 @@ import ( | |||
"bytes" | |||
"errors" | |||
"fmt" | |||
"github.com/kubeedge/edgemesh/agent/pkg/chassis/protocol" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go语言包的引入顺序请遵守以下规则:
- 内置包
- 第三方包
- 项目内部包
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
ac65102
to
f3a4b65
Compare
f3a4b65
to
63c7b20
Compare
改好了 |
/close |
@khalid-jobs: Closed this PR. In response to this:
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. |
/reopen |
@Poorunga: Reopened this PR. In response to this:
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. |
你可以使用go fmt处理下这个文件, |
/close |
@khalid-jobs: Closed this PR. In response to this:
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. |
/reopen |
@khalid-jobs: Reopened this PR. In response to this:
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. |
@king-jingxiang CI已经通过了,还有两件事: |
好的,我再修改一下,当时看kube-dns只有一个svc,就没有改那个 |
Signed-off-by: JingXiang <jingxiang@leinao.ai>
44a44bc
to
113fe55
Compare
/close |
@khalid-jobs: Closed this PR. In response to this:
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. |
/reopen |
@khalid-jobs: Reopened this PR. In response to this:
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. |
/lgtm |
/approve |
[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 |
Signed-off-by: JingXiang jingxiang@leinao.ai
#173