forked from openservicemesh/osm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugger: refactor httpserver and debugger (openservicemesh#2308)
- Debugger specific code, logic and tests that was living in `httpserver` has been entirely moved to `debugger` package. - Some specific code related to metrics, probes and versioning that was also living in `httpserver` has been moved out in order to make `httpserver` reusable in both osm-controller and debugger HTTP server instances. - `Debugger` package now manages its own HTTP server, specified and opened on `constants.DebugPort`. - Updated E2E to repeat some iterations of the DebugServer on/off scenario. Signed-off-by: Eduard Serra <eduser25@gmail.com>
- Loading branch information
Showing
24 changed files
with
216 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package debugger | ||
|
||
import ( | ||
"github.com/openservicemesh/osm/pkg/announcements" | ||
"github.com/openservicemesh/osm/pkg/constants" | ||
"github.com/openservicemesh/osm/pkg/httpserver" | ||
"github.com/openservicemesh/osm/pkg/kubernetes/events" | ||
) | ||
|
||
// StartDebugServerConfigListener registers a go routine to listen to configuration and configure debug server as needed | ||
func (d *DebugConfig) StartDebugServerConfigListener() { | ||
// Subscribe to configuration updates | ||
ch := events.GetPubSubInstance().Subscribe( | ||
announcements.ConfigMapAdded, | ||
announcements.ConfigMapDeleted, | ||
announcements.ConfigMapUpdated) | ||
|
||
// This is the Debug server | ||
httpDebugServer := httpserver.NewHTTPServer(constants.DebugPort) | ||
httpDebugServer.AddHandlers(d.GetHandlers()) | ||
|
||
// Run config listener | ||
go func(cfgSubChannel chan interface{}, dConf *DebugConfig, httpServ *httpserver.HTTPServer) { | ||
// Bootstrap after subscribing | ||
started := false | ||
|
||
if d.configurator.IsDebugServerEnabled() { | ||
if err := httpDebugServer.Start(); err != nil { | ||
log.Error().Err(err).Msgf("error starting debug server") | ||
} | ||
started = true | ||
} | ||
|
||
for { | ||
<-cfgSubChannel | ||
isDbgSrvEnabled := d.configurator.IsDebugServerEnabled() | ||
|
||
if isDbgSrvEnabled && !started { | ||
if err := httpDebugServer.Start(); err != nil { | ||
log.Error().Err(err).Msgf("error starting debug server") | ||
} else { | ||
started = true | ||
} | ||
} | ||
if !isDbgSrvEnabled && started { | ||
if err := httpDebugServer.Stop(); err != nil { | ||
log.Error().Err(err).Msgf("error stoping debug server") | ||
} else { | ||
started = false | ||
} | ||
} | ||
} | ||
}(ch, d, httpDebugServer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.