From 80c41a87b0f9f46ca45fbf09c3d46bbf4bb99ee9 Mon Sep 17 00:00:00 2001 From: Arkadiusz Galwas Date: Wed, 11 Sep 2024 11:37:27 +0200 Subject: [PATCH 1/3] Fixes to migrator that will remove unimportant differences --- hack/runtime-migrator/main.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hack/runtime-migrator/main.go b/hack/runtime-migrator/main.go index ca5adcef..76f8aaa2 100644 --- a/hack/runtime-migrator/main.go +++ b/hack/runtime-migrator/main.go @@ -206,7 +206,7 @@ func createRuntime(ctx context.Context, shoot v1beta1.Shoot, cfg migrator.Config }, Provider: v1.Provider{ Type: shoot.Spec.Provider.Type, - Workers: shoot.Spec.Provider.Workers, + Workers: getWorkersConfig(shoot.Spec.Provider.Workers), }, Networking: v1.Networking{ Type: shoot.Spec.Networking.Type, @@ -214,7 +214,6 @@ func createRuntime(ctx context.Context, shoot v1beta1.Shoot, cfg migrator.Config Nodes: *shoot.Spec.Networking.Nodes, Services: *shoot.Spec.Networking.Services, }, - ControlPlane: getControlPlane(shoot), }, Security: v1.Security{ Administrators: subjects, @@ -235,9 +234,28 @@ func createRuntime(ctx context.Context, shoot v1beta1.Shoot, cfg migrator.Config Conditions: nil, // deliberately left nil by our migrator to show that controller has not picked it yet }, } + + controlPlane := getControlPlane(shoot) + if controlPlane != nil { + runtime.Spec.Shoot.ControlPlane = controlPlane + } + return runtime, nil } +// The goal of this function is to make the migrator output equal to the shoot created by the converter +// As a result we can automatically verify the correctness of the migrator output +func getWorkersConfig(workers []v1beta1.Worker) []v1beta1.Worker { + // We need to set the following fields to nil, as they are not set by the KIM converter + for i := 0; i < len(workers); i++ { + workers[i].Machine.Architecture = nil + workers[i].SystemComponents = nil + workers[i].CRI = nil + } + + return workers +} + func getOidcConfig(shoot v1beta1.Shoot) v1beta1.OIDCConfig { var oidcConfig = v1beta1.OIDCConfig{ CABundle: nil, // deliberately left empty From 815595afe7788ec5d4873d3a877fe8a539c313be Mon Sep 17 00:00:00 2001 From: Arkadiusz Galwas Date: Wed, 11 Sep 2024 11:46:58 +0200 Subject: [PATCH 2/3] Fixes to migrator that will remove unimportant differences --- hack/runtime-migrator/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/runtime-migrator/main.go b/hack/runtime-migrator/main.go index 76f8aaa2..da38ce41 100644 --- a/hack/runtime-migrator/main.go +++ b/hack/runtime-migrator/main.go @@ -206,7 +206,7 @@ func createRuntime(ctx context.Context, shoot v1beta1.Shoot, cfg migrator.Config }, Provider: v1.Provider{ Type: shoot.Spec.Provider.Type, - Workers: getWorkersConfig(shoot.Spec.Provider.Workers), + Workers: adjustWorkersConfig(shoot.Spec.Provider.Workers), }, Networking: v1.Networking{ Type: shoot.Spec.Networking.Type, @@ -245,7 +245,7 @@ func createRuntime(ctx context.Context, shoot v1beta1.Shoot, cfg migrator.Config // The goal of this function is to make the migrator output equal to the shoot created by the converter // As a result we can automatically verify the correctness of the migrator output -func getWorkersConfig(workers []v1beta1.Worker) []v1beta1.Worker { +func adjustWorkersConfig(workers []v1beta1.Worker) []v1beta1.Worker { // We need to set the following fields to nil, as they are not set by the KIM converter for i := 0; i < len(workers); i++ { workers[i].Machine.Architecture = nil From 2a618e77c04cffbdebb1e59c1d0372de105a7b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Thu, 12 Sep 2024 16:03:58 +0200 Subject: [PATCH 3/3] fixes logger panics --- .../runtime/fsm/runtime_fsm_configure_auditlog.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/controller/runtime/fsm/runtime_fsm_configure_auditlog.go b/internal/controller/runtime/fsm/runtime_fsm_configure_auditlog.go index d03cb5d6..c06681f9 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_configure_auditlog.go +++ b/internal/controller/runtime/fsm/runtime_fsm_configure_auditlog.go @@ -2,6 +2,7 @@ package fsm import ( "context" + "strconv" imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "github.com/kyma-project/infrastructure-manager/internal/auditlogging" @@ -26,11 +27,13 @@ func sFnConfigureAuditLog(ctx context.Context, m *fsm, s *systemState) (stateFn, return updateStatusAndRequeueAfter(gardenerRequeueDuration) } + auditLogMandatoryString := strconv.FormatBool(m.RCCfg.AuditLogMandatory) + if err != nil { //nolint:nestif errorMessage := err.Error() if errors.Is(err, auditlogging.ErrMissingMapping) { if m.RCCfg.AuditLogMandatory { - m.log.Error(err, "Failed to configure Audit Log, missing region mapping for this shoot", "AuditLogMandatory", m.RCCfg.AuditLogMandatory, "providerType", s.shoot.Spec.Provider.Type, "region", s.shoot.Spec.Region) + m.log.Error(err, "AuditLogMandatory", auditLogMandatoryString, "providerType", s.shoot.Spec.Provider.Type, "region", s.shoot.Spec.Region) s.instance.UpdateStatePending( imv1.ConditionTypeAuditLogConfigured, imv1.ConditionReasonAuditLogMissingRegionMapping, @@ -38,7 +41,7 @@ func sFnConfigureAuditLog(ctx context.Context, m *fsm, s *systemState) (stateFn, errorMessage, ) } else { - m.log.Info(errorMessage, "Audit Log was not configured, missing region mapping for this shoot.", "AuditLogMandatory", m.RCCfg.AuditLogMandatory, "providerType", s.shoot.Spec.Provider.Type, "region", s.shoot.Spec.Region) + m.log.Info(errorMessage, "AuditLogMandatory", auditLogMandatoryString, "providerType", s.shoot.Spec.Provider.Type, "region", s.shoot.Spec.Region) s.instance.UpdateStateReady( imv1.ConditionTypeAuditLogConfigured, imv1.ConditionReasonAuditLogMissingRegionMapping, @@ -46,14 +49,14 @@ func sFnConfigureAuditLog(ctx context.Context, m *fsm, s *systemState) (stateFn, } } else { if m.RCCfg.AuditLogMandatory { - m.log.Error(err, "Failed to configure Audit Log", "AuditLogMandatory", m.RCCfg.AuditLogMandatory) + m.log.Error(err, "AuditLogMandatory", auditLogMandatoryString) s.instance.UpdateStatePending( imv1.ConditionTypeAuditLogConfigured, imv1.ConditionReasonAuditLogError, "False", errorMessage) } else { - m.log.Info(errorMessage, "AuditLogMandatory", m.RCCfg.AuditLogMandatory) + m.log.Info(errorMessage, "AuditLogMandatory", auditLogMandatoryString) s.instance.UpdateStateReady( imv1.ConditionTypeAuditLogConfigured, imv1.ConditionReasonAuditLogError,