From 94952cd1c7c7a96aeb41a728f360fe0c162f4893 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 7 Nov 2024 10:47:38 -0800 Subject: [PATCH 01/12] remove closeChannelWhenEmpty busy loop --- .../engine_functions/create_engine.go | 16 ++++++++++ .../persistent_volume_logs_database_client.go | 16 ++-------- ...istent_volume_logs_database_client_test.go | 4 ++- engine/server/engine/main.go | 32 ++++++++++++------- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go index 3096451b91..0cc596c907 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go @@ -169,6 +169,16 @@ func CreateEngine( ) } + pprofPortSpec, err := port_spec.NewPortSpec(6060, consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait, consts.EmptyApplicationURL) + if err != nil { + return nil, stacktrace.Propagate( + err, + "An error occurred creating the pprofs http port spec object using number '%v' and protocol '%v'", + 6060, + consts.EngineTransportProtocol.String(), + ) + } + engineAttrs, err := objAttrsProvider.ForEngineServer( engineGuid, consts.KurtosisInternalContainerGrpcPortId, @@ -205,11 +215,17 @@ func CreateEngine( return nil, stacktrace.Propagate(err, "An error occurred transforming the Enclave Manager API port spec to a Docker port") } + pprofDockerPort, err := shared_helpers.TransformPortSpecToDockerPort(pprofPortSpec) + if err != nil { + return nil, stacktrace.Propagate(err, "An error occurred transforming the pprof port spec to a Docker port") + } + usedPorts := map[nat.Port]docker_manager.PortPublishSpec{ privateGrpcDockerPort: docker_manager.NewManualPublishingSpec(grpcPortNum), enclaveManagerUIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerUIPort)), enclaveManagerAPIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerAPIPort)), restAPIDockerPort: docker_manager.NewManualPublishingSpec(engine.RESTAPIPortAddr), + pprofDockerPort: docker_manager.NewManualPublishingSpec(6060), } // Configure the debug port only if it's required diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go index 67bd58b6bb..16497b53c5 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go @@ -90,14 +90,13 @@ func (client *persistentVolumeLogsDatabaseClient) StreamUserServiceLogs( // this go routine handles the stream cancellation go func() { - //wait for stream go routine to end + // wait for stream go routine to end wgSenders.Wait() - // send all buffered log lines + // flush should send remainder of logs in the channel logLineSender.Flush() - // wait until the channel has been fully read/empty before closing it - closeChannelWhenEmpty(logsByKurtosisUserServiceUuidChan) + close(logsByKurtosisUserServiceUuidChan) close(streamErrChan) //then cancel the context @@ -174,12 +173,3 @@ func (client *persistentVolumeLogsDatabaseClient) streamServiceLogLines( shouldReturnAllLogs, numLogLines) } - -func closeChannelWhenEmpty(logsChan chan map[service.ServiceUUID][]logline.LogLine) { - for { - if len(logsChan) == 0 { - close(logsChan) - return - } - } -} diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go index d245581bde..21e898e30c 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go @@ -722,7 +722,9 @@ func executeStreamCallAndGetReceivedServiceLogLines( return nil, stacktrace.NewError("Receiving stream logs in the test has reached the '%v' time out", testTimeOut) case streamErr, isChanOpen := <-errChan: if !isChanOpen { - shouldReceiveStream = false + if len(userServiceLogsByUuidChan) == 0 { + shouldReceiveStream = false + } break } return nil, stacktrace.Propagate(streamErr, "Receiving streaming error.") diff --git a/engine/server/engine/main.go b/engine/server/engine/main.go index 4670968c54..69b21c42f5 100644 --- a/engine/server/engine/main.go +++ b/engine/server/engine/main.go @@ -8,18 +8,6 @@ package main import ( "context" "fmt" - "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/persistent_volume/file_layout" - "io/fs" - "math" - "net" - "net/http" - "os" - "path" - "path/filepath" - "runtime" - "strings" - "time" - "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" "github.com/kurtosis-tech/kurtosis/api/golang/engine/kurtosis_engine_rpc_api_bindings/kurtosis_engine_rpc_api_bindingsconnect" enclaveApi "github.com/kurtosis-tech/kurtosis/api/golang/http_rest/server/core_rest_api" @@ -39,6 +27,7 @@ import ( "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs" "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/kurtosis_backend" "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/persistent_volume" + "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/persistent_volume/file_layout" "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/persistent_volume/log_file_manager" "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/persistent_volume/logs_clock" "github.com/kurtosis-tech/kurtosis/engine/server/engine/centralized_logs/client_implementations/persistent_volume/stream_logs_strategy" @@ -57,6 +46,17 @@ import ( echomiddleware "github.com/labstack/echo/v4/middleware" "github.com/rs/cors" "github.com/sirupsen/logrus" + "io/fs" + "math" + "net" + "net/http" + _ "net/http/pprof" + "os" + "path" + "path/filepath" + "runtime" + "strings" + "time" ) const ( @@ -200,6 +200,14 @@ func runMain() error { return stacktrace.Propagate(err, "Failed to create an enclave manager for backend type '%v' and config '%+v'", serverArgs.KurtosisBackendType, backendConfig) } + // start server + go func() { + logrus.Info("Starting pprof server on :6060") + if err := http.ListenAndServe("0.0.0.0:6060", nil); err != nil { + logrus.Fatalf("pprof server failed: %v", err) + } + }() + go func() { envJsFilePath := filepath.Join(pathToStaticFolder, envJsFilename) envJsFilePathPerm := envJsFilePerm From 6b56048d8e7a09d5f1512f2f8a6c39af5e809c02 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 7 Nov 2024 10:54:07 -0800 Subject: [PATCH 02/12] lint --- .../engine_functions/create_engine.go | 9 +++++---- engine/server/engine/main.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go index 0cc596c907..20f7ce4738 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go @@ -31,6 +31,7 @@ const ( enclaveManagerUIPort = 9711 enclaveManagerAPIPort = 8081 engineDebugServerPort = 50102 // in ClI this is 50101 and 50103 for the APIC + pprofServerPort = 6060 maxWaitForEngineAvailabilityRetries = 40 timeBetweenWaitForEngineAvailabilityRetries = 2 * time.Second logsStorageDirPath = "/var/log/kurtosis/" @@ -169,12 +170,12 @@ func CreateEngine( ) } - pprofPortSpec, err := port_spec.NewPortSpec(6060, consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait, consts.EmptyApplicationURL) + pprofPortSpec, err := port_spec.NewPortSpec(pprofServerPort, consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait, consts.EmptyApplicationURL) if err != nil { return nil, stacktrace.Propagate( err, - "An error occurred creating the pprofs http port spec object using number '%v' and protocol '%v'", - 6060, + "An error occurred creating the pprof http port spec object using number '%v' and protocol '%v'", + pprofServerPort, consts.EngineTransportProtocol.String(), ) } @@ -225,7 +226,7 @@ func CreateEngine( enclaveManagerUIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerUIPort)), enclaveManagerAPIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerAPIPort)), restAPIDockerPort: docker_manager.NewManualPublishingSpec(engine.RESTAPIPortAddr), - pprofDockerPort: docker_manager.NewManualPublishingSpec(6060), + pprofDockerPort: docker_manager.NewManualPublishingSpec(pprofServerPort), } // Configure the debug port only if it's required diff --git a/engine/server/engine/main.go b/engine/server/engine/main.go index 69b21c42f5..5debe0bd20 100644 --- a/engine/server/engine/main.go +++ b/engine/server/engine/main.go @@ -73,6 +73,7 @@ const ( functionPathSeparator = "." emptyFunctionName = "" webappPortAddr = ":9711" + pprofPortAddr = ":6060" remoteBackendConfigFilename = "remote_backend_config.json" pathToStaticFolder = "/run/webapp" @@ -200,10 +201,9 @@ func runMain() error { return stacktrace.Propagate(err, "Failed to create an enclave manager for backend type '%v' and config '%+v'", serverArgs.KurtosisBackendType, backendConfig) } - // start server go func() { logrus.Info("Starting pprof server on :6060") - if err := http.ListenAndServe("0.0.0.0:6060", nil); err != nil { + if err := http.ListenAndServe(pprofPortAddr, nil); err != nil { logrus.Fatalf("pprof server failed: %v", err) } }() From f3f4a85dba601db9e64d141ef6ef4ceb510d1fbf Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 7 Nov 2024 22:58:55 -0800 Subject: [PATCH 03/12] read till chan is empty --- .../persistent_volume_logs_database_client_test.go | 6 +++--- .../server/engine/server/engine_connect_server_service.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go index 21e898e30c..ff2ea2813c 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go @@ -47,7 +47,7 @@ const ( notFoundedFilterText = "it shouldn't be found in the log lines" firstMatchRegexFilterStr = "Starting.*idempotently'" - testTimeOut = 2 * time.Minute + testTimeOut = 15 * time.Second doNotFollowLogs = false defaultYear = 2023 @@ -719,7 +719,7 @@ func executeStreamCallAndGetReceivedServiceLogLines( for shouldReceiveStream { select { case <-time.Tick(testTimeOut): - return nil, stacktrace.NewError("Receiving stream logs in the test has reached the '%v' time out", testTimeOut) + return receivedServiceLogsByUuid, nil case streamErr, isChanOpen := <-errChan: if !isChanOpen { if len(userServiceLogsByUuidChan) == 0 { @@ -729,7 +729,7 @@ func executeStreamCallAndGetReceivedServiceLogLines( } return nil, stacktrace.Propagate(streamErr, "Receiving streaming error.") case userServiceLogsByUuid, isChanOpen := <-userServiceLogsByUuidChan: - if !isChanOpen { + if !isChanOpen && len(userServiceLogsByUuidChan) == 0 { shouldReceiveStream = false break } diff --git a/engine/server/engine/server/engine_connect_server_service.go b/engine/server/engine/server/engine_connect_server_service.go index ea2d266e9e..25faf3f011 100644 --- a/engine/server/engine/server/engine_connect_server_service.go +++ b/engine/server/engine/server/engine_connect_server_service.go @@ -347,7 +347,7 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c //stream case case serviceLogsByServiceUuid, isChanOpen := <-serviceLogsByServiceUuidChan: //If the channel is closed means that the logs database client won't continue sending streams - if !isChanOpen { + if !isChanOpen && len(serviceLogsByServiceUuidChan) == 0 { logrus.Debug("Exiting the stream loop after receiving a close signal from the service logs by service UUID channel") return nil } From fdad7aa4b257bacb6fcd2219a917a5e218a81519 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 04:48:57 -0800 Subject: [PATCH 04/12] fix --- .../engine/server/engine_connect_server_service.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/server/engine/server/engine_connect_server_service.go b/engine/server/engine/server/engine_connect_server_service.go index 25faf3f011..7b40725544 100644 --- a/engine/server/engine/server/engine_connect_server_service.go +++ b/engine/server/engine/server/engine_connect_server_service.go @@ -358,16 +358,20 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c } //client cancel ctx case case <-contextWithCancel.Done(): + if len(serviceLogsByServiceUuidChan) == 0 { + return nil + } logrus.Debug("The user service logs stream has done") - return nil //error from logs database case case err, isChanOpen := <-errChan: if isChanOpen { logrus.Debug("Exiting the stream because an error from the logs database client was received through the error chan.") return stacktrace.Propagate(err, "An error occurred streaming user service logs.") } - logrus.Debug("Exiting the stream loop after receiving a close signal from the error chan") - return nil + if len(serviceLogsByServiceUuidChan) == 0 { + logrus.Debug("Exiting the stream loop after receiving a close signal from the error chan") + return nil + } } } } From 6165b667c7bafe5e3d8b64b680be8f69465773f0 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 09:58:35 -0800 Subject: [PATCH 05/12] trigger ci From f868ae99b8558e53bd13daab5a77ca4edf2ecf01 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 10:29:38 -0800 Subject: [PATCH 06/12] revert timeout --- .../persistent_volume_logs_database_client.go | 2 +- .../persistent_volume_logs_database_client_test.go | 4 ++-- engine/server/engine/server/engine_connect_server_service.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go index 16497b53c5..1afdd99f30 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client.go @@ -93,7 +93,7 @@ func (client *persistentVolumeLogsDatabaseClient) StreamUserServiceLogs( // wait for stream go routine to end wgSenders.Wait() - // flush should send remainder of logs in the channel + // flush should send remainder of logs in the buffer to the channel to be read logLineSender.Flush() close(logsByKurtosisUserServiceUuidChan) diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go index ff2ea2813c..0f5197b1c5 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go @@ -47,7 +47,7 @@ const ( notFoundedFilterText = "it shouldn't be found in the log lines" firstMatchRegexFilterStr = "Starting.*idempotently'" - testTimeOut = 15 * time.Second + testTimeOut = 2 * time.Minute doNotFollowLogs = false defaultYear = 2023 @@ -719,7 +719,7 @@ func executeStreamCallAndGetReceivedServiceLogLines( for shouldReceiveStream { select { case <-time.Tick(testTimeOut): - return receivedServiceLogsByUuid, nil + return nil, stacktrace.NewError("Receiving stream logs in the test has reached the '%v' time out", testTimeOut) case streamErr, isChanOpen := <-errChan: if !isChanOpen { if len(userServiceLogsByUuidChan) == 0 { diff --git a/engine/server/engine/server/engine_connect_server_service.go b/engine/server/engine/server/engine_connect_server_service.go index 7b40725544..0003c5482d 100644 --- a/engine/server/engine/server/engine_connect_server_service.go +++ b/engine/server/engine/server/engine_connect_server_service.go @@ -346,7 +346,8 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c select { //stream case case serviceLogsByServiceUuid, isChanOpen := <-serviceLogsByServiceUuidChan: - //If the channel is closed means that the logs database client won't continue sending streams + // If the channel is closed means that the logs database client won't continue sending streams + // but keep reading from it until the channel is empty if !isChanOpen && len(serviceLogsByServiceUuidChan) == 0 { logrus.Debug("Exiting the stream loop after receiving a close signal from the service logs by service UUID channel") return nil @@ -359,9 +360,9 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c //client cancel ctx case case <-contextWithCancel.Done(): if len(serviceLogsByServiceUuidChan) == 0 { + logrus.Debug("The user service logs stream has done") return nil } - logrus.Debug("The user service logs stream has done") //error from logs database case case err, isChanOpen := <-errChan: if isChanOpen { From f6f5320a7a3bd9b2b60b879ebfb557d1b06955fa Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 18:51:07 -0800 Subject: [PATCH 07/12] only wait on err chan --- .../persistent_volume_logs_database_client_test.go | 12 ++++++------ .../engine/server/engine_connect_server_service.go | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go index 0f5197b1c5..6e3d77c2a6 100644 --- a/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go +++ b/engine/server/engine/centralized_logs/client_implementations/persistent_volume/persistent_volume_logs_database_client_test.go @@ -721,15 +721,15 @@ func executeStreamCallAndGetReceivedServiceLogLines( case <-time.Tick(testTimeOut): return nil, stacktrace.NewError("Receiving stream logs in the test has reached the '%v' time out", testTimeOut) case streamErr, isChanOpen := <-errChan: - if !isChanOpen { - if len(userServiceLogsByUuidChan) == 0 { - shouldReceiveStream = false - } + if !isChanOpen && len(userServiceLogsByUuidChan) == 0 { + shouldReceiveStream = false break } - return nil, stacktrace.Propagate(streamErr, "Receiving streaming error.") + if isChanOpen && streamErr != nil { + return nil, stacktrace.Propagate(streamErr, "Receiving streaming error.") + } case userServiceLogsByUuid, isChanOpen := <-userServiceLogsByUuidChan: - if !isChanOpen && len(userServiceLogsByUuidChan) == 0 { + if !isChanOpen { shouldReceiveStream = false break } diff --git a/engine/server/engine/server/engine_connect_server_service.go b/engine/server/engine/server/engine_connect_server_service.go index 0003c5482d..281a80e9af 100644 --- a/engine/server/engine/server/engine_connect_server_service.go +++ b/engine/server/engine/server/engine_connect_server_service.go @@ -347,8 +347,7 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c //stream case case serviceLogsByServiceUuid, isChanOpen := <-serviceLogsByServiceUuidChan: // If the channel is closed means that the logs database client won't continue sending streams - // but keep reading from it until the channel is empty - if !isChanOpen && len(serviceLogsByServiceUuidChan) == 0 { + if !isChanOpen { logrus.Debug("Exiting the stream loop after receiving a close signal from the service logs by service UUID channel") return nil } @@ -359,10 +358,8 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c } //client cancel ctx case case <-contextWithCancel.Done(): - if len(serviceLogsByServiceUuidChan) == 0 { - logrus.Debug("The user service logs stream has done") - return nil - } + logrus.Debug("The user service logs stream is done.") + return nil //error from logs database case case err, isChanOpen := <-errChan: if isChanOpen { From cc7ec45a0323559b56f2ac89fcd644286e0fb8f6 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 18:52:54 -0800 Subject: [PATCH 08/12] format pprof port addr log --- engine/server/engine/main.go | 2 +- engine/server/engine/server/engine_connect_server_service.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/server/engine/main.go b/engine/server/engine/main.go index 5debe0bd20..73802259e8 100644 --- a/engine/server/engine/main.go +++ b/engine/server/engine/main.go @@ -202,7 +202,7 @@ func runMain() error { } go func() { - logrus.Info("Starting pprof server on :6060") + logrus.Infof("Starting pprof server on: %s", pprofPortAddr) if err := http.ListenAndServe(pprofPortAddr, nil); err != nil { logrus.Fatalf("pprof server failed: %v", err) } diff --git a/engine/server/engine/server/engine_connect_server_service.go b/engine/server/engine/server/engine_connect_server_service.go index 281a80e9af..c19df02394 100644 --- a/engine/server/engine/server/engine_connect_server_service.go +++ b/engine/server/engine/server/engine_connect_server_service.go @@ -346,7 +346,7 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c select { //stream case case serviceLogsByServiceUuid, isChanOpen := <-serviceLogsByServiceUuidChan: - // If the channel is closed means that the logs database client won't continue sending streams + //If the channel is closed means that the logs database client won't continue sending streams if !isChanOpen { logrus.Debug("Exiting the stream loop after receiving a close signal from the service logs by service UUID channel") return nil @@ -358,7 +358,7 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c } //client cancel ctx case case <-contextWithCancel.Done(): - logrus.Debug("The user service logs stream is done.") + logrus.Debug("The user service logs stream has done") return nil //error from logs database case case err, isChanOpen := <-errChan: From f4863e80829e07b608b4179d6ecb98da1c1c5f43 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 19:04:09 -0800 Subject: [PATCH 09/12] dont validate cloud kurtosis --- .../lib/user_support_constants/user_support_constants.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/container-engine-lib/lib/user_support_constants/user_support_constants.go b/container-engine-lib/lib/user_support_constants/user_support_constants.go index a50b590632..166b69f601 100644 --- a/container-engine-lib/lib/user_support_constants/user_support_constants.go +++ b/container-engine-lib/lib/user_support_constants/user_support_constants.go @@ -31,7 +31,6 @@ const ( FeedbackEmail = "feedback@" + OldDomain FeedbackEmailLink = "mailto:" + FeedbackEmail KurtosisTechTwitterProfileLink = "https://twitter.com/KurtosisTech" - KurtosisCloudLink = "https://cloud." + Domain // If you add new URLs above, make sure to add them to the urlsToValidateInTest below!!! // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING @@ -56,6 +55,5 @@ var urlsToValidateInTest = []string{ KurtosisDiscordUrl, KurtosisOnBoardCalendlyUrl, HowImportWorksLink, - KurtosisCloudLink, KurtosisTechTwitterProfileLink, } From a4445abd7d1ade088d152ea3490e020659b59411 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Nov 2024 19:09:30 -0800 Subject: [PATCH 10/12] remove use of cloud const --- cli/cli/commands/web/web.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cli/cli/commands/web/web.go b/cli/cli/commands/web/web.go index 3a4aafdfb9..2fb08b0419 100644 --- a/cli/cli/commands/web/web.go +++ b/cli/cli/commands/web/web.go @@ -7,9 +7,9 @@ import ( "github.com/kurtosis-tech/kurtosis/cli/cli/command_framework/lowlevel/flags" "github.com/kurtosis-tech/kurtosis/cli/cli/command_str_consts" "github.com/kurtosis-tech/kurtosis/cli/cli/helpers/multi_os_command_executor" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/user_support_constants" "github.com/kurtosis-tech/kurtosis/contexts-config-store/store" "github.com/kurtosis-tech/stacktrace" + "github.com/sirupsen/logrus" ) var WebCmd = &lowlevel.LowlevelKurtosisCommand{ @@ -35,9 +35,7 @@ func run(_ context.Context, _ *flags.ParsedFlags, _ *args.ParsedArgs) error { return stacktrace.Propagate(err, "tried fetching the current Kurtosis context but failed, we can't switch clusters without this information. This is a bug in Kurtosis") } if store.IsRemote(currentKurtosisContext) { - if err := multi_os_command_executor.OpenFile(user_support_constants.KurtosisCloudLink); err != nil { - return stacktrace.Propagate(err, "An error occurred while opening the Kurtosis Cloud Web UI") - } + logrus.Warn("Kurtosis Cloud has been deprecated. Switch to a local kurtosis context to use the local Kurtosis web UI instead.") } if err := multi_os_command_executor.OpenFile(webUILink); err != nil { From b3e60d472060f15b260ae482e96cb3f70918e3de Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 9 Nov 2024 16:12:58 -0800 Subject: [PATCH 11/12] remove extra pprof port --- .../engine_functions/create_engine.go | 17 ----------------- engine/server/engine/main.go | 8 -------- 2 files changed, 25 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go index 20f7ce4738..3096451b91 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/create_engine.go @@ -31,7 +31,6 @@ const ( enclaveManagerUIPort = 9711 enclaveManagerAPIPort = 8081 engineDebugServerPort = 50102 // in ClI this is 50101 and 50103 for the APIC - pprofServerPort = 6060 maxWaitForEngineAvailabilityRetries = 40 timeBetweenWaitForEngineAvailabilityRetries = 2 * time.Second logsStorageDirPath = "/var/log/kurtosis/" @@ -170,16 +169,6 @@ func CreateEngine( ) } - pprofPortSpec, err := port_spec.NewPortSpec(pprofServerPort, consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait, consts.EmptyApplicationURL) - if err != nil { - return nil, stacktrace.Propagate( - err, - "An error occurred creating the pprof http port spec object using number '%v' and protocol '%v'", - pprofServerPort, - consts.EngineTransportProtocol.String(), - ) - } - engineAttrs, err := objAttrsProvider.ForEngineServer( engineGuid, consts.KurtosisInternalContainerGrpcPortId, @@ -216,17 +205,11 @@ func CreateEngine( return nil, stacktrace.Propagate(err, "An error occurred transforming the Enclave Manager API port spec to a Docker port") } - pprofDockerPort, err := shared_helpers.TransformPortSpecToDockerPort(pprofPortSpec) - if err != nil { - return nil, stacktrace.Propagate(err, "An error occurred transforming the pprof port spec to a Docker port") - } - usedPorts := map[nat.Port]docker_manager.PortPublishSpec{ privateGrpcDockerPort: docker_manager.NewManualPublishingSpec(grpcPortNum), enclaveManagerUIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerUIPort)), enclaveManagerAPIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerAPIPort)), restAPIDockerPort: docker_manager.NewManualPublishingSpec(engine.RESTAPIPortAddr), - pprofDockerPort: docker_manager.NewManualPublishingSpec(pprofServerPort), } // Configure the debug port only if it's required diff --git a/engine/server/engine/main.go b/engine/server/engine/main.go index 73802259e8..558bbb21af 100644 --- a/engine/server/engine/main.go +++ b/engine/server/engine/main.go @@ -73,7 +73,6 @@ const ( functionPathSeparator = "." emptyFunctionName = "" webappPortAddr = ":9711" - pprofPortAddr = ":6060" remoteBackendConfigFilename = "remote_backend_config.json" pathToStaticFolder = "/run/webapp" @@ -201,13 +200,6 @@ func runMain() error { return stacktrace.Propagate(err, "Failed to create an enclave manager for backend type '%v' and config '%+v'", serverArgs.KurtosisBackendType, backendConfig) } - go func() { - logrus.Infof("Starting pprof server on: %s", pprofPortAddr) - if err := http.ListenAndServe(pprofPortAddr, nil); err != nil { - logrus.Fatalf("pprof server failed: %v", err) - } - }() - go func() { envJsFilePath := filepath.Join(pathToStaticFolder, envJsFilename) envJsFilePathPerm := envJsFilePerm From 1fa587a0b0d0e8ac7facee6ff044e5d8afbe5bae Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 9 Nov 2024 16:45:15 -0800 Subject: [PATCH 12/12] register pprof endpoint w web app port 9711 --- engine/server/engine/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/server/engine/main.go b/engine/server/engine/main.go index 558bbb21af..936bf24aa9 100644 --- a/engine/server/engine/main.go +++ b/engine/server/engine/main.go @@ -73,6 +73,7 @@ const ( functionPathSeparator = "." emptyFunctionName = "" webappPortAddr = ":9711" + pprofPath = "/debug/pprof/" remoteBackendConfigFilename = "remote_backend_config.json" pathToStaticFolder = "/run/webapp" @@ -213,8 +214,9 @@ func runMain() error { } logrus.Debugf("Created environment js file with content: \n%s", envJsFileContent) + handler := http.NewServeMux() fileServer := http.FileServer(http.Dir(pathToStaticFolder)) - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + handler.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { path, err := filepath.Abs(r.URL.Path) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) @@ -236,6 +238,7 @@ func runMain() error { w.Header().Add("Cache-Control", "no-store") fileServer.ServeHTTP(w, r) }) + handler.Handle(pprofPath, http.HandlerFunc(http.DefaultServeMux.ServeHTTP)) err := http.ListenAndServe(webappPortAddr, handler) if err != nil {