Quit if CLI fails to create the ConfigMap (#782)

Fixes a bug which causes the tap command to hang until timeout if Mizu
is missing the permission to create ConfigMaps, after printing a wrong
warning message which addresses the deprecated policy validation
feature.
This commit is contained in:
Nimrod Gilboa Markevich 2022-02-09 12:15:35 +02:00 committed by GitHub
parent 9318388101
commit f99a0b435e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,14 +16,16 @@ import (
)
func CreateTapMizuResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, serializedValidationRules string, serializedContract string, serializedMizuConfig string, isNsRestrictedMode bool, mizuResourcesNamespace string, agentImage string, syncEntriesConfig *shared.SyncEntriesConfig, maxEntriesDBSizeBytes int64, apiServerResources shared.Resources, imagePullPolicy core.PullPolicy, logLevel logging.Level) (bool, error) {
mizuServiceAccountExists := false
if !isNsRestrictedMode {
if err := createMizuNamespace(ctx, kubernetesProvider, mizuResourcesNamespace); err != nil {
return false, err
return mizuServiceAccountExists, err
}
}
if err := createMizuConfigmap(ctx, kubernetesProvider, serializedValidationRules, serializedContract, serializedMizuConfig, mizuResourcesNamespace); err != nil {
logger.Log.Warningf(uiUtils.Warning, fmt.Sprintf("Failed to create resources required for policy validation. Mizu will not validate policy rules. error: %v", errormessage.FormatError(err)))
return mizuServiceAccountExists, err
}
mizuServiceAccountExists, err := createRBACIfNecessary(ctx, kubernetesProvider, isNsRestrictedMode, mizuResourcesNamespace, []string{"pods", "services", "endpoints"})