Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use everywhere new constructor for op manager #1517

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/process/deprovisioning/btp_operator_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ type BTPOperatorCleanupStep struct {
}

func NewBTPOperatorCleanupStep(os storage.Operations, k8sClientProvider K8sClientProvider) *BTPOperatorCleanupStep {
return &BTPOperatorCleanupStep{
operationManager: process.NewOperationManager(os),
step := &BTPOperatorCleanupStep{
k8sClientProvider: k8sClientProvider,
}
step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet)
return step
}

func (s *BTPOperatorCleanupStep) Name() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"k8s.io/apimachinery/pkg/api/meta"

"github.com/kyma-project/kyma-environment-broker/internal/process/steps"
Expand All @@ -25,10 +27,11 @@ type CheckGardenerClusterDeletedStep struct {
}

func NewCheckGardenerClusterDeletedStep(operations storage.Operations, kcpClient client.Client) *CheckGardenerClusterDeletedStep {
return &CheckGardenerClusterDeletedStep{
operationManager: process.NewOperationManager(operations),
kcpClient: kcpClient,
step := &CheckGardenerClusterDeletedStep{
kcpClient: kcpClient,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (step *CheckGardenerClusterDeletedStep) Name() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/process/steps"

"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -25,11 +27,12 @@ type CheckKymaResourceDeletedStep struct {
}

func NewCheckKymaResourceDeletedStep(operations storage.Operations, kcpClient client.Client, kymaResourceDeletionTimeout time.Duration) *CheckKymaResourceDeletedStep {
return &CheckKymaResourceDeletedStep{
operationManager: process.NewOperationManager(operations),
step := &CheckKymaResourceDeletedStep{
kcpClient: kcpClient,
kymaResourceDeletionTimeout: kymaResourceDeletionTimeout,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (step *CheckKymaResourceDeletedStep) Name() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/storage/dberr"

"github.com/kyma-project/control-plane/components/provisioner/pkg/gqlschema"
Expand All @@ -25,12 +27,13 @@ var _ process.Step = &CheckRuntimeRemovalStep{}

func NewCheckRuntimeRemovalStep(operations storage.Operations, instances storage.Instances,
provisionerClient provisioner.Client, timeout time.Duration) *CheckRuntimeRemovalStep {
return &CheckRuntimeRemovalStep{
operationManager: process.NewOperationManager(operations),
step := &CheckRuntimeRemovalStep{
provisionerClient: provisionerClient,
instanceStorage: instances,
timeout: timeout,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (s *CheckRuntimeRemovalStep) Name() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

imv1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/kyma-project/kyma-environment-broker/internal"
"github.com/kyma-project/kyma-environment-broker/internal/process"
Expand All @@ -22,11 +24,12 @@ type CheckRuntimeResourceDeletionStep struct {
}

func NewCheckRuntimeResourceDeletionStep(operations storage.Operations, kcpClient client.Client, checkRuntimeResourceDeletionStepTimeout time.Duration) *CheckRuntimeResourceDeletionStep {
return &CheckRuntimeResourceDeletionStep{
operationManager: process.NewOperationManager(operations),
step := &CheckRuntimeResourceDeletionStep{
kcpClient: kcpClient,
checkRuntimeResourceDeletionStepTimeout: checkRuntimeResourceDeletionStepTimeout,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (step *CheckRuntimeResourceDeletionStep) Name() string {
Expand Down
11 changes: 7 additions & 4 deletions internal/process/deprovisioning/delete_gardener_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"k8s.io/apimachinery/pkg/api/meta"

"github.com/kyma-project/kyma-environment-broker/internal/process/steps"
Expand All @@ -24,11 +26,12 @@ type DeleteGardenerClusterStep struct {
}

func NewDeleteGardenerClusterStep(operations storage.Operations, kcpClient client.Client, instances storage.Instances) *DeleteGardenerClusterStep {
return &DeleteGardenerClusterStep{
operationManager: process.NewOperationManager(operations),
kcpClient: kcpClient,
instances: instances,
step := &DeleteGardenerClusterStep{
kcpClient: kcpClient,
instances: instances,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.KEBDependency)
return step
}

func (step *DeleteGardenerClusterStep) Name() string {
Expand Down
13 changes: 8 additions & 5 deletions internal/process/deprovisioning/delete_kyma_resource_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/broker"
"github.com/kyma-project/kyma-environment-broker/internal/process/input"

Expand Down Expand Up @@ -34,12 +36,13 @@ type DeleteKymaResourceStep struct {
}

func NewDeleteKymaResourceStep(operations storage.Operations, instances storage.Instances, kcpClient client.Client, configProvider input.ConfigurationProvider) *DeleteKymaResourceStep {
return &DeleteKymaResourceStep{
operationManager: process.NewOperationManager(operations),
kcpClient: kcpClient,
configProvider: configProvider,
instances: instances,
step := &DeleteKymaResourceStep{
kcpClient: kcpClient,
configProvider: configProvider,
instances: instances,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (step *DeleteKymaResourceStep) Name() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/ptr"

"github.com/kyma-project/kyma-environment-broker/internal/process/steps"
Expand All @@ -29,10 +31,11 @@ type DeleteRuntimeResourceStep struct {
}

func NewDeleteRuntimeResourceStep(operations storage.Operations, kcpClient client.Client) *DeleteRuntimeResourceStep {
return &DeleteRuntimeResourceStep{
operationManager: process.NewOperationManager(operations),
kcpClient: kcpClient,
step := &DeleteRuntimeResourceStep{
kcpClient: kcpClient,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (step *DeleteRuntimeResourceStep) Name() string {
Expand Down
13 changes: 7 additions & 6 deletions internal/process/deprovisioning/edp_deregistration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ type InstanceOperationStorage interface {
}

func NewEDPDeregistrationStep(os storage.Operations, is storage.Instances, client EDPClient, config edp.Config) *EDPDeregistrationStep {
return &EDPDeregistrationStep{
operationManager: process.NewOperationManager(os),
client: client,
config: config,
dbOperations: os,
dbInstances: is,
step := &EDPDeregistrationStep{
client: client,
config: config,
dbOperations: os,
dbInstances: is,
}
step.operationManager = process.NewOperationManager(os, step.Name(), kebError.EDPDependency)
return step
}

func (s *EDPDeregistrationStep) Name() string {
Expand Down
7 changes: 5 additions & 2 deletions internal/process/deprovisioning/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/common/orchestration"
"github.com/kyma-project/kyma-environment-broker/internal"
"github.com/kyma-project/kyma-environment-broker/internal/process"
Expand All @@ -21,12 +23,13 @@ type InitStep struct {
}

func NewInitStep(operations storage.Operations, instances storage.Instances, operationTimeout time.Duration) *InitStep {
return &InitStep{
operationManager: process.NewOperationManager(operations),
step := &InitStep{
operationTimeout: operationTimeout,
operationStorage: operations,
instanceStorage: instances,
}
step.operationManager = process.NewOperationManager(operations, step.Name(), kebError.NotSet)
return step
}

func (s *InitStep) Name() string {
Expand Down
11 changes: 7 additions & 4 deletions internal/process/deprovisioning/release_subscription_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/euaccess"

"github.com/kyma-project/kyma-environment-broker/common/hyperscaler"
Expand All @@ -25,11 +27,12 @@ type ReleaseSubscriptionStep struct {
var _ process.Step = &ReleaseSubscriptionStep{}

func NewReleaseSubscriptionStep(os storage.Operations, instanceStorage storage.Instances, accountProvider hyperscaler.AccountProvider) ReleaseSubscriptionStep {
return ReleaseSubscriptionStep{
operationManager: process.NewOperationManager(os),
instanceStorage: instanceStorage,
accountProvider: accountProvider,
step := ReleaseSubscriptionStep{
instanceStorage: instanceStorage,
accountProvider: accountProvider,
}
step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet)
return step
}

func (s ReleaseSubscriptionStep) Name() string {
Expand Down
7 changes: 5 additions & 2 deletions internal/process/deprovisioning/remove_instance_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"strings"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/storage/dberr"

"github.com/kyma-project/kyma-environment-broker/internal/process"
Expand All @@ -23,11 +25,12 @@ type RemoveInstanceStep struct {
var _ process.Step = &RemoveInstanceStep{}

func NewRemoveInstanceStep(instanceStorage storage.Instances, operationStorage storage.Operations) *RemoveInstanceStep {
return &RemoveInstanceStep{
operationManager: process.NewOperationManager(operationStorage),
step := &RemoveInstanceStep{
instanceStorage: instanceStorage,
operationStorage: operationStorage,
}
step.operationManager = process.NewOperationManager(operationStorage, step.Name(), kebError.NotSet)
return step
}

func (s *RemoveInstanceStep) Name() string {
Expand Down
7 changes: 5 additions & 2 deletions internal/process/deprovisioning/remove_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"time"

kebError "github.com/kyma-project/kyma-environment-broker/internal/error"

"github.com/kyma-project/kyma-environment-broker/internal/storage/dberr"

"github.com/kyma-project/kyma-environment-broker/internal/broker"
Expand All @@ -24,12 +26,13 @@ type RemoveRuntimeStep struct {
}

func NewRemoveRuntimeStep(os storage.Operations, is storage.Instances, cli provisioner.Client, provisionerTimeout time.Duration) *RemoveRuntimeStep {
return &RemoveRuntimeStep{
operationManager: process.NewOperationManager(os),
step := &RemoveRuntimeStep{
instanceStorage: is,
provisionerClient: cli,
provisionerTimeout: provisionerTimeout,
}
step.operationManager = process.NewOperationManager(os, step.Name(), kebError.NotSet)
return step
}

func (s *RemoveRuntimeStep) Name() string {
Expand Down
6 changes: 1 addition & 5 deletions internal/process/operation_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ type OperationManager struct {
step string
}

func NewOperationManager(storage storage.Operations) *OperationManager {
return &OperationManager{storage: storage}
}

func NewOperationManagerWithMetadata(storage storage.Operations, step string, component kebErr.Component) *OperationManager {
func NewOperationManager(storage storage.Operations, step string, component kebErr.Component) *OperationManager {
return &OperationManager{storage: storage, component: component, step: step}
}

Expand Down
14 changes: 7 additions & 7 deletions internal/process/operation_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_OperationManager_RetryOperationOnce(t *testing.T) {
// given
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManager(operations)
opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency)
op := internal.Operation{}
op.UpdatedAt = time.Now()
retryInterval := time.Hour
Expand Down Expand Up @@ -50,7 +50,7 @@ func Test_OperationManager_RetryOperation(t *testing.T) {
// given
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManager(operations)
opManager := NewOperationManager(operations, "some_step", kebErr.NotSet)
op := internal.Operation{}
op.UpdatedAt = time.Now()
retryInterval := time.Hour
Expand Down Expand Up @@ -84,7 +84,7 @@ func Test_OperationManager_LastError(t *testing.T) {
t.Run("when all last error field set with 1 component v1", func(t *testing.T) {
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ProvisionerDependency)
opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency)
op := internal.Operation{}
err := operations.InsertOperation(op)
require.NoError(t, err)
Expand All @@ -98,7 +98,7 @@ func Test_OperationManager_LastError(t *testing.T) {
t.Run("when all last error field set with 1 components v2", func(t *testing.T) {
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.KebDbDependency)
opManager := NewOperationManager(operations, "some_step", kebErr.KebDbDependency)
op := internal.Operation{}
err := operations.InsertOperation(op)
require.NoError(t, err)
Expand All @@ -112,7 +112,7 @@ func Test_OperationManager_LastError(t *testing.T) {
t.Run("when no error passed", func(t *testing.T) {
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ProvisionerDependency)
opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency)
op := internal.Operation{}
err := operations.InsertOperation(op)
require.NoError(t, err)
Expand All @@ -126,7 +126,7 @@ func Test_OperationManager_LastError(t *testing.T) {
t.Run("when no description passed", func(t *testing.T) {
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ProvisionerDependency)
opManager := NewOperationManager(operations, "some_step", kebErr.ProvisionerDependency)
op := internal.Operation{}
err := operations.InsertOperation(op)
require.NoError(t, err)
Expand All @@ -140,7 +140,7 @@ func Test_OperationManager_LastError(t *testing.T) {
t.Run("when no description and no err passed", func(t *testing.T) {
memory := storage.NewMemoryStorage()
operations := memory.Operations()
opManager := NewOperationManagerWithMetadata(operations, "some_step", kebErr.ReconcileDependency)
opManager := NewOperationManager(operations, "some_step", kebErr.ReconcileDependency)
op := internal.Operation{}
err := operations.InsertOperation(op)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/process/provisioning/apply_kyma_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ process.Step = &ApplyKymaStep{}

func NewApplyKymaStep(os storage.Operations, cli client.Client) *ApplyKymaStep {
step := &ApplyKymaStep{k8sClient: cli}
step.operationManager = process.NewOperationManagerWithMetadata(os, step.Name(), kebErr.LifeCycleManagerDependency)
step.operationManager = process.NewOperationManager(os, step.Name(), kebErr.LifeCycleManagerDependency)
return step
}

Expand Down
Loading
Loading