Skip to content

Commit

Permalink
Merge branch 'main' into rbac_least_priviligates
Browse files Browse the repository at this point in the history
  • Loading branch information
Disper authored Nov 26, 2024
2 parents c05e888 + e8fe97e commit 2682cfa
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 24 deletions.
4 changes: 1 addition & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ func main() {
flag.BoolVar(&shootSpecDumpEnabled, "shoot-spec-dump-enabled", false, "Feature flag to allow persisting specs of created shoots")
flag.BoolVar(&auditLogMandatory, "audit-log-mandatory", true, "Feature flag to enable strict mode for audit log configuration")

opts := zap.Options{
Development: true,
}
opts := zap.Options{}
opts.BindFlags(flag.CommandLine)
flag.Parse()

Expand Down
9 changes: 4 additions & 5 deletions hack/runtime-migrator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ import (
"strings"
"time"

"github.com/go-playground/validator/v10"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/shoot/extender/auditlogs"
v12 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"

"github.com/gardener/gardener/pkg/apis/core/v1beta1"
gardener_types "github.com/gardener/gardener/pkg/client/core/clientset/versioned/typed/core/v1beta1"
"github.com/go-playground/validator/v10"
"github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/config"
kimConfig "github.com/kyma-project/infrastructure-manager/pkg/config"
"github.com/kyma-project/infrastructure-manager/pkg/gardener"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/kubeconfig"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/shoot/extender/auditlogs"
"github.com/pkg/errors"
v12 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down
2 changes: 1 addition & 1 deletion hack/runtime-migrator/cmd/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"github.com/pkg/errors"
"log/slog"

"github.com/gardener/gardener/pkg/apis/core/v1beta1"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/kyma-project/infrastructure-manager/pkg/config"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/kubeconfig"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/shoot/extender/auditlogs"
"github.com/pkg/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down
3 changes: 2 additions & 1 deletion hack/runtime-migrator/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package config
import (
"flag"
"fmt"
"log"

v1 "github.com/kyma-project/infrastructure-manager/api/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/clientcmd"
"log"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down
7 changes: 4 additions & 3 deletions hack/runtime-migrator/internal/migration/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package migration
import (
"encoding/json"
"fmt"
v1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/runtime"
"os"
"path"
"sigs.k8s.io/yaml"
"time"

v1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/runtime"
"sigs.k8s.io/yaml"
)

type OutputWriter struct {
Expand Down
1 change: 1 addition & 0 deletions hack/runtime-migrator/internal/runtime/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package runtime
import (
"context"
"fmt"

"github.com/gardener/gardener/pkg/apis/core/v1beta1"
v1 "github.com/kyma-project/infrastructure-manager/api/v1"
migrator "github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/config"
Expand Down
3 changes: 2 additions & 1 deletion hack/runtime-migrator/internal/runtime/verifier.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package runtime

import (
"slices"

"github.com/gardener/gardener/pkg/apis/core/v1beta1"
v1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/kyma-project/infrastructure-manager/hack/shoot-comparator/pkg/shoot"
"github.com/kyma-project/infrastructure-manager/pkg/config"
gardener_shoot "github.com/kyma-project/infrastructure-manager/pkg/gardener/shoot"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/shoot/extender/auditlogs"
"k8s.io/utils/ptr"
"slices"
)

type Verifier struct {
Expand Down
6 changes: 2 additions & 4 deletions internal/controller/metrics/mocks/Metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/controller/runtime/fsm/runtime_fsm_patch_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fsm

import (
"context"
"fmt"
"slices"

gardener "github.com/gardener/gardener/pkg/apis/core/v1beta1"
Expand Down Expand Up @@ -67,7 +68,7 @@ func sFnPatchExistingShoot(ctx context.Context, m *fsm, s *systemState) (stateFn

m.log.Error(err, "Failed to patch shoot object, exiting with no retry")
m.Metrics.IncRuntimeFSMStopCounter()
return updateStatePendingWithErrorAndStop(&s.instance, imv1.ConditionTypeRuntimeProvisioned, imv1.ConditionReasonProcessingErr, "Shoot patch error")
return updateStatePendingWithErrorAndStop(&s.instance, imv1.ConditionTypeRuntimeProvisioned, imv1.ConditionReasonProcessingErr, fmt.Sprintf("Gardener API shoot patch error: %v", err))
}

if updatedShoot.Generation == s.shoot.Generation {
Expand Down
20 changes: 15 additions & 5 deletions internal/controller/runtime/runtime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package runtime

import (
"context"
"fmt"
"sync/atomic"

"github.com/go-logr/logr"
imv1 "github.com/kyma-project/infrastructure-manager/api/v1"
Expand All @@ -42,14 +42,13 @@ type RuntimeReconciler struct {
Log logr.Logger
Cfg fsm.RCCfg
EventRecorder record.EventRecorder
RequestID atomic.Uint64
}

//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes,verbs=get;list;watch;create;update;patch,namespace=kcp-system
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes/status,verbs=get;list;delete;create;update;patch,namespace=kcp-system
//+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes/finalizers,verbs=get;list;delete;create;update;patch,namespace=kcp-system

var requCounter = 0 // nolint:gochecknoglobals

func (r *RuntimeReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
r.Log.Info(request.String())

Expand All @@ -60,10 +59,21 @@ func (r *RuntimeReconciler) Reconcile(ctx context.Context, request ctrl.Request)
}, client.IgnoreNotFound(err)
}

r.Log.Info("Reconciling Runtime", "Name", runtime.Name, "Namespace", runtime.Namespace)
runtimeID, ok := runtime.Labels["kyma-project.io/runtime-id"]
if !ok {
runtimeID = runtime.Name
}

shootName, ok := runtime.Labels["kyma-project.io/shoot-name"]
if !ok {
shootName = "N/D"
}

log := r.Log.WithValues("runtimeID", runtimeID, "shootName", shootName, "requestID", r.RequestID.Add(1))
log.Info("Reconciling Runtime", "Name", runtime.Name, "Namespace", runtime.Namespace)

stateFSM := fsm.NewFsm(
r.Log.WithName(fmt.Sprintf("reqID %d", requCounter)),
log,
r.Cfg,
fsm.K8s{
Client: r.Client,
Expand Down

0 comments on commit 2682cfa

Please sign in to comment.