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

chore(RedisInstance): no longer put cloud provider errors in conditions #885

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redisinstance

import (
"context"
"fmt"

"github.com/aws/aws-sdk-go-v2/service/elasticache/types"
"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand Down Expand Up @@ -69,8 +68,8 @@ func createElastiCacheCluster(ctx context.Context, st composed.State) (error, co
meta.SetStatusCondition(redisInstance.Conditions(), metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: "True",
Reason: v1beta1.ConditionTypeError,
Message: fmt.Sprintf("Failed creating AWS Elasticache: %s", err),
Reason: v1beta1.ReasonCloudProviderError,
Message: "Failed to create RedisInstance",
})
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
err = state.UpdateObjStatus(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redisinstance

import (
"context"
"fmt"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"

Expand Down Expand Up @@ -45,8 +44,8 @@ func updateElastiCacheCluster(ctx context.Context, st composed.State) (error, co
meta.SetStatusCondition(redisInstance.Conditions(), metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeError,
Status: "True",
Reason: cloudcontrolv1beta1.ConditionTypeError,
Message: fmt.Sprintf("Failed updating GwsRedis: %s", err),
Reason: cloudcontrolv1beta1.ReasonCloudProviderError,
Message: "Failed to update RedisInstance",
})
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
err = state.UpdateObjStatus(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redisinstance

import (
"context"
"errors"

"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand All @@ -18,13 +19,14 @@ func waitElastiCacheAvailable(ctx context.Context, st composed.State) (error, co

if state.elastiCacheReplicationGroup == nil {
errorMsg := "Error: elasti cache cluster instance is not loaded"
logger.Error(errors.New(errorMsg), errorMsg)
redisInstance := st.Obj().(*v1beta1.RedisInstance)
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
return composed.UpdateStatus(redisInstance).
SetExclusiveConditions(metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: metav1.ConditionTrue,
Reason: v1beta1.ConditionTypeError,
Reason: v1beta1.ReasonUnknown,
Message: errorMsg,
}).
SuccessError(composed.StopAndForget).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redisinstance

import (
"context"
"errors"
"fmt"

"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand All @@ -25,13 +26,14 @@ func waitElastiCacheDeleted(ctx context.Context, st composed.State) (error, cont

if cacheState != awsmeta.ElastiCache_DELETING {
errorMsg := fmt.Sprintf("Error: unexpected aws elasticache cluster state: %s", cacheState)
logger.Error(errors.New(errorMsg), errorMsg)
redisInstance := st.Obj().(*v1beta1.RedisInstance)
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
return composed.UpdateStatus(redisInstance).
SetExclusiveConditions(metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: metav1.ConditionTrue,
Reason: v1beta1.ConditionTypeError,
Reason: v1beta1.ReasonUnknown,
Message: errorMsg,
}).
SuccessError(composed.StopAndForget).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redisinstance

import (
"context"
"errors"
"fmt"

"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand All @@ -25,13 +26,14 @@ func waitUserGroupDeleted(ctx context.Context, st composed.State) (error, contex

if cacheState != awsmeta.ElastiCache_UserGroup_DELETING {
errorMsg := fmt.Sprintf("Error: unexpected aws elasticache user group state: %s", cacheState)
logger.Error(errors.New(errorMsg), errorMsg)
redisInstance := st.Obj().(*v1beta1.RedisInstance)
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
return composed.UpdateStatus(redisInstance).
SetExclusiveConditions(metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: metav1.ConditionTrue,
Reason: v1beta1.ConditionTypeError,
Reason: v1beta1.ReasonUnknown,
Message: errorMsg,
}).
SuccessError(composed.StopAndForget).
Expand Down
4 changes: 2 additions & 2 deletions pkg/kcp/provider/gcp/redisinstance/createRedis.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func createRedis(ctx context.Context, st composed.State) (error, context.Context
meta.SetStatusCondition(redisInstance.Conditions(), metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: "True",
Reason: v1beta1.ReasonGcpError,
Message: fmt.Sprintf("Failed creating GcpRedis: %s", err),
Reason: v1beta1.ReasonCloudProviderError,
Message: "Failed to create RedisInstance",
})
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState

Expand Down
5 changes: 2 additions & 3 deletions pkg/kcp/provider/gcp/redisinstance/deleteRedis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redisinstance

import (
"context"
"fmt"

"cloud.google.com/go/redis/apiv1/redispb"
"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand Down Expand Up @@ -43,8 +42,8 @@ func deleteRedis(ctx context.Context, st composed.State) (error, context.Context
meta.SetStatusCondition(redisInstance.Conditions(), metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: "True",
Reason: v1beta1.ReasonGcpError,
Message: fmt.Sprintf("Failed deleting GcpRedis: %s", err),
Reason: v1beta1.ReasonCloudProviderError,
Message: "Failed to delete RedisInstance",
})
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState

Expand Down
5 changes: 2 additions & 3 deletions pkg/kcp/provider/gcp/redisinstance/loadRedis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redisinstance

import (
"context"
"fmt"

"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand Down Expand Up @@ -40,8 +39,8 @@ func loadRedis(ctx context.Context, st composed.State) (error, context.Context)
meta.SetStatusCondition(redisInstance.Conditions(), metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: "True",
Reason: v1beta1.ReasonGcpError,
Message: fmt.Sprintf("Failed loading GcpRedis: %s", err),
Reason: v1beta1.ReasonCloudProviderError,
Message: "Failed to load RedisInstance",
})
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState

Expand Down
5 changes: 3 additions & 2 deletions pkg/kcp/provider/gcp/redisinstance/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ func New(stateFactory StateFactory) composed.Action {

state, err := stateFactory.NewState(ctx, st.(types.State))
if err != nil {
composed.LoggerFromCtx(ctx).Error(err, "Failed to bootstrap GCP RedisInstance state")
redisInstance := st.Obj().(*v1beta1.RedisInstance)
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
return composed.UpdateStatus(redisInstance).
SetExclusiveConditions(metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: metav1.ConditionTrue,
Reason: v1beta1.ReasonGcpError,
Message: err.Error(),
Reason: v1beta1.ReasonCloudProviderError,
Message: "Failed to create RedisInstance state",
}).
SuccessError(composed.StopAndForget).
SuccessLogMsg(fmt.Sprintf("Error creating new GCP RedisInstance state: %s", err)).
Expand Down
5 changes: 2 additions & 3 deletions pkg/kcp/provider/gcp/redisinstance/updateRedis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redisinstance

import (
"context"
"fmt"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/composed"
Expand Down Expand Up @@ -43,8 +42,8 @@ func updateRedis(ctx context.Context, st composed.State) (error, context.Context
meta.SetStatusCondition(redisInstance.Conditions(), metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeError,
Status: "True",
Reason: cloudcontrolv1beta1.ReasonGcpError,
Message: fmt.Sprintf("Failed updating GcpRedis: %s", err),
Reason: cloudcontrolv1beta1.ReasonCloudProviderError,
Message: "Failed to update RedisInstance",
})
err = state.UpdateObjStatus(ctx)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion pkg/kcp/provider/gcp/redisinstance/waitRedisAvailable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redisinstance

import (
"context"
"errors"

"cloud.google.com/go/redis/apiv1/redispb"
"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand All @@ -17,13 +18,14 @@ func waitRedisAvailable(ctx context.Context, st composed.State) (error, context.

if state.gcpRedisInstance == nil {
errorMsg := "Error: redis instance is not loaded"
logger.Error(errors.New(errorMsg), errorMsg)
redisInstance := st.Obj().(*v1beta1.RedisInstance)
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
return composed.UpdateStatus(redisInstance).
SetExclusiveConditions(metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: metav1.ConditionTrue,
Reason: v1beta1.ReasonGcpError,
Reason: v1beta1.ReasonUnknown,
Message: errorMsg,
}).
SuccessError(composed.StopAndForget).
Expand Down
4 changes: 3 additions & 1 deletion pkg/kcp/provider/gcp/redisinstance/waitRedisDeleted.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redisinstance

import (
"context"
"errors"

"cloud.google.com/go/redis/apiv1/redispb"
"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand All @@ -21,13 +22,14 @@ func waitRedisDeleted(ctx context.Context, st composed.State) (error, context.Co

if state.gcpRedisInstance.State != redispb.Instance_DELETING {
errorMsg := "Error: unexpected gcp redis state"
logger.Error(errors.New(errorMsg), errorMsg)
redisInstance := st.Obj().(*v1beta1.RedisInstance)
redisInstance.Status.State = cloudcontrolv1beta1.ErrorState
return composed.UpdateStatus(redisInstance).
SetExclusiveConditions(metav1.Condition{
Type: v1beta1.ConditionTypeError,
Status: metav1.ConditionTrue,
Reason: v1beta1.ReasonGcpError,
Reason: v1beta1.ReasonUnknown,
Message: errorMsg,
}).
SuccessError(composed.StopAndForget).
Expand Down
Loading