From 2f24b24cee1d78cdacee09d539a4410b4f6a88c2 Mon Sep 17 00:00:00 2001 From: Wayne Starr Date: Sat, 29 Jul 2023 10:36:22 -0500 Subject: [PATCH 1/5] Fix the bug with registry push/pull on detected but invalid clusters --- src/cmd/tools/crane.go | 9 +++++---- src/config/lang/english.go | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cmd/tools/crane.go b/src/cmd/tools/crane.go index 8a9b82d445..d7461eef7f 100644 --- a/src/cmd/tools/crane.go +++ b/src/cmd/tools/crane.go @@ -56,7 +56,7 @@ func init() { if platform != "all" { v1Platform, err = v1.ParsePlatform(platform) if err != nil { - message.Fatalf(err, lang.CmdToolsRegistryInvalidPlatformErr, err.Error()) + message.Fatalf(err, lang.CmdToolsRegistryInvalidPlatformErr, platform, err.Error()) } } @@ -137,7 +137,7 @@ func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command wrappedCommand.RunE = func(cmd *cobra.Command, args []string) error { if len(args) < imageNameArgumentIndex+1 { - message.Fatal(nil, lang.CmdToolsCraneNotEnoughArgumentsSpecified) + message.Fatal(nil, lang.CmdToolsCraneNotEnoughArgumentsErr) } // Try to connect to a Zarf initialized cluster otherwise then pass it down to crane. @@ -146,10 +146,11 @@ func zarfCraneInternalWrapper(commandToWrap func(*[]crane.Option) *cobra.Command return originalListFn(cmd, args) } - // Load the state + // Load the state (if able) zarfState, err := zarfCluster.LoadZarfState() if err != nil { - return err + message.Warnf(lang.CmdToolsCraneConnectedButBadStateErr, err.Error()) + return originalListFn(cmd, args) } // Check to see if it matches the existing internal address. diff --git a/src/config/lang/english.go b/src/config/lang/english.go index e3287a6dd1..5ab24d2c93 100644 --- a/src/config/lang/english.go +++ b/src/config/lang/english.go @@ -375,7 +375,8 @@ const ( CmdToolsClearCacheSuccess = "Successfully cleared the cache from %s" CmdToolsClearCacheFlagCachePath = "Specify the location of the Zarf artifact cache (images and git repositories)" - CmdToolsCraneNotEnoughArgumentsSpecified = "You do not have enough arguments specified." + CmdToolsCraneNotEnoughArgumentsErr = "You do not have enough arguments specified for this command" + CmdToolsCraneConnectedButBadStateErr = "Detected a K8s cluster but was unable to get Zarf state - continuing without state information: %s" CmdToolsDownloadInitShort = "Downloads the init package for the current Zarf version into the specified directory" CmdToolsDownloadInitFlagOutputDirectory = "Specify a directory to place the init package in." @@ -421,7 +422,7 @@ const ( zarf tools wait-for http google.com success # wait for any 2xx response from http://google.com ` CmdToolsWaitForFlagTimeout = "Specify the timeout duration for the wait command." - CmdToolsWaitForErrTimeoutString = "Invalid timeout duration. Please use a valid duration string (e.g. 1s, 2m, 3h)." + CmdToolsWaitForErrTimeoutString = "Invalid timeout duration '%s'. Please use a valid duration string (e.g. 1s, 2m, 3h)." CmdToolsWaitForErrTimeout = "Wait timed out." CmdToolsWaitForErrConditionString = "Invalid HTTP status code. Please use a valid HTTP status code (e.g. 200, 404, 500)." CmdToolsWaitForErrZarfPath = "Could not locate the current Zarf binary path." @@ -513,7 +514,7 @@ const ( var ( ErrInitNotFound = errors.New("this command requires a zarf-init package, but one was not found on the local system. Re-run the last command again without '--confirm' to download the package") ErrUnableToCheckArch = errors.New("unable to get the configured cluster's architecture") - ErrInterrupt = errors.New("Failed due to interrupt") + ErrInterrupt = errors.New("execution cancelled due to an interrupt") ) // Collection of reusable warn messages. From e44bd2090f5b4cac3c37804932238ca80775f47c Mon Sep 17 00:00:00 2001 From: Wayne Starr Date: Sat, 29 Jul 2023 11:26:20 -0500 Subject: [PATCH 2/5] Temporarily lower the Helm timeout to allow BB to fail earlier --- src/internal/packager/helm/chart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 97a589bb1f..d14a97a662 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -30,7 +30,7 @@ import ( ) // Set the default helm client timeout to 15 minutes -const defaultClientTimeout = 15 * time.Minute +const defaultClientTimeout = 5 * time.Minute // InstallOrUpgradeChart performs a helm install of the given chart. func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) { From dedbf62bd45eea5535f133eed24b3a42eb81ad55 Mon Sep 17 00:00:00 2001 From: Wayne Starr Date: Tue, 1 Aug 2023 10:56:09 -0500 Subject: [PATCH 3/5] Lower the helm timeout further --- src/internal/packager/helm/chart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index d14a97a662..86d67b6d83 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -30,7 +30,7 @@ import ( ) // Set the default helm client timeout to 15 minutes -const defaultClientTimeout = 5 * time.Minute +const defaultClientTimeout = 3 * time.Minute // InstallOrUpgradeChart performs a helm install of the given chart. func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) { From 24a22ab01fda430a7bcb2c499d26c6b741d7635c Mon Sep 17 00:00:00 2001 From: Wayne Starr Date: Tue, 1 Aug 2023 12:31:02 -0500 Subject: [PATCH 4/5] Reduce CPU requests / limits for flux --- .../package/flux-overrides-helm-controller.yaml | 8 ++++---- .../flux-overrides-kustomize-controller.yaml | 17 +++++++++++++++++ .../flux-overrides-notification-controller.yaml | 17 +++++++++++++++++ .../flux-overrides-source-controller.yaml | 6 +++--- src/extensions/bigbang/test/package/zarf.yaml | 2 ++ 5 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/extensions/bigbang/test/package/flux-overrides-kustomize-controller.yaml create mode 100644 src/extensions/bigbang/test/package/flux-overrides-notification-controller.yaml diff --git a/src/extensions/bigbang/test/package/flux-overrides-helm-controller.yaml b/src/extensions/bigbang/test/package/flux-overrides-helm-controller.yaml index db49be63ec..d5e68feaee 100644 --- a/src/extensions/bigbang/test/package/flux-overrides-helm-controller.yaml +++ b/src/extensions/bigbang/test/package/flux-overrides-helm-controller.yaml @@ -10,8 +10,8 @@ spec: - name: manager resources: limits: - cpu: 500m - memory: 1Gi + cpu: 200m + memory: 256Mi requests: - cpu: 500m - memory: 1Gi + cpu: 100m + memory: 64Mi diff --git a/src/extensions/bigbang/test/package/flux-overrides-kustomize-controller.yaml b/src/extensions/bigbang/test/package/flux-overrides-kustomize-controller.yaml new file mode 100644 index 0000000000..22e1d7d16b --- /dev/null +++ b/src/extensions/bigbang/test/package/flux-overrides-kustomize-controller.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kustomize-controller + namespace: flux-system +spec: + template: + spec: + containers: + - name: manager + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 64Mi diff --git a/src/extensions/bigbang/test/package/flux-overrides-notification-controller.yaml b/src/extensions/bigbang/test/package/flux-overrides-notification-controller.yaml new file mode 100644 index 0000000000..a2476b01d2 --- /dev/null +++ b/src/extensions/bigbang/test/package/flux-overrides-notification-controller.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: notification-controller + namespace: flux-system +spec: + template: + spec: + containers: + - name: manager + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 64Mi diff --git a/src/extensions/bigbang/test/package/flux-overrides-source-controller.yaml b/src/extensions/bigbang/test/package/flux-overrides-source-controller.yaml index f20c351c5d..292492775a 100644 --- a/src/extensions/bigbang/test/package/flux-overrides-source-controller.yaml +++ b/src/extensions/bigbang/test/package/flux-overrides-source-controller.yaml @@ -11,7 +11,7 @@ spec: resources: limits: cpu: 100m - memory: 384Mi + memory: 256Mi requests: - cpu: 100m - memory: 384Mi + cpu: 50m + memory: 64Mi diff --git a/src/extensions/bigbang/test/package/zarf.yaml b/src/extensions/bigbang/test/package/zarf.yaml index b90bc9953c..426fed8f54 100644 --- a/src/extensions/bigbang/test/package/zarf.yaml +++ b/src/extensions/bigbang/test/package/zarf.yaml @@ -21,6 +21,8 @@ components: fluxPatchFiles: - flux-overrides-helm-controller.yaml - flux-overrides-source-controller.yaml + - flux-overrides-kustomize-controller.yaml + - flux-overrides-notification-controller.yaml valuesFiles: - disable-all-bb###ZARF_PKG_TMPL_BB_MAJOR###.yaml - enable-twistlock.yaml From a4ff777ee27f6ef089f5c7f67af9f065101cddb6 Mon Sep 17 00:00:00 2001 From: Wayne Starr Date: Tue, 1 Aug 2023 12:51:26 -0500 Subject: [PATCH 5/5] Revert helm timeout shortening --- src/internal/packager/helm/chart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 86d67b6d83..97a589bb1f 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -30,7 +30,7 @@ import ( ) // Set the default helm client timeout to 15 minutes -const defaultClientTimeout = 3 * time.Minute +const defaultClientTimeout = 15 * time.Minute // InstallOrUpgradeChart performs a helm install of the given chart. func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) {