-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat:add vlogs server. #5343
feat:add vlogs server. #5343
Conversation
🤖 Generated by lychee actionSummary
Full action output |
service/vlogs/Makefile
Outdated
@@ -0,0 +1,55 @@ | |||
IMG ?= ghcr.io/labring/sealos-launchpad-service:latest |
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.
change image name
service/vlogs/Makefile
Outdated
|
||
.PHONY: docker-build | ||
docker-build: build | ||
mv bin/manager bin/service-launchpad-${TARGETARCH} |
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.
change binary name
service/vlogs/README.md
Outdated
1. Build and push your image to the location specified by `IMG`: | ||
|
||
```sh | ||
make docker-build docker-push IMG=<some-registry>/sealos-cloud-database-monitor:tag |
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.
change name
env: | ||
- name: VM_SERVICE_HOST | ||
value: http://vmsingle-victoria-metrics-k8s-stack.vm.svc:8429 | ||
image: ghcr.io/labring/sealos-launchpad-service:latest |
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.
change name
kind: Service | ||
metadata: | ||
labels: | ||
app: launchpad-vlogs |
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
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.
already fix it.
service/vlogs/server/server.go
Outdated
if config, err := url.PathUnescape(kubeConfig); err == nil { | ||
kubeConfig = config | ||
} else { | ||
return "", "", "", 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.
return with fmt.Errorf("failed to PathUnescape : %s", err)
For different errors in the same method, please use format to wrap different error messages.
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.
already fix it.
service/vlogs/server/server.go
Outdated
vlogsReq := &api.VlogsRequest{} | ||
err := json.NewDecoder(req.Body).Decode(&vlogsReq) | ||
if err != nil { | ||
return "", "", "", errors.New("invalid JSON data,decode error") |
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.
The original error message is not included, replace with fmt.Errorf and include the original err information.
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.
already fix it.
service/vlogs/server/server.go
Outdated
return stream + generateCommonQuery(req) + builder.String() + generateDropQuery() + generateNumberQuery(req), nil | ||
} | ||
|
||
func generateStreamQuery(req *api.VlogsRequest) (string, error) { |
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.
Why is there no error return, but the return parameter needs to contain error?
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.
already fix it.
service/vlogs/server/server.go
Outdated
return builder.String() + stream + generateCommonQuery(req) + generateDropQuery() + generateNumberQuery(req), nil | ||
} | ||
|
||
func generateJsonQuery(req *api.VlogsRequest) (string, error) { |
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.
no error
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.
already fix it.
service/vlogs/request/req.go
Outdated
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("URL: %s\n", req.URL.String()) |
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.
use log.
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.
already fix it.
service/vlogs/server/server.go
Outdated
func (vl *VLogsServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { | ||
pathPrefix := "" | ||
switch { | ||
case req.URL.Path == pathPrefix+"/queryLogsByParams": | ||
vl.queryLogsByParams(rw, req) | ||
default: | ||
http.Error(rw, "Not found", http.StatusNotFound) | ||
return | ||
} | ||
} |
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.
pathPrefix 有啥用?
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.
already fix it.
service/vlogs/server/server.go
Outdated
// return | ||
//} | ||
|
||
fmt.Println("query: " + query) |
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.
用log,别用print
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.
already fix it.
service/vlogs/server/server.go
Outdated
if req.JsonMode == "true" { | ||
var builder strings.Builder | ||
builder.WriteString(" | unpack_json") | ||
if len(req.JsonQuery) > 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.
这个if没必要存在
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.
already fix it.
service/vlogs/server/server.go
Outdated
case "=": | ||
item = fmt.Sprintf("| %s:=%s ", jsonQuery.Key, jsonQuery.Value) | ||
case "!=": | ||
item = fmt.Sprintf("| %s:(!=%s) ", jsonQuery.Key, jsonQuery.Value) | ||
case "~": | ||
item = fmt.Sprintf("| %s:%s ", jsonQuery.Key, jsonQuery.Value) | ||
default: | ||
return errors.New("invalid JSON data,jsonMode value 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.
这些case在jsonquery定义处写上注释
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.
already fix it.
service/vlogs/server/server.go
Outdated
switch { | ||
case len(req.Pod) == 0 && len(req.Container) == 0: | ||
builder.WriteString(fmt.Sprintf(`{namespace="%s"}`, req.Namespace)) | ||
case len(req.Pod) == 0: | ||
addItems(req.Namespace, "container", req.Container) | ||
case len(req.Container) == 0: | ||
addItems(req.Namespace, "pod", req.Pod) | ||
default: | ||
for i, container := range req.Container { | ||
for j, pod := range req.Pod { | ||
builder.WriteString(fmt.Sprintf(`{container="%s",namespace="%s",pod="%s"}`, container, req.Namespace, pod)) | ||
if i != len(req.Container)-1 || j != len(req.Pod)-1 { | ||
builder.WriteString(" OR ") | ||
} | ||
} | ||
} | ||
} | ||
v.query += builder.String() |
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.
优化这段,如果是request定义导致这段代码不好写就改request定义
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.
already fix it.
- /config/config.yml | ||
command: | ||
- /manager | ||
image: bearslyricattack/vlogs:latest |
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.
change to system image hub
a394d13
to
d18160c
Compare
feat:add vlogs server feat:add vlogs server feat:add vlogs server feat:add vlogs server feat:websocket and auto shutdown server. feat: devbox websocket. feat: devbox websocket. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. fix vlogs bug. code fmt.
e9bc489
to
a56460c
Compare
No description provided.