Skip to content

Commit

Permalink
Merge pull request #2084 from wotolom/lmbda-function-special-handle-i…
Browse files Browse the repository at this point in the history
…nactive-idle-state

fix(lambda/function): resource is ready when function is inactive due to idle
  • Loading branch information
MisterMX authored Jul 29, 2024
2 parents 24abbe4 + 3c0ced8 commit dbe8d46
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controller/lambda/function/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/pkg/errors"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"

svcapitypes "github.com/crossplane-contrib/provider-aws/apis/lambda/v1beta1"
Expand Down Expand Up @@ -131,7 +132,13 @@ func postObserve(_ context.Context, cr *svcapitypes.Function, resp *svcsdk.GetFu
cr.SetConditions(xpv1.Available())
case string(svcapitypes.State_Pending):
cr.SetConditions(xpv1.Creating())
case string(svcapitypes.State_Failed), string(svcapitypes.State_Inactive):
case string(svcapitypes.State_Inactive):
if aws.StringValue(resp.Configuration.StateReasonCode) == string(svcapitypes.StateReasonCode_Idle) {
cr.SetConditions(xpv1.Available().WithMessage(ptr.Deref(resp.Configuration.StateReason, "")))
} else {
cr.SetConditions(xpv1.Unavailable().WithMessage(ptr.Deref(resp.Configuration.StateReason, "")))
}
case string(svcapitypes.State_Failed):
cr.SetConditions(xpv1.Unavailable())
}
return obs, nil
Expand Down

0 comments on commit dbe8d46

Please sign in to comment.