-
Notifications
You must be signed in to change notification settings - Fork 502
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
dm-operator: support discovery dm-master service in current discovery service #3098
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3098 +/- ##
==========================================
+ Coverage 43.12% 43.24% +0.12%
==========================================
Files 156 159 +3
Lines 16924 17073 +149
==========================================
+ Hits 7298 7384 +86
- Misses 9001 9062 +61
- Partials 625 627 +2
Flags with carried forward coverage won't be shown. Click here to find out more. |
pkg/discovery/server/server.go
Outdated
@@ -44,6 +46,7 @@ func NewServer(pdControl pdapi.PDControlInterface, cli versioned.Interface, kube | |||
func (s *server) registerHandlers() { | |||
ws := new(restful.WebService) | |||
ws.Route(ws.GET("/new/{advertise-peer-url}").To(s.newHandler)) | |||
ws.Route(ws.GET("/newdm/{advertise-peer-url}").To(s.newDMHandler)) |
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.
is it possible to add a parameter to /new/{advertise-peer-url}
API for dm? e.g. service=dm
newHandler
and newDMHandler
are similar, we can avoid duplicate code if we can.
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.
addressed in 609e797
cli: cli, | ||
pdControl: pdControl, | ||
masterControl: masterControl, | ||
clusters: map[string]*clusterInfo{}, |
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.
Initialize dmClusters
here?
pkg/discovery/discovery.go
Outdated
return "", err | ||
} | ||
keyName := fmt.Sprintf("%s/%s", ns, dcName) | ||
// TODO: the replicas should be the total replicas of pd sets. |
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.
// TODO: the replicas should be the total replicas of pd sets. | |
// TODO: the replicas should be the total replicas of dm master set. |
pkg/discovery/server/server.go
Outdated
result, err = s.discovery.DiscoverDM(advertisePeerURL) | ||
default: | ||
klog.Errorf("invalid register-type %s", registerType) | ||
if err := resp.WriteError(http.StatusInternalServerError, err); err != nil { |
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.
Set err
to include the invalid register-type %s
message? It is nil here, right?
pkg/dmapi/dmapi.go
Outdated
return nil, fmt.Errorf("unable to list members info from dm-master, err: %s", listMemberResp.Msg) | ||
} | ||
if len(listMemberResp.ListMemberResp) != 1 { | ||
return nil, fmt.Errorf("invalid list members resp: %s", body) |
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.
Should we use string(body)
?
pkg/dmapi/master_control.go
Outdated
|
||
// MasterClientURL builds the url of master client | ||
func MasterClientURL(namespace Namespace, clusterName string, scheme string) string { | ||
return fmt.Sprintf("%s://%s-master.%s:2379", scheme, clusterName, string(namespace)) |
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.
2379
should be updated?
pkg/discovery/discovery.go
Outdated
} | ||
klog.Infof("dm advertisePeerUrl is: %s", advertisePeerUrl) | ||
strArr := strings.Split(advertisePeerUrl, ".") | ||
if len(strArr) != 4 { |
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.
IF we require the namespace to be the same as we have checked in L140, we can just take pd-0.pd-peer
as the URL to decrease the DNS queries.
pkg/discovery/server/server.go
Outdated
klog.Errorf("invalid register-type %s", registerType) | ||
if err := resp.WriteError(http.StatusInternalServerError, fmt.Errorf("invalid register-type %s", registerType)); err != nil { | ||
klog.Errorf("failed to writeError: %v", err) | ||
} |
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.
klog.Errorf("invalid register-type %s", registerType) | |
if err := resp.WriteError(http.StatusInternalServerError, fmt.Errorf("invalid register-type %s", registerType)); err != nil { | |
klog.Errorf("failed to writeError: %v", err) | |
} | |
err = fmt.Errorf("invalid register-type %s", registerType) | |
klog.Errorf("%v", err) | |
if werr := resp.WriteError(http.StatusInternalServerError, err); werr != nil { | |
klog.Errorf("failed to writeError: %v", werr) | |
} |
…b-operator into discoverySupportDM
…b-operator into discoverySupportDM
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.
LGTM
b7b0c31
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.
LGTM
What problem does this PR solve?
#2868
Support discovery dm-master service in current discovery service
What is changed and how does it work?
Check List
Tests
Code changes
Does this PR introduce a user-facing change?: