From b94f563cc534ec63bf16def770807807ca6ad1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Wed, 23 Oct 2024 09:09:42 +0200 Subject: [PATCH 1/5] switches daily-markdown-link-check action to a concrete sha version --- .github/workflows/daily-markdown-link-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/daily-markdown-link-check.yaml b/.github/workflows/daily-markdown-link-check.yaml index 21f6d3a7..f8b4dcff 100644 --- a/.github/workflows/daily-markdown-link-check.yaml +++ b/.github/workflows/daily-markdown-link-check.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: gaurav-nelson/github-action-markdown-link-check@v1 + - uses: gaurav-nelson/github-action-markdown-link-check@d53a906aa6b22b8979d33bc86170567e619495ec with: use-quiet-mode: 'yes' use-verbose-mode: 'yes' config-file: '.mlc.config.json' folder-path: '.' - max-depth: -1 \ No newline at end of file + max-depth: -1 From 49e37b1791456d3b41eab7aea20ac35b1c961b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Golicz?= Date: Wed, 23 Oct 2024 17:57:55 +0200 Subject: [PATCH 2/5] proposal to reset runtime metric on application startup --- cmd/main.go | 10 ++++++++++ internal/controller/metrics/metrics.go | 5 +++++ internal/controller/metrics/mocks/Metrics.go | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index 62679ab5..5f72827f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "context" "encoding/json" "flag" "fmt" @@ -182,6 +183,15 @@ func main() { os.Exit(1) } + // refresh runtime metrics + metrics.ResetRuntimeMetrics() + var RuntimeList infrastructuremanagerv1.RuntimeList + if err = mgr.GetClient().List(context.TODO(), &RuntimeList); err != nil { + for _, rt := range RuntimeList.Items { + metrics.SetRuntimeStates(rt) + } + } + cfg := fsm.RCCfg{ GardenerRequeueDuration: defaultGardenerRequeueDuration, ControlPlaneRequeueDuration: defaultControlPlaneRequeueDuration, diff --git a/internal/controller/metrics/metrics.go b/internal/controller/metrics/metrics.go index e73cdfb7..4daa325c 100644 --- a/internal/controller/metrics/metrics.go +++ b/internal/controller/metrics/metrics.go @@ -34,6 +34,7 @@ const ( type Metrics interface { SetRuntimeStates(runtime v1.Runtime) CleanUpRuntimeGauge(runtimeID string) + ResetRuntimeMetrics() IncRuntimeFSMStopCounter() SetGardenerClusterStates(cluster v1.GardenerCluster) CleanUpGardenerClusterGauge(runtimeID string) @@ -100,6 +101,10 @@ func (m metricsImpl) CleanUpRuntimeGauge(runtimeID string) { }) } +func (m metricsImpl) ResetRuntimeMetrics() { + m.runtimeStateGauge.Reset() +} + func (m metricsImpl) IncRuntimeFSMStopCounter() { m.runtimeFSMUnexpectedStopsCnt.Inc() } diff --git a/internal/controller/metrics/mocks/Metrics.go b/internal/controller/metrics/mocks/Metrics.go index ca21c996..c144ac51 100644 --- a/internal/controller/metrics/mocks/Metrics.go +++ b/internal/controller/metrics/mocks/Metrics.go @@ -37,6 +37,11 @@ func (_m *Metrics) IncRuntimeFSMStopCounter() { _m.Called() } +// ResetRuntimeMetrics provides a mock function with given fields: +func (_m *Metrics) ResetRuntimeMetrics() { + _m.Called() +} + // SetGardenerClusterStates provides a mock function with given fields: cluster func (_m *Metrics) SetGardenerClusterStates(cluster v1.GardenerCluster) { _m.Called(cluster) From e45cb49a6ac0dabb43c48c7996ab7b85ff7618f1 Mon Sep 17 00:00:00 2001 From: m00g3n Date: Wed, 23 Oct 2024 19:17:13 +0200 Subject: [PATCH 3/5] fix yaml error --- .github/workflows/build_kim.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_kim.yaml b/.github/workflows/build_kim.yaml index 3b217a36..15049280 100644 --- a/.github/workflows/build_kim.yaml +++ b/.github/workflows/build_kim.yaml @@ -93,8 +93,8 @@ jobs: path: ${{ env.trivy-table }} - name: Print trivy table - if: success() || failure() - run: test -f ${{ env.trivy-table }} && cat ${{ env.trivy-table }} || echo ':: no data ::' + if: success() || failure() + run: "test -f ${{ env.trivy-table }} && cat ${{ env.trivy-table }} || echo ':: no data ::'" build-image: needs: setup From 03708bb5358cc20eb9ae61bd0a3fc0f972947b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Thu, 24 Oct 2024 07:16:46 +0200 Subject: [PATCH 4/5] attempts to fix linter (`RuntimeList' should not be capitalized) --- cmd/main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 5f72827f..f4fa2bf5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -28,7 +28,6 @@ import ( "github.com/gardener/gardener/pkg/apis/core/v1beta1" gardener_apis "github.com/gardener/gardener/pkg/client/core/clientset/versioned/typed/core/v1beta1" gardener_oidc "github.com/gardener/oidc-webhook-authenticator/apis/authentication/v1alpha1" - "github.com/go-playground/validator/v10" infrastructuremanagerv1 "github.com/kyma-project/infrastructure-manager/api/v1" "github.com/kyma-project/infrastructure-manager/internal/auditlogging" kubeconfig_controller "github.com/kyma-project/infrastructure-manager/internal/controller/kubeconfig" @@ -185,9 +184,9 @@ func main() { // refresh runtime metrics metrics.ResetRuntimeMetrics() - var RuntimeList infrastructuremanagerv1.RuntimeList - if err = mgr.GetClient().List(context.TODO(), &RuntimeList); err != nil { - for _, rt := range RuntimeList.Items { + var runtimeList infrastructuremanagerv1.RuntimeList + if err = mgr.GetClient().List(context.TODO(), &runtimeList); err != nil { + for _, rt := range runtimeList.Items { metrics.SetRuntimeStates(rt) } } From 18c3e0be749b7c9d0cfb00cb36f98fd1b0976d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Thu, 24 Oct 2024 07:25:03 +0200 Subject: [PATCH 5/5] adds validator import back --- cmd/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/main.go b/cmd/main.go index f4fa2bf5..808cdc99 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -28,6 +28,7 @@ import ( "github.com/gardener/gardener/pkg/apis/core/v1beta1" gardener_apis "github.com/gardener/gardener/pkg/client/core/clientset/versioned/typed/core/v1beta1" gardener_oidc "github.com/gardener/oidc-webhook-authenticator/apis/authentication/v1alpha1" + validator "github.com/go-playground/validator/v10" infrastructuremanagerv1 "github.com/kyma-project/infrastructure-manager/api/v1" "github.com/kyma-project/infrastructure-manager/internal/auditlogging" kubeconfig_controller "github.com/kyma-project/infrastructure-manager/internal/controller/kubeconfig"