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

add app mode testing server #22

Merged
merged 1 commit into from
Jun 28, 2023
Merged

add app mode testing server #22

merged 1 commit into from
Jun 28, 2023

Conversation

ii2day
Copy link
Collaborator

@ii2day ii2day commented Jun 14, 2023

No description provided.

@ii2day ii2day requested a review from weizhoublue as a code owner June 14, 2023 10:49
@ii2day ii2day added the pr/not-ready not ready for merging label Jun 14, 2023
@codecov
Copy link

codecov bot commented Jun 14, 2023

Codecov Report

Merging #22 (910c07f) into main (d606747) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #22   +/-   ##
=======================================
  Coverage   40.77%   40.77%           
=======================================
  Files           8        8           
  Lines         488      488           
=======================================
  Hits          199      199           
  Misses        285      285           
  Partials        4        4           
Flag Coverage Δ
unittests 40.77% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@panpan0000
Copy link

  1. can you elaborate the difference between this and k8s readinessProbe in the README.
  2. also doc the test summary of the distributed stress client.

@ii2day
Copy link
Collaborator Author

ii2day commented Jun 15, 2023

  1. can you elaborate the difference between this and k8s readinessProbe in the README.
  2. also doc the test summary of the distributed stress client.

1.This mode is used for kdoctor e2e testing, and readinessProbe still uses http
2.The report shows the request status of each client

@ii2day ii2day force-pushed the agent-api branch 3 times, most recently from 0cb2591 to 78cc141 Compare June 16, 2023 04:19
@ii2day ii2day changed the title add app mode https add app mode testing server Jun 16, 2023
@ii2day ii2day force-pushed the agent-api branch 2 times, most recently from cf17f54 to 002725e Compare June 16, 2023 06:07
@ii2day ii2day added release/feature-new and removed pr/not-ready not ready for merging labels Jun 16, 2023
@weizhoublue
Copy link
Collaborator

conflict

@ii2day
Copy link
Collaborator Author

ii2day commented Jun 19, 2023

conflict

done

@ii2day ii2day force-pushed the agent-api branch 5 times, most recently from d5710ff to 9bf3a72 Compare June 19, 2023 08:28
@@ -29,7 +29,11 @@ spec:
{{- end }}
{{- if .Values.feature.enableIPv4 }}
- name: http
port: {{ .Values.kdoctorAgent.httpServer.port }}
port: {{ .Values.kdoctorAgent.httpServer.healthPort }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

health 不需要 用 service 暴露出来

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

RequestMethod: r.HTTPRequest.Method,
ServerName: hostname,
RequestCount: atomic.LoadInt64(&requestCounts),
ParamDetail: ParamInformation,
Copy link
Collaborator

Choose a reason for hiding this comment

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

supported all method ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CONNECT 这个方法不支持 剩下的都支持

Copy link
Collaborator

Choose a reason for hiding this comment

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

我说 在 响应中 list 所有支持的 method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

}

func (s *echoGetHandler) Handle(r echo.GetParams) middleware.Responder {
s.logger.Sugar().Debugf("%s method %s request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

also print r.Delay

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

srvApp.TLSCertificateKey = flags.Filename(types.AgentConfig.TlsServerKeyPath)
}
} else {
srvApp.Port = int(types.AgentConfig.AgentAppPort)
Copy link
Collaborator

@weizhoublue weizhoublue Jun 19, 2023

Choose a reason for hiding this comment

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

if http {
logger.Sugar().Infof("setup agent app http server at port %v", types.AgentConfig.AgentAppPort)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

srvApp := server.NewServer(api)
srvApp.EnabledListeners = []string{types.AgentConfig.AgentAppProtocol}
if types.AgentConfig.AgentAppProtocol == "https" {
srvApp.TLSPort = int(types.AgentConfig.AgentAppPort)
Copy link
Collaborator

@weizhoublue weizhoublue Jun 19, 2023

Choose a reason for hiding this comment

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

logger.Sugar().Infof("setup agent app https server at port %v", types.AgentConfig.AgentAppPort)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -71,6 +71,10 @@ func init() {
globalFlag := rootCmd.PersistentFlags()
globalFlag.StringVarP(&types.AgentConfig.ConfigMapPath, "config-path", "C", "", "configmap file path")
globalFlag.BoolVarP(&types.AgentConfig.AppMode, "app-mode", "A", false, "app mode")
globalFlag.StringVarP(&types.AgentConfig.AgentAppProtocol, "app-protocol", "P", "http", "app mode protocol")
Copy link
Collaborator

Choose a reason for hiding this comment

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

AgentAppProtocol -> enableHttpTls : true / false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

if types.AgentConfig.AppMode {
// app mode, just used to debug
rootLogger.Info("run in app mode")
// sleep forever
select {}
} else {
rootLogger.Info("run in agent mode")

initGrpcServer()
Copy link
Collaborator

Choose a reason for hiding this comment

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

initGrpcServer also could be test in app mode

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

func SetupAppHttpServer() {
logger := rootLogger.Named("app http")

if types.AgentConfig.AgentAppPort == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

AgentAppPort -> AppHttpPort

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


srvApp := server.NewServer(api)
srvApp.EnabledListeners = []string{types.AgentConfig.AgentAppProtocol}
if types.AgentConfig.AgentAppProtocol == "https" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

when tls is enabled, http 1.1 and http2.0 is supported at the same time ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

同时支持

@ii2day ii2day force-pushed the agent-api branch 8 times, most recently from 1df2ff0 to dbee155 Compare June 25, 2023 08:54
@ii2day
Copy link
Collaborator Author

ii2day commented Jun 25, 2023

#32

@@ -167,7 +167,7 @@ kdoctorAgent:
ingressClass: ""

## @param kdoctorAgent.ingress.route the route of agent ingress. Default to "/kdoctoragent", if it changes, ingress please re-write url forwarded to "/kdoctoragent"
route: "/kdoctoragent"
Copy link
Collaborator

Choose a reason for hiding this comment

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

????

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -323,8 +327,31 @@ kdoctorAgent:
## @param kdoctorAgent.debug.gopsPort the gops port of template agent
gopsPort: 5712

## @section kdoctorController parameters
##
Copy link
Collaborator

Choose a reason for hiding this comment

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

????

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

test2: test2
kind: ConfigMap
metadata:
name: kdoctor-test-body
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

sed 's?<<EXAMPLE_APP_IMAGE>>?ghcr.io/kdoctor-io/kdoctor-agent:'$(PROJECT_IMAGE_VERSION)'?' yaml/testpod.yaml | kubectl --kubeconfig=$(KIND_KUBECONFIG) apply -f -
@ if ! kubectl rollout status daemonset/test --kubeconfig $(KIND_KUBECONFIG) -w --timeout=120s ; then \
sed 's?<<EXAMPLE_APP_IMAGE>>?ghcr.io/kdoctor-io/kdoctor-agent:'$(IMAGE_TAG)'?' yaml/testpod.yaml | kubectl --kubeconfig=$(KIND_KUBECONFIG) apply -f -
@ if ! kubectl rollout status daemonset/kdoctor-test -n kube-system --kubeconfig $(KIND_KUBECONFIG) -w --timeout=120s ; then \
Copy link
Collaborator

Choose a reason for hiding this comment

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

就一个 app,导致 CI 不能串行,否则 所有的压测数据都不准了

// Copyright 2023 Authors of kdoctor-io
// SPDX-License-Identifier: Apache-2.0

package cmd
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个实现 越来越大了,可 放到 pkg 中 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@ii2day ii2day force-pushed the agent-api branch 4 times, most recently from f0ee404 to cf5f327 Compare June 27, 2023 09:48
@@ -26,6 +26,21 @@ global:
## @param global.configName the configmap name
configName: "kdoctor"

## TLS configuration for kdoctor
tls:
Copy link
Collaborator

Choose a reason for hiding this comment

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

tls 不是 一个子层级,是一个 顶级的层级

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


## @param kdoctorAgent.tls.client.certExpiration server cert expiration
# in day, default 200 years
certExpiration: '73000'
Copy link
Collaborator

Choose a reason for hiding this comment

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

不需要了,我们没有 刷 新的机制,暴露给用户是累赘

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

var caKey *rsa.PrivateKey
var caDERBytes []byte
// ----------- generate self-signed ca
if caCertPath == "" && caKeyPath == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

||

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

}

alternateDNS = append(alternateDNS, types.AgentConfig.PodName)
logger.Sugar().Debugf("alternate ip %v", alternateIP)
Copy link
Collaborator

Choose a reason for hiding this comment

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

alternate ip for tls cert:
alternate dns for tls cert

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -71,6 +71,9 @@ func init() {
globalFlag := rootCmd.PersistentFlags()
globalFlag.StringVarP(&types.AgentConfig.ConfigMapPath, "config-path", "C", "", "configmap file path")
globalFlag.BoolVarP(&types.AgentConfig.AppMode, "app-mode", "A", false, "app mode")
globalFlag.BoolVarP(&types.AgentConfig.Insecure, "insecure", "K", true, "skip verify tls")
Copy link
Collaborator

Choose a reason for hiding this comment

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

tls-insecure

Signed-off-by: ii2day <ji.li@daocloud.io>
@weizhoublue weizhoublue merged commit 87f4ede into main Jun 28, 2023
@ii2day ii2day deleted the agent-api branch July 5, 2023 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants