-
Notifications
You must be signed in to change notification settings - Fork 494
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
[mesh] sidecar egress supports routing by request domain #299
Conversation
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.
[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 299 Deploy Test Success
Codecov Report
@@ Coverage Diff @@
## main #299 +/- ##
==========================================
+ Coverage 80.23% 80.45% +0.22%
==========================================
Files 53 53
Lines 5888 5888
==========================================
+ Hits 4724 4737 +13
+ Misses 905 895 -10
+ Partials 259 256 -3
Continue to review full report at Codecov.
|
// vet-services.easemesh.svc.cluster.local | ||
// _zip._tcp.vet-services.easemesh.svc.com | ||
func (egs *EgressServer) buildHostRegex(serviceName string) string { | ||
return fmt.Sprintf("^(|(\\w+\\.)+)%s\\.(\\w+)\\.svc\\..+", serviceName) |
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.
propose to not using Sprintf
to avoid double escaping which make the regexp hard to read.
and, is the regexp correct?
return fmt.Sprintf("^(|(\\w+\\.)+)%s\\.(\\w+)\\.svc\\..+", serviceName) | |
return `^(|(\w+\.)+)` + serviceName + `\.(\w+)\.svc\..+` |
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 use this program to test the regexp locally, it works.
package main
import (
"fmt"
"regexp"
)
func main() {
hostRE, err := regexp.Compile(`^(|(\w+\.)+)vet-services\.(\w+)\.svc\..+`)
if err != nil {
fmt.Printf("gen regexp failed: %v", err)
return
}
pass := func() bool {
host := "_tcp._zip.vet-services.easemesh.svc.cluster.local"
if (hostRE.MatchString(host)) != true {
fmt.Printf("failed at %s\n", host)
return false
}
host = "_zip.vet-services.easemesh.svc.cluster.local"
if hostRE.Match([]byte(host)) != true {
fmt.Printf("failed at %s\n", host)
return false
}
host = "_udp.vet-services.easemesh.svc.local"
if hostRE.Match([]byte(host)) != true {
fmt.Printf("failed at %s\n", host)
return false
}
host = "vet-services.easemesh.svc.local"
if hostRE.MatchString(host) != true {
fmt.Printf("failed at %s\n", host)
return false
}
host = "_tcp._zip.vetservices.easemesh.svc.cluster.local"
if hostRE.MatchString(host) != false {
fmt.Printf("failed at %s\n", host)
return false
}
host = "_tcp._zip.vet-services.easemesh.cluster.local"
if hostRE.MatchString(host) != false {
fmt.Printf("failed at %s\n", host)
return false
}
host = "_tcp._zip.vet-services.easemesh.svk.cluster.local"
if hostRE.MatchString(host) != false {
fmt.Printf("failed at %s\n", host)
return false
}
host = "_tcp._zip.vet-services.easemesh.svc"
if hostRE.MatchString(host) != false {
fmt.Printf("failed at %s\n", host)
return false
}
return true
}()
if pass {
fmt.Println("ok")
return
}
fmt.Println("failed")
}
Co-authored-by: Bomin Zhang <[email protected]>
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.
[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 299 Deploy Test Success
Co-authored-by: Bomin Zhang <[email protected]>
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.
[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 299 Deploy Test Success
EaseMesh sidecar egress enhancement: