Change latency spike
This commit is contained in:
parent
b82a8d37ee
commit
ee8837f101
2 changed files with 15 additions and 12 deletions
|
@ -360,7 +360,6 @@ spec:
|
||||||
- name: server
|
- name: server
|
||||||
# image: gcr.io/qwiklab-gke-debugging/productcatalogservice:v0.1.0
|
# image: gcr.io/qwiklab-gke-debugging/productcatalogservice:v0.1.0
|
||||||
image: gcr.io/cloud-ops-demo-app/productservice:latest
|
image: gcr.io/cloud-ops-demo-app/productservice:latest
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3550
|
- containerPort: 3550
|
||||||
env:
|
env:
|
||||||
|
@ -374,8 +373,8 @@ spec:
|
||||||
value: "1"
|
value: "1"
|
||||||
- name: ENABLE_RELOAD
|
- name: ENABLE_RELOAD
|
||||||
value: "1"
|
value: "1"
|
||||||
# - name: LATENCY_SPIKE
|
- name: LATENCY_SPIKE
|
||||||
# value: "1"
|
value: "1"
|
||||||
# - name: JAEGER_SERVICE_ADDR
|
# - name: JAEGER_SERVICE_ADDR
|
||||||
# value: "jaeger-collector:14268"
|
# value: "jaeger-collector:14268"
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -241,25 +241,29 @@ func (p *productCatalog) Watch(req *healthpb.HealthCheckRequest, ws healthpb.Hea
|
||||||
|
|
||||||
func (p *productCatalog) ListProducts(context.Context, *pb.Empty) (*pb.ListProductsResponse, error) {
|
func (p *productCatalog) ListProducts(context.Context, *pb.Empty) (*pb.ListProductsResponse, error) {
|
||||||
time.Sleep(extraLatency)
|
time.Sleep(extraLatency)
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
n := 3 * (1 + rand.Intn(20)) // n will be between 0 and v
|
|
||||||
time.Sleep(time.Duration(n)*time.Second)
|
|
||||||
return &pb.ListProductsResponse{Products: parseCatalog()}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *productCatalog) GetProduct(ctx context.Context, req *pb.GetProductRequest) (*pb.Product, error) {
|
|
||||||
if s := os.Getenv("LATENCY_SPIKE"); s != "" {
|
if s := os.Getenv("LATENCY_SPIKE"); s != "" {
|
||||||
// v, err := strconv.Atoi(s)
|
// v, err := strconv.Atoi(s)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Fatalf("faigit chaled to parse EXTRA_LATENCY (%s) as int: %+v", v, err)
|
// log.Fatalf("faigit chaled to parse EXTRA_LATENCY (%s) as int: %+v", v, err)
|
||||||
// }
|
// }
|
||||||
// rand.Seed(time.Now().UnixNano())
|
// rand.Seed(time.Now().UnixNano())
|
||||||
n := 3 * (1 + rand.Intn(10)) // n will be between 0 and v
|
n := 3 + rand.Intn(25) // n will be between 0 and v
|
||||||
time.Sleep(time.Duration(n)*time.Second)
|
time.Sleep(time.Duration(n)*time.Second)
|
||||||
log.Infof("extra latency enabled (duration: %v)", extraLatency)
|
log.Infof("extra latency enabled (duration: %v)", extraLatency)
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(extraLatency)
|
time.Sleep(extraLatency)
|
||||||
}
|
}
|
||||||
|
return &pb.ListProductsResponse{Products: parseCatalog()}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *productCatalog) GetProduct(ctx context.Context, req *pb.GetProductRequest) (*pb.Product, error) {
|
||||||
|
if s := os.Getenv("LATENCY_SPIKE"); s != "" {
|
||||||
|
n := 3 + rand.Intn(25) // n will be between 0 and v
|
||||||
|
time.Sleep(time.Duration(n)*time.Second)
|
||||||
|
log.Infof("extra latency enabled (duration: %v)", extraLatency)
|
||||||
|
} else {
|
||||||
|
time.Sleep(extraLatency)
|
||||||
|
}
|
||||||
var found *pb.Product
|
var found *pb.Product
|
||||||
for i := 0; i < len(parseCatalog()); i++ {
|
for i := 0; i < len(parseCatalog()); i++ {
|
||||||
if req.Id == parseCatalog()[i].Id {
|
if req.Id == parseCatalog()[i].Id {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue