Skip to content

Commit ee28d98

Browse files
TylerHelmuthdragonlord93
authored andcommitted
[opampsupervisor] remove health check port (open-telemetry#39908)
1 parent a64f8bd commit ee28d98

18 files changed

+44
-177
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: opampsupervisor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remnove `agent.health_check_port`.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39908]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: The opampsupervisor no longer starts the collector with a default health check extension.
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

cmd/opampsupervisor/e2e_test.go

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,17 @@ func TestSupervisorStartsCollectorWithNoOpAMPServerWithNoLastRemoteConfig(t *tes
292292
},
293293
})
294294

295-
healthcheckPort, err := findRandomPort()
296-
require.NoError(t, err)
297-
298295
s := newSupervisor(t, "healthcheck_port", map[string]string{
299-
"url": server.addr,
300-
"storage_dir": storageDir,
301-
"healthcheck_port": fmt.Sprintf("%d", healthcheckPort),
302-
"local_config": filepath.Join("testdata", "collector", "nop_config.yaml"),
296+
"url": server.addr,
297+
"storage_dir": storageDir,
298+
"local_config": filepath.Join("testdata", "collector", "healthcheck_config.yaml"),
303299
})
304300
t.Cleanup(s.Shutdown)
305301
require.Nil(t, s.Start())
306302

307303
// Verify the collector runs eventually by pinging the healthcheck extension
308304
require.Eventually(t, func() bool {
309-
resp, err := http.DefaultClient.Get(fmt.Sprintf("http://localhost:%d", healthcheckPort))
305+
resp, err := http.DefaultClient.Get("http://localhost:13133")
310306
if err != nil {
311307
t.Logf("Failed healthcheck: %s", err)
312308
return false
@@ -1118,20 +1114,16 @@ func createHealthCheckCollectorConf(t *testing.T) (cfg *bytes.Buffer, hash []byt
11181114
templ, err := template.New("").Parse(string(colCfgTpl))
11191115
require.NoError(t, err)
11201116

1121-
port, err := findRandomPort()
1122-
11231117
var confmapBuf bytes.Buffer
11241118
err = templ.Execute(
11251119
&confmapBuf,
1126-
map[string]string{
1127-
"HealthCheckEndpoint": fmt.Sprintf("localhost:%d", port),
1128-
},
1120+
map[string]string{},
11291121
)
11301122
require.NoError(t, err)
11311123

11321124
h := sha256.Sum256(confmapBuf.Bytes())
11331125

1134-
return &confmapBuf, h[:], port
1126+
return &confmapBuf, h[:], 13133
11351127
}
11361128

11371129
// Wait for the Supervisor to connect to or disconnect from the OpAMP server
@@ -1593,8 +1585,7 @@ func TestSupervisorStopsAgentProcessWithEmptyConfigMap(t *testing.T) {
15931585
})
15941586

15951587
s := newSupervisor(t, "healthcheck_port", map[string]string{
1596-
"url": server.addr,
1597-
"healthcheck_port": "12345",
1588+
"url": server.addr,
15981589
})
15991590

16001591
require.Nil(t, s.Start())
@@ -1623,7 +1614,7 @@ func TestSupervisorStopsAgentProcessWithEmptyConfigMap(t *testing.T) {
16231614

16241615
// Use health check endpoint to determine if the collector is actually running
16251616
require.Eventually(t, func() bool {
1626-
resp, err := http.DefaultClient.Get("http://localhost:12345")
1617+
resp, err := http.DefaultClient.Get("http://localhost:13133")
16271618
if err != nil {
16281619
t.Logf("Failed agent healthcheck request: %s", err)
16291620
return false

cmd/opampsupervisor/specification/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,8 @@ agent:
167167
non_identifying_attributes:
168168
custom.attribute: "custom-value"
169169

170-
# The port the Collector's health check extension will be configured to use
171-
health_check_port:
172170

173-
# The port the Supervisor will start its OpAmp server on and the Collector's
171+
# The port the Supervisor will start its OpAmp server on and the Collector's
174172
# OpAmp extension will connect to
175173
opamp_server_port:
176174
```

cmd/opampsupervisor/supervisor/config/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ type Agent struct {
195195
Description AgentDescription `mapstructure:"description"`
196196
ConfigApplyTimeout time.Duration `mapstructure:"config_apply_timeout"`
197197
BootstrapTimeout time.Duration `mapstructure:"bootstrap_timeout"`
198-
HealthCheckPort int `mapstructure:"health_check_port"`
199198
OpAMPServerPort int `mapstructure:"opamp_server_port"`
200199
PassthroughLogs bool `mapstructure:"passthrough_logs"`
201200
ConfigFiles []string `mapstructure:"config_files"`
@@ -213,10 +212,6 @@ func (a Agent) Validate() error {
213212
return errors.New("agent::bootstrap_timeout must be positive")
214213
}
215214

216-
if a.HealthCheckPort < 0 || a.HealthCheckPort > 65535 {
217-
return errors.New("agent::health_check_port must be a valid port number")
218-
}
219-
220215
if a.OpAMPServerPort < 0 || a.OpAMPServerPort > 65535 {
221216
return errors.New("agent::opamp_server_port must be a valid port number")
222217
}

cmd/opampsupervisor/supervisor/config/config_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -226,32 +226,6 @@ func TestValidate(t *testing.T) {
226226
},
227227
expectedError: "agent::orphan_detection_interval must be positive",
228228
},
229-
{
230-
name: "Invalid health check port number",
231-
config: Supervisor{
232-
Server: OpAMPServer{
233-
Endpoint: "wss://localhost:9090/opamp",
234-
Headers: http.Header{
235-
"Header1": []string{"HeaderValue"},
236-
},
237-
TLSSetting: tlsConfig,
238-
},
239-
Agent: Agent{
240-
Executable: "${file_path}",
241-
OrphanDetectionInterval: 5 * time.Second,
242-
HealthCheckPort: 65536,
243-
ConfigApplyTimeout: 2 * time.Second,
244-
BootstrapTimeout: 5 * time.Second,
245-
},
246-
Capabilities: Capabilities{
247-
AcceptsRemoteConfig: true,
248-
},
249-
Storage: Storage{
250-
Directory: "/etc/opamp-supervisor/storage",
251-
},
252-
},
253-
expectedError: "agent::health_check_port must be a valid port number",
254-
},
255229
{
256230
name: "Zero value health check port number",
257231
config: Supervisor{
@@ -265,7 +239,6 @@ func TestValidate(t *testing.T) {
265239
Agent: Agent{
266240
Executable: "${file_path}",
267241
OrphanDetectionInterval: 5 * time.Second,
268-
HealthCheckPort: 0,
269242
ConfigApplyTimeout: 2 * time.Second,
270243
BootstrapTimeout: 5 * time.Second,
271244
},
@@ -290,7 +263,6 @@ func TestValidate(t *testing.T) {
290263
Agent: Agent{
291264
Executable: "${file_path}",
292265
OrphanDetectionInterval: 5 * time.Second,
293-
HealthCheckPort: 29848,
294266
ConfigApplyTimeout: 2 * time.Second,
295267
BootstrapTimeout: 5 * time.Second,
296268
},
@@ -564,7 +536,6 @@ agent:
564536
orphan_detection_interval: 10s
565537
config_apply_timeout: 8s
566538
bootstrap_timeout: 8s
567-
health_check_port: 8089
568539
opamp_server_port: 8090
569540
passthrough_logs: true
570541
@@ -609,7 +580,6 @@ telemetry:
609580
OrphanDetectionInterval: 10 * time.Second,
610581
ConfigApplyTimeout: 8 * time.Second,
611582
BootstrapTimeout: 8 * time.Second,
612-
HealthCheckPort: 8089,
613583
OpAMPServerPort: 8090,
614584
PassthroughLogs: true,
615585
Signature: DefaultSupervisor().Agent.Signature,

cmd/opampsupervisor/supervisor/healthchecker/healthchecker.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

cmd/opampsupervisor/supervisor/supervisor.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import (
5353

5454
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/commander"
5555
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/config"
56-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/healthchecker"
5756
)
5857

5958
var (
@@ -116,8 +115,6 @@ type Supervisor struct {
116115

117116
startedAt time.Time
118117

119-
healthChecker *healthchecker.HTTPHealthChecker
120-
121118
// Supervisor's own config.
122119
config config.Supervisor
123120

@@ -143,10 +140,6 @@ type Supervisor struct {
143140
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21078
144141
agentConfigOwnMetricsSection *atomic.Value
145142

146-
// agentHealthCheckEndpoint is the endpoint the Collector's health check extension
147-
// will listen on for health check requests from the Supervisor.
148-
agentHealthCheckEndpoint string
149-
150143
// Internal config state for agent use. See the [configState] struct for more details.
151144
cfgState *atomic.Value
152145

@@ -329,14 +322,6 @@ func (s *Supervisor) Start() error {
329322
return fmt.Errorf("could not get bootstrap info from the Collector: %w", err)
330323
}
331324

332-
healthCheckPort := s.config.Agent.HealthCheckPort
333-
if healthCheckPort == 0 {
334-
healthCheckPort, err = s.findRandomPort()
335-
if err != nil {
336-
return fmt.Errorf("could not find port for health check: %w", err)
337-
}
338-
}
339-
340325
s.opampServerPort, err = s.getSupervisorOpAMPServerPort()
341326
if err != nil {
342327
return fmt.Errorf("get opamp server port: %w", err)
@@ -360,8 +345,6 @@ func (s *Supervisor) Start() error {
360345
return fmt.Errorf("could not find port for health check: %w", err)
361346
}
362347

363-
s.agentHealthCheckEndpoint = fmt.Sprintf("localhost:%d", healthCheckPort)
364-
365348
s.telemetrySettings.Logger.Info("Supervisor starting",
366349
zap.String("id", s.persistentState.InstanceID.String()))
367350

@@ -1016,7 +999,6 @@ func (s *Supervisor) composeExtraLocalConfig() []byte {
1016999
resourceAttrs[attr.Key] = attr.Value.GetStringValue()
10171000
}
10181001
tplVars := map[string]any{
1019-
"Healthcheck": s.agentHealthCheckEndpoint,
10201002
"ResourceAttributes": resourceAttrs,
10211003
"SupervisorPort": s.opampServerPort,
10221004
}
@@ -1347,7 +1329,6 @@ func (s *Supervisor) startAgentCommand() (agentStartStatus, error) {
13471329
s.agentStartHealthCheckAttempts = 0
13481330
s.startedAt = time.Now()
13491331

1350-
s.healthChecker = healthchecker.NewHTTPHealthChecker(fmt.Sprintf("http://%s", s.agentHealthCheckEndpoint))
13511332
return agentStarting, nil
13521333
}
13531334

0 commit comments

Comments
 (0)