Skip to content

Commit

Permalink
fix: move where logs aggregator is destroyed (#1110)
Browse files Browse the repository at this point in the history
## Description:
This ensures that log aggregator won't be removed by `kurtosis clean
-a`, but will be removed when you stop the engines.

## Is this change user facing?
NO (but now users won't have to restart the engine every time they want
to add an enclave after doing a `clean`)
  • Loading branch information
tedim52 committed Aug 14, 2023
1 parent 8ba54d0 commit aa392f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -803,9 +803,9 @@ jobs:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
steps:
- run:
name: "Verify only the engine container remains after the clean"
name: "Verify only the engine container and logs aggregator remains after the clean"
command: |
if ! [ "$(docker container ls -a | tail -n+2 | wc -l)" -eq 1 ]; then
if ! [ "$(docker container ls -a | tail -n+2 | wc -l)" -eq 2 ]; then
docker container ls -a
false
fi
Expand Down
Expand Up @@ -2,7 +2,6 @@ package engine_functions

import (
"context"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_aggregator_functions"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_operation_parallelizer"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/engine"
Expand Down Expand Up @@ -62,13 +61,5 @@ func DestroyEngines(
)
}

// This is a small hack so that the log aggregator isn't cleaned while trying to remove stopped engines (eg. kurtosis clean -a)
shouldRemoveLogComponents := len(matchingEnginesByContainerId) == 0
if shouldRemoveLogComponents {
if err := logs_aggregator_functions.DestroyLogsAggregator(ctx, dockerManager); err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred removing the logging components.")
}
}

return successfulGuids, erroredGuids, nil
}
Expand Up @@ -2,6 +2,7 @@ package engine_functions

import (
"context"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_aggregator_functions"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_operation_parallelizer"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/engine"
Expand Down Expand Up @@ -66,5 +67,10 @@ func StopEngines(
)
}

// Stop centralized logging components
if err := logs_aggregator_functions.DestroyLogsAggregator(ctx, dockerManager); err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred removing the logging components.")
}

return successfulGuids, erroredGuids, nil
}

0 comments on commit aa392f3

Please sign in to comment.