Skip to content

Commit 7cf512a

Browse files
authored
fix(forwarder): preserve HTTP/HTTPS integrations on config sync (#2308)
SyncCollectorConfig was deleting HTTP/HTTPS-only integrations (e.g. github) on every service restart because they are not present in ProtoPorts. Added a guard to skip deletion when the integration has an active HTTP or HTTPS entry, since those are managed by enable-integration / disable-integration.
1 parent a6730a4 commit 7cf512a

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

collectors/forwarder/collector/config.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func SyncCollectorConfig() error {
5555

5656
for key := range cnf.Integrations {
5757
if _, exists := config.ProtoPorts[config.DataType(key)]; !exists {
58+
integration := cnf.Integrations[key]
59+
if integration.HTTP != nil || integration.HTTPS != nil {
60+
continue
61+
}
5862
delete(cnf.Integrations, key)
5963
modified = true
6064
utils.Logger.Info("Removed obsolete integration from config: %s", key)
@@ -252,8 +256,6 @@ func IsPortBindable(port string, proto string) bool {
252256
}
253257
}
254258

255-
256-
257259
func ChangeFileIntegrationStatus(logTyp string, isEnabled bool) ([]string, error) {
258260
cnf, err := schema.ReadCollectorConfig()
259261
if err != nil {
@@ -319,11 +321,11 @@ func GetFileIntegrationPaths(logTyp string) ([]string, error) {
319321
}
320322

321323
type HTTPIntegrationOptions struct {
322-
Proto string // "http" or "https"
323-
Port string
324-
Path string // URL path, default "/logs"
325-
Bind string // bind address, default "127.0.0.1"
326-
Auth string // "" | "bearer" | "hmac"
324+
Proto string // "http" or "https"
325+
Port string
326+
Path string // URL path, default "/logs"
327+
Bind string // bind address, default "127.0.0.1"
328+
Auth string // "" | "bearer" | "hmac"
327329
SignatureHeader string // e.g. "X-Hub-Signature-256"
328330
}
329331

@@ -352,11 +354,11 @@ func EnableHTTPIntegration(logTyp string, opts HTTPIntegrationOptions) error {
352354

353355
integration := cfg.Integrations[logTyp]
354356
httpPort := &schema.HTTPPort{
355-
Enabled: true,
356-
Port: opts.Port,
357-
Path: opts.Path,
358-
Bind: opts.Bind,
359-
Auth: opts.Auth,
357+
Enabled: true,
358+
Port: opts.Port,
359+
Path: opts.Path,
360+
Bind: opts.Bind,
361+
Auth: opts.Auth,
360362
SignatureHeader: opts.SignatureHeader,
361363
}
362364

0 commit comments

Comments
 (0)