Skip to content

Commit c134d9d

Browse files
committed
stop chan in port forwarder
1 parent bb55ee7 commit c134d9d

File tree

5 files changed

+21
-35
lines changed

5 files changed

+21
-35
lines changed

test/e2e/framework/kubernetes/create-kapinger-deployment.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (c *CreateKapingerDeployment) GetKapingerDeployment() *appsv1.Deployment {
146146
Containers: []v1.Container{
147147
{
148148
Name: "kapinger",
149-
Image: "acnpublic.azurecr.io/kapinger:20241011.3",
149+
Image: "acnpublic.azurecr.io/kapinger:20241011.4",
150150
Resources: v1.ResourceRequirements{
151151
Requests: v1.ResourceList{
152152
"memory": resource.MustParse("20Mi"),
@@ -210,17 +210,6 @@ func (c *CreateKapingerDeployment) GetKapingerDeployment() *appsv1.Deployment {
210210
Value: c.BurstVolume,
211211
},
212212
},
213-
LivenessProbe: &v1.Probe{
214-
ProbeHandler: v1.ProbeHandler{
215-
HTTPGet: &v1.HTTPGetAction{
216-
Path: "/",
217-
Port: intstr.FromInt(KapingerHTTPPort),
218-
},
219-
},
220-
TimeoutSeconds: 10, //nolint
221-
PeriodSeconds: 10, //nolint
222-
InitialDelaySeconds: 3, //nolint
223-
},
224213
},
225214
},
226215
},

test/e2e/framework/kubernetes/port-forward.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,17 @@ func (p *PortForward) Run() error {
110110

111111
log.Printf("port forward validation HTTP request to \"%s\" succeeded, response: %s\n", p.pf.Address(), resp.Status)
112112

113+
log.Printf("starting keepalive for port forward...\n")
114+
go p.pf.KeepAlive(pctx)
113115
return nil
114116
}
115117

116118
if err = defaultRetrier.Do(portForwardCtx, portForwardFn); err != nil {
117119
return fmt.Errorf("could not start port forward within %ds: %w", defaultTimeoutSeconds, err)
118120
}
119121
log.Printf("successfully port forwarded to \"%s\"\n", p.pf.Address())
122+
log.Printf("starting port forward keepalive...\n")
123+
go p.pf.KeepAlive(pctx)
120124
return nil
121125
}
122126

test/e2e/framework/kubernetes/portforward.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ func (p *PortForwarder) KeepAlive(ctx context.Context) {
171171
case <-ctx.Done():
172172
p.logger.Logf("port forwarder: keep alive cancelled: %v", ctx.Err())
173173
return
174+
case <-p.stopChan:
175+
p.logger.Logf("port forwarder: keep alive stopped via stop channel")
176+
return
174177
case pfErr := <-p.errChan:
175178
// as of client-go v0.26.1, if the connection is successful at first but then fails,
176179
// an error is logged but only a nil error is sent to this channel. this will be fixed

test/e2e/framework/kubernetes/pprof.go

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import (
99
"net/url"
1010
"os"
1111
"strconv"
12-
"sync"
1312
"time"
1413
)
1514

1615
const (
17-
defaultTimeout = 30 * time.Second
16+
defaultTimeout = 3200 * time.Second
1817
defaultRetinaPort = 10093
1918
defaultSpanTime = 10 * time.Second
2019
)
@@ -96,22 +95,15 @@ func (p *PullPProf) Run() error {
9695
}
9796
}
9897

99-
var wg sync.WaitGroup
100-
10198
for name, path := range durationProfiles {
102-
wg.Add(1)
103-
go func(name, path string) {
104-
file := folder + name + ".out"
105-
err = p.scraper.GetProfileWithDuration(name, path, file, defaultSpanTime)
106-
if err != nil {
107-
// don't return here because some data is better than no data,
108-
// and other profiles might be functional
109-
log.Printf("error getting %s profile: %v\n", name, err)
110-
}
111-
wg.Done()
112-
}(name, path)
99+
file := folder + name + ".out"
100+
err = p.scraper.GetProfileWithDuration(name, path, file, defaultSpanTime)
101+
if err != nil {
102+
// don't return here because some data is better than no data,
103+
// and other profiles might be functional
104+
log.Printf("error getting %s profile: %v\n", name, err)
105+
}
113106
}
114-
wg.Wait()
115107

116108
log.Printf("-- finished scraping profiles, saved to to %s --\n", folder)
117109
log.Printf("waiting %s seconds for next scrape\n", p.ScrapeIntervalSeconds)
@@ -166,12 +158,12 @@ func (p *PprofScraper) GetProfileWithDuration(name, path, outfile string, durati
166158
log.Printf("getting %s profile for %d seconds...\n", name, seconds)
167159
profileURL := p.formatURLWithSeconds(seconds)
168160
profileURL.Path += path
169-
return p.scrape(profileURL.String(), defaultTimeout+duration, outfile)
161+
return p.scrape(profileURL.String(), outfile)
170162
}
171163

172164
func (p *PprofScraper) GetProfile(name, path, outfile string) error {
173165
log.Printf("getting %s profile...\n", name)
174-
return p.scrape(p.baseURL.String()+path, defaultTimeout, outfile)
166+
return p.scrape(p.baseURL.String()+path, outfile)
175167
}
176168

177169
func (p *PprofScraper) formatURLWithSeconds(seconds int) url.URL {
@@ -183,10 +175,8 @@ func (p *PprofScraper) formatURLWithSeconds(seconds int) url.URL {
183175
return queryURL
184176
}
185177

186-
func (p *PprofScraper) scrape(scrapingURL string, timeout time.Duration, outfile string) error {
187-
client := http.Client{
188-
Timeout: timeout,
189-
}
178+
func (p *PprofScraper) scrape(scrapingURL, outfile string) error {
179+
client := http.Client{}
190180

191181
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, scrapingURL, http.NoBody)
192182
if err != nil {

test/e2e/scenarios/longrunning/scenario.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func PullPProf(kubeConfigFilePath string) *types.Scenario {
1717
KapingerReplicas: "500",
1818
KubeConfigFilePath: kubeConfigFilePath,
1919
BurstIntervalMs: "10000", // 10 seconds
20-
BurstVolume: "10", // 500 requests every 10 seconds
20+
BurstVolume: "200", // 500 requests every 10 seconds
2121
},
2222
},
2323
{

0 commit comments

Comments
 (0)