Fix clean again (#431)

* Revert "Fix mizu clean (#430)"

This reverts commit 57cd7a365b.

* Update cleanRunner.go and tapRunner.go
This commit is contained in:
RamiBerm 2021-11-04 14:47:48 +02:00 committed by GitHub
parent 57cd7a365b
commit 9a9e5fda0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -1,10 +1,12 @@
package cmd package cmd
import "github.com/up9inc/mizu/cli/apiserver"
func performCleanCommand() { func performCleanCommand() {
kubernetesProvider, err := getKubernetesProviderForCli() kubernetesProvider, err := getKubernetesProviderForCli()
if err != nil { if err != nil {
return return
} }
finishMizuExecution(kubernetesProvider) finishMizuExecution(kubernetesProvider, apiserver.NewProvider(GetApiServerUrl(), apiserver.DefaultRetries, apiserver.DefaultTimeout))
} }

View File

@ -41,10 +41,11 @@ type tapState struct {
} }
var state tapState var state tapState
var apiProvider = apiserver.NewProvider(GetApiServerUrl(), apiserver.DefaultRetries, apiserver.DefaultTimeout) var apiProvider *apiserver.Provider
func RunMizuTap() { func RunMizuTap() {
mizuApiFilteringOptions, err := getMizuApiFilteringOptions() mizuApiFilteringOptions, err := getMizuApiFilteringOptions()
apiProvider = apiserver.NewProvider(GetApiServerUrl(), apiserver.DefaultRetries, apiserver.DefaultTimeout)
if err != nil { if err != nil {
logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Error parsing regex-masking: %v", errormessage.FormatError(err))) logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Error parsing regex-masking: %v", errormessage.FormatError(err)))
return return
@ -133,13 +134,13 @@ func RunMizuTap() {
} }
if config.Config.Tap.DaemonMode { if config.Config.Tap.DaemonMode {
if err := handleDaemonModePostCreation(cancel, kubernetesProvider); err != nil { if err := handleDaemonModePostCreation(cancel, kubernetesProvider); err != nil {
defer finishMizuExecution(kubernetesProvider) defer finishMizuExecution(kubernetesProvider, apiProvider)
cancel() cancel()
} else { } else {
logger.Log.Infof(uiUtils.Magenta, "Mizu is now running in daemon mode, run `mizu view` to connect to the mizu daemon instance") logger.Log.Infof(uiUtils.Magenta, "Mizu is now running in daemon mode, run `mizu view` to connect to the mizu daemon instance")
} }
} else { } else {
defer finishMizuExecution(kubernetesProvider) defer finishMizuExecution(kubernetesProvider, apiProvider)
if err = startTapperSyncer(ctx, cancel, kubernetesProvider, targetNamespaces, *mizuApiFilteringOptions); err != nil { if err = startTapperSyncer(ctx, cancel, kubernetesProvider, targetNamespaces, *mizuApiFilteringOptions); err != nil {
logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Error starting mizu tapper syncer: %v", err)) logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Error starting mizu tapper syncer: %v", err))
@ -416,7 +417,7 @@ func getSyncEntriesConfig() *shared.SyncEntriesConfig {
} }
} }
func finishMizuExecution(kubernetesProvider *kubernetes.Provider) { func finishMizuExecution(kubernetesProvider *kubernetes.Provider, apiProvider *apiserver.Provider) {
telemetry.ReportAPICalls(apiProvider) telemetry.ReportAPICalls(apiProvider)
removalCtx, cancel := context.WithTimeout(context.Background(), cleanupTimeout) removalCtx, cancel := context.WithTimeout(context.Background(), cleanupTimeout)
defer cancel() defer cancel()