Skip to content

Commit

Permalink
fix: unable to delete VPC peering when network is in Warning state
Browse files Browse the repository at this point in the history
  • Loading branch information
vandjelk authored Nov 26, 2024
1 parent c9b04f2 commit d81ed34
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/kcp/provider/aws/vpcpeering/createRemoteClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func createRemoteClient(ctx context.Context, st composed.State) (error, context.
return nil, nil
}

remoteAccountId := state.remoteNetwork.Spec.Network.Reference.Aws.AwsAccountId
remoteRegion := state.remoteNetwork.Spec.Network.Reference.Aws.Region
remoteAccountId := state.remoteNetwork.Status.Network.Aws.AwsAccountId
remoteRegion := state.remoteNetwork.Status.Network.Aws.Region

roleArn := fmt.Sprintf("arn:aws:iam::%s:role/%s", remoteAccountId, state.roleName)

Expand Down
3 changes: 1 addition & 2 deletions pkg/kcp/provider/aws/vpcpeering/kcpNetworkLocalLoad.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/kyma-project/cloud-manager/pkg/composed"
"github.com/kyma-project/cloud-manager/pkg/util"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -50,7 +49,7 @@ func kcpNetworkLocalLoad(ctx context.Context, st composed.State) (error, context
Run(ctx, state)
}

if !meta.IsStatusConditionTrue(*net.Conditions(), cloudcontrolv1beta1.ConditionTypeReady) {
if net.Status.Network == nil {
state.ObjAsVpcPeering().Status.State = string(cloudcontrolv1beta1.ErrorState)
return composed.PatchStatus(state.ObjAsVpcPeering()).
SetExclusiveConditions(metav1.Condition{
Expand Down
2 changes: 1 addition & 1 deletion pkg/kcp/provider/aws/vpcpeering/kcpNetworkRemoteLoad.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func kcpNetworkRemoteLoad(ctx context.Context, st composed.State) (error, contex
Run(ctx, state)
}

if net.Status.State != string(cloudcontrolv1beta1.ReadyState) {
if net.Status.Network == nil {
state.ObjAsVpcPeering().Status.State = string(cloudcontrolv1beta1.ErrorState)
return composed.PatchStatus(state.ObjAsVpcPeering()).
SetExclusiveConditions(metav1.Condition{
Expand Down
3 changes: 1 addition & 2 deletions pkg/kcp/provider/azure/vpcpeering/kcpNetworkLocalLoad.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
azureutil "github.com/kyma-project/cloud-manager/pkg/kcp/provider/azure/util"
"github.com/kyma-project/cloud-manager/pkg/util"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -51,7 +50,7 @@ func kcpNetworkLocalLoad(ctx context.Context, st composed.State) (error, context
Run(ctx, state)
}

if !meta.IsStatusConditionTrue(*net.Conditions(), cloudcontrolv1beta1.ConditionTypeReady) {
if net.Status.Network == nil {
state.ObjAsVpcPeering().Status.State = string(cloudcontrolv1beta1.ErrorState)
return composed.PatchStatus(state.ObjAsVpcPeering()).
SetExclusiveConditions(metav1.Condition{
Expand Down
2 changes: 1 addition & 1 deletion pkg/kcp/provider/azure/vpcpeering/kcpNetworkRemoteLoad.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func kcpNetworkRemoteLoad(ctx context.Context, st composed.State) (error, contex
Run(ctx, state)
}

if net.Status.State != string(cloudcontrolv1beta1.ReadyState) {
if net.Status.Network == nil {
state.ObjAsVpcPeering().Status.State = string(cloudcontrolv1beta1.ErrorState)
return composed.PatchStatus(state.ObjAsVpcPeering()).
SetExclusiveConditions(metav1.Condition{
Expand Down

0 comments on commit d81ed34

Please sign in to comment.