Skip to content

Commit 5330024

Browse files
committed
update idp reconciler to get out sooner if nothing to do
1 parent 2998f55 commit 5330024

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

pkg/cloud/services/eks/identity_provider.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,20 @@ func (s *Service) reconcileIdentityProvider(ctx context.Context) error {
4949
}
5050

5151
s.scope.V(2).Info("creating oidc provider plan", "desired", desired, "current", current)
52+
procedures, err := identityprovider.
53+
NewPlan(clusterName, current, desired, s.EKSClient, s.scope.Logger).
54+
Create(ctx)
5255

53-
identityProviderPlan := identityprovider.NewPlan(clusterName, current, desired, s.EKSClient, s.scope.Logger)
54-
55-
procedures, err := identityProviderPlan.Create(ctx)
5656
if err != nil {
5757
s.scope.Error(err, "failed creating eks identity provider plan")
5858
return fmt.Errorf("creating eks identity provider plan: %w", err)
5959
}
60+
61+
// nothing will be done, we can leave
62+
if len(procedures) == 0 {
63+
return nil
64+
}
65+
6066
s.scope.V(2).Info("computed EKS identity provider plan", "numprocs", len(procedures))
6167

6268
// Perform required operations
@@ -73,16 +79,24 @@ func (s *Service) reconcileIdentityProvider(ctx context.Context) error {
7379
return errors.Wrap(err, "getting associated identity provider")
7480
}
7581

76-
if latest != nil {
77-
s.scope.ControlPlane.Status.IdentityProviderStatus = ekscontrolplanev1.IdentityProviderStatus{
78-
ARN: latest.IdentityProviderConfigArn,
79-
Status: latest.Status,
80-
}
82+
if latest == nil {
83+
return nil
84+
}
8185

82-
err := s.scope.PatchObject()
83-
if err != nil {
84-
return errors.Wrap(err, "updating identity provider status")
85-
}
86+
// don't patch if arn/status is the same
87+
if latest.IdentityProviderConfigArn == s.scope.ControlPlane.Status.IdentityProviderStatus.ARN &&
88+
latest.Status == s.scope.ControlPlane.Status.IdentityProviderStatus.Status {
89+
return nil
90+
}
91+
92+
// idp status has changed, patch the control plane
93+
s.scope.ControlPlane.Status.IdentityProviderStatus = ekscontrolplanev1.IdentityProviderStatus{
94+
ARN: latest.IdentityProviderConfigArn,
95+
Status: latest.Status,
96+
}
97+
98+
if err := s.scope.PatchObject(); err != nil {
99+
return errors.Wrap(err, "updating identity provider status")
86100
}
87101

88102
return nil

0 commit comments

Comments
 (0)