Skip to content

Commit

Permalink
Merge pull request #1464 from MisterMX/fix/elbv2-target-not-registered
Browse files Browse the repository at this point in the history
fix(elbv2/target): Retry registration if target is unused
  • Loading branch information
haarchri authored Oct 29, 2022
2 parents d3cb664 + 3156129 commit eb9f23a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion apis/elbv2/manualv1alpha1/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type TargetObservation struct {
TargetHealth *TargetHealth `json:"targetHealth,omitempty"`
}

// GetState returns TargetHealth.State if it is not nil, otherwise an empty
// GetState returns s.TargetHealth.State if it is not nil, otherwise an empty
// string.
func (s *TargetObservation) GetState() string {
if s.TargetHealth != nil && s.TargetHealth.State != nil {
Expand All @@ -194,6 +194,15 @@ func (s *TargetObservation) GetState() string {
return ""
}

// GetReason returns s.TargetHealth.Reason if it is not nil, otherwise an empty
// string.
func (s *TargetObservation) GetReason() string {
if s.TargetHealth != nil && s.TargetHealth.Reason != nil {
return *s.TargetHealth.Reason
}
return ""
}

// TargetStatus defines the observed state of a
// Target
type TargetStatus struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/elbv2/target/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (e *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
}

return managed.ExternalObservation{
ResourceExists: true,
ResourceExists: cr.Status.AtProvider.GetReason() != string(types.TargetHealthReasonEnumNotRegistered),
ResourceUpToDate: true, // Targets cannot be updated
}, nil
}
Expand Down

0 comments on commit eb9f23a

Please sign in to comment.