From eb60c8c5a8ca52188e0c06611389117c04467913 Mon Sep 17 00:00:00 2001 From: Jesse Hitch Date: Tue, 22 Oct 2024 16:20:13 +0200 Subject: [PATCH] Add sleep before syncs for mastodon (#325) * add extra sleep time between syncing for mastodon * update help screenshot * switch to 4 seconds instead of 5 for mastodon syncs --- docs/assets/images/screenshots/help_text.svg | 128 +++++++++---------- pyproject.toml | 2 +- smol_k8s_lab/k8s_apps/social/mastodon.py | 6 +- smol_k8s_lab/k8s_tools/argocd_util.py | 14 +- 4 files changed, 78 insertions(+), 72 deletions(-) diff --git a/docs/assets/images/screenshots/help_text.svg b/docs/assets/images/screenshots/help_text.svg index 73b5fd46a..d21ab6211 100644 --- a/docs/assets/images/screenshots/help_text.svg +++ b/docs/assets/images/screenshots/help_text.svg @@ -19,139 +19,139 @@ font-weight: 700; } - .terminal-3473103371-matrix { + .terminal-3736820236-matrix { font-family: Fira Code, monospace; font-size: 20px; line-height: 24.4px; font-variant-east-asian: full-width; } - .terminal-3473103371-title { + .terminal-3736820236-title { font-size: 18px; font-weight: bold; font-family: arial; } - .terminal-3473103371-r1 { fill: #c5c8c6 } -.terminal-3473103371-r2 { fill: #5f87ff } -.terminal-3473103371-r3 { fill: #5f87af;font-style: italic; } -.terminal-3473103371-r4 { fill: #5f87af } -.terminal-3473103371-r5 { fill: #8787ff } -.terminal-3473103371-r6 { fill: #afafff } -.terminal-3473103371-r7 { fill: #87afff } -.terminal-3473103371-r8 { fill: #afafff;font-weight: bold } -.terminal-3473103371-r9 { fill: #868887 } -.terminal-3473103371-r10 { fill: #6179a9 } -.terminal-3473103371-r11 { fill: #6161a9 } -.terminal-3473103371-r12 { fill: #7979a9;font-weight: bold } -.terminal-3473103371-r13 { fill: #4961a9 } + .terminal-3736820236-r1 { fill: #c5c8c6 } +.terminal-3736820236-r2 { fill: #5f87ff } +.terminal-3736820236-r3 { fill: #5f87af;font-style: italic; } +.terminal-3736820236-r4 { fill: #5f87af } +.terminal-3736820236-r5 { fill: #8787ff } +.terminal-3736820236-r6 { fill: #afafff } +.terminal-3736820236-r7 { fill: #87afff } +.terminal-3736820236-r8 { fill: #afafff;font-weight: bold } +.terminal-3736820236-r9 { fill: #868887 } +.terminal-3736820236-r10 { fill: #6179a9 } +.terminal-3736820236-r11 { fill: #6161a9 } +.terminal-3736820236-r12 { fill: #7979a9;font-weight: bold } +.terminal-3736820236-r13 { fill: #4961a9 } - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - term + term - + - -                           ๐Ÿงธsmol k8s lab - -Install slim Kubernetes distros + plus all your apps via Argo CD. - -Usage:smol-k8s-lab[OPTIONS] - -โ•ญโ”€ ส• แต”แดฅแต”ส” Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ -โ”‚โ”‚ -โ”‚-c--config CONFIG_FILEFull path and name of the YAML config file to parse.โ”‚ -โ”‚Defaults to                                         โ”‚ -โ”‚$XDG_CONFIG_HOME/smol-k8s-lab/config.yamlโ”‚ -โ”‚โ”‚ -โ”‚-D--delete CLUSTER_NAMEDelete an existing cluster by name.                 โ”‚ -โ”‚โ”‚ -โ”‚-i--interactiveโš™๏ธ Interactively configures smol-k8s-labโ”‚ -โ”‚โ”‚ -โ”‚-v--versionPrint the version of smol-k8s-lab (v5.17.3)         โ”‚ -โ”‚โ”‚ -โ”‚-f--final_cmdRun command immediately after smol-k8s-lab before   โ”‚ -โ”‚main cli phase                                      โ”‚ -โ”‚โ”‚ -โ”‚-h--helpShow this message and exit.                         โ”‚ -โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: https://small-hack.github.io/smol-k8s-labโ”€โ•ฏ + +                           ๐Ÿงธsmol k8s lab + +Install slim Kubernetes distros + plus all your apps via Argo CD. + +Usage:smol-k8s-lab[OPTIONS] + +โ•ญโ”€ ส• แต”แดฅแต”ส” Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ +โ”‚โ”‚ +โ”‚-c--config CONFIG_FILEFull path and name of the YAML config file to parse.โ”‚ +โ”‚Defaults to                                         โ”‚ +โ”‚$XDG_CONFIG_HOME/smol-k8s-lab/config.yamlโ”‚ +โ”‚โ”‚ +โ”‚-D--delete CLUSTER_NAMEDelete an existing cluster by name.                 โ”‚ +โ”‚โ”‚ +โ”‚-i--interactiveโš™๏ธ Interactively configures smol-k8s-labโ”‚ +โ”‚โ”‚ +โ”‚-v--versionPrint the version of smol-k8s-lab (v5.17.4)         โ”‚ +โ”‚โ”‚ +โ”‚-f--final_cmdRun command immediately after smol-k8s-lab before   โ”‚ +โ”‚main cli phase                                      โ”‚ +โ”‚โ”‚ +โ”‚-h--helpShow this message and exit.                         โ”‚ +โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: https://small-hack.github.io/smol-k8s-labโ”€โ•ฏ diff --git a/pyproject.toml b/pyproject.toml index a12d42627..ab85aeb7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "smol_k8s_lab" -version = "5.17.3" +version = "5.17.4" description = "CLI and TUI to quickly install slimmer Kubernetes distros and then manage apps declaratively using Argo CD" authors = ["Jesse Hitch ", "Max Roby "] diff --git a/smol_k8s_lab/k8s_apps/social/mastodon.py b/smol_k8s_lab/k8s_apps/social/mastodon.py index 9435206e3..1c30b2c4f 100644 --- a/smol_k8s_lab/k8s_apps/social/mastodon.py +++ b/smol_k8s_lab/k8s_apps/social/mastodon.py @@ -1,6 +1,6 @@ # internal libraries from smol_k8s_lab.bitwarden.bw_cli import BwCLI, create_custom_field -from smol_k8s_lab.k8s_apps.operators.minio import create_minio_alias, BetterMinio +from smol_k8s_lab.k8s_apps.operators.minio import create_minio_alias from smol_k8s_lab.k8s_apps.social.mastodon_secrets import generate_mastodon_secrets from smol_k8s_lab.k8s_tools.argocd_util import ArgoCD from smol_k8s_lab.k8s_tools.restores import restore_seaweedfs, restore_cnpg_cluster @@ -151,8 +151,8 @@ def configure_mastodon(argocd: ArgoCD, argocd.install_app('mastodon', cfg['argo']) elif init_enabled and not restore_enabled: argocd.install_app('mastodon', cfg['argo'], True) - # for for all the mastodon apps to come up - argocd.sync_app('mastodon-web-app') + # wait for all the mastodon apps to come up, give it extra time + argocd.sync_app(app='mastodon-web-app', sleep_time=4) argocd.wait_for_app('mastodon-web-app') # create admin credentials diff --git a/smol_k8s_lab/k8s_tools/argocd_util.py b/smol_k8s_lab/k8s_tools/argocd_util.py index 05ea1083e..d4cae70cc 100644 --- a/smol_k8s_lab/k8s_tools/argocd_util.py +++ b/smol_k8s_lab/k8s_tools/argocd_util.py @@ -3,6 +3,7 @@ from .k8s_lib import K8s from ..utils.run.subproc import subproc from json import loads +from time import sleep class ArgoCD(): @@ -44,7 +45,8 @@ def sync_app(self, app: str, spinner: bool = True, replace: bool = False, - force: bool = False) -> str: + force: bool = False, + sleep_time: int = 1) -> str: """ syncs an argocd app and returns the result """ @@ -58,9 +60,6 @@ def sync_app(self, counter = 0 while True: - if counter == 10: - log.error("Something has gone wrong with syncs! we tried 10 times!") - break # run sync command if spinner: res = subproc([cmd], error_ok=True) @@ -69,6 +68,13 @@ def sync_app(self, if "permission denied" not in res: return res + else: + if counter == 10: + log.error("Something has gone wrong with syncs! we tried 10 times!") + break + else: + log.error(f"Sleeping {sleep_time} seconds before next attempt to sync...") + sleep(sleep_time) counter += 1