From ec1bc9fd7dcf110b9153437c556e89a9bed03ae8 Mon Sep 17 00:00:00 2001 From: XmasApple Date: Thu, 7 Sep 2023 18:03:22 +0300 Subject: [PATCH] add retry for `slo create` command --- .github/workflows/slo.yml | 4 ++-- slo/src/Cli/CliCommands.cs | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/slo.yml b/.github/workflows/slo.yml index 27909df1..c5c8f4d5 100644 --- a/.github/workflows/slo.yml +++ b/.github/workflows/slo.yml @@ -1,6 +1,6 @@ on: push: - # branches: [main] + branches: [main] pull_request: branches: [main] workflow_dispatch: @@ -29,7 +29,7 @@ jobs: DOCKER_REPO: ${{ secrets.SLO_DOCKER_REPO }} - name: Run SLO - uses: ydb-platform/slo-tests@php-version + uses: ydb-platform/slo-tests@js-version if: env.DOCKER_REPO != null env: DOCKER_REPO: ${{ secrets.SLO_DOCKER_REPO }} diff --git a/slo/src/Cli/CliCommands.cs b/slo/src/Cli/CliCommands.cs index d5b9297f..cb5d5183 100644 --- a/slo/src/Cli/CliCommands.cs +++ b/slo/src/Cli/CliCommands.cs @@ -1,5 +1,3 @@ -using System.Reflection; -using System.Text.RegularExpressions; using Prometheus; using slo.Jobs; using Ydb.Sdk; @@ -24,8 +22,22 @@ internal static async Task Create(CreateConfig createConfig) var executor = new Executor(tableClient); var table = new Table(createConfig.TableName, executor); - await table.Init(createConfig.InitialDataCount, createConfig.PartitionSize, createConfig.MinPartitionsCount, - createConfig.MaxPartitionsCount); + const int maxCreateAttempts = 10; + for (var i = 0; i < maxCreateAttempts; i++) + { + try + { + await table.Init(createConfig.InitialDataCount, createConfig.PartitionSize, + createConfig.MinPartitionsCount, + createConfig.MaxPartitionsCount); + break; + } + catch (Exception e) + { + Console.WriteLine(e); + Thread.Sleep(millisecondsTimeout: 1000); + } + } } internal static async Task CleanUp(CleanUpConfig cleanUpConfig)