Skip to content

Commit

Permalink
Merge branch 'main' into oidc-enabled-only-for-clusters-managed-by-kim
Browse files Browse the repository at this point in the history
  • Loading branch information
akgalwas authored Sep 13, 2024
2 parents aca7e6f + 56e53d8 commit 63ede49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
22 changes: 20 additions & 2 deletions hack/runtime-migrator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,14 @@ 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: adjustWorkersConfig(shoot.Spec.Provider.Workers),
},
Networking: v1.Networking{
Type: shoot.Spec.Networking.Type,
Pods: *shoot.Spec.Networking.Pods,
Nodes: *shoot.Spec.Networking.Nodes,
Services: *shoot.Spec.Networking.Services,
},
ControlPlane: getControlPlane(shoot),
},
Security: v1.Security{
Administrators: subjects,
Expand All @@ -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 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
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -26,34 +27,36 @@ 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,
"False",
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,
"Missing region mapping for this shoot. Audit Log is not mandatory. Skipping configuration")
}
} 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,
Expand Down

0 comments on commit 63ede49

Please sign in to comment.