POST pod regex to Hub if Kubeshark is still running

This commit is contained in:
M. Mert Yildiran 2023-01-22 04:33:30 +03:00
parent 4dd941f8d9
commit 6c69fb6bc4
No known key found for this signature in database
GPG Key ID: DA5D6DCBB758A461

View File

@ -85,7 +85,9 @@ func tap() {
if state.selfServiceAccountExists, err = resources.CreateHubResources(ctx, kubernetesProvider, config.Config.IsNsRestrictedMode(), config.Config.SelfNamespace, config.Config.Tap.Resources.Hub, config.Config.ImagePullPolicy(), config.Config.ImagePullSecrets(), config.Config.Tap.Debug); err != nil {
var statusError *k8serrors.StatusError
if errors.As(err, &statusError) && (statusError.ErrStatus.Reason == metav1.StatusReasonAlreadyExists) {
log.Warn().Msg(fmt.Sprintf("%s is already running in this namespace, change the `selfnamespace` configuration or run `%s clean` to remove the currently running %s instance", misc.Software, misc.Program, misc.Software))
log.Info().Msg(fmt.Sprintf("%s is already running in this namespace, change the `selfnamespace` configuration or run `%s clean` to remove the currently running %s instance.", misc.Software, misc.Program, misc.Software))
connector.PostRegexToHub(config.Config.Tap.PodRegexStr, state.targetNamespaces)
log.Info().Msg("Updated the targeted pods. Exiting.")
} else {
defer resources.CleanUpSelfResources(ctx, cancel, kubernetesProvider, config.Config.IsNsRestrictedMode(), config.Config.SelfNamespace)
log.Error().Err(errormessage.FormatError(err)).Msg("Error creating resources!")