Skip to content

Commit d2dd468

Browse files
committed
add some logs
1 parent 492be1b commit d2dd468

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

azure/services/scalesets/scalesets.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (s *Service) Name() string {
7979

8080
// Reconcile idempotently gets, creates, and updates a scale set.
8181
func (s *Service) Reconcile(ctx context.Context) (retErr error) {
82-
ctx, _, done := tele.StartSpanWithLogger(ctx, "scalesets.Service.Reconcile")
82+
ctx, log, done := tele.StartSpanWithLogger(ctx, "scalesets.Service.Reconcile")
8383
defer done()
8484

8585
ctx, cancel := context.WithTimeout(ctx, s.Scope.DefaultedAzureServiceReconcileTimeout())
@@ -138,12 +138,17 @@ func (s *Service) Reconcile(ctx context.Context) (retErr error) {
138138
break
139139
}
140140
}
141+
142+
log = log.WithValues("rg", spec.ResourceGroupName(), "resourceName", spec.ResourceName())
141143
if !azLatestModelApplied {
144+
log.V(3).Info("latest model not applied")
145+
142146
resourceName := spec.ResourceName()
143147
futureType := infrav1.PostFuture
144148
// Check for an ongoing long-running operation.
145149
resumeToken := ""
146150
if future := s.Scope.GetLongRunningOperationState(resourceName, serviceName, futureType); future != nil {
151+
log.V(4).Info("found future")
147152
t, err := converters.FutureToResumeToken(*future)
148153
if err != nil {
149154
s.Scope.DeleteLongRunningOperationState(resourceName, serviceName, futureType)
@@ -156,17 +161,22 @@ func (s *Service) Reconcile(ctx context.Context) (retErr error) {
156161
InstanceIDs: []*string{&target},
157162
}, resumeToken)
158163
if poller != nil && azure.IsContextDeadlineExceededOrCanceledError(err) {
164+
log.Info("context deadline exceeded or canceled for long running op", "err", err)
165+
159166
future, err := converters.PollerToFuture(poller, futureType, serviceName, resourceName, spec.ResourceGroupName())
160167
if err != nil {
161168
return errors.Wrap(err, "failed to convert poller to future")
162169
}
163170
s.Scope.SetLongRunningOperationState(future)
164171
return azure.WithTransientError(azure.NewOperationNotDoneError(future), s.Scope.DefaultedReconcilerRequeue())
165172
}
173+
log.Info("latest model update operation done")
166174

167175
// Once the operation is done, delete the long-running operation state. Even if the operation ended with
168176
// an error, clear out any lingering state to try the operation again.
169177
s.Scope.DeleteLongRunningOperationState(resourceName, serviceName, futureType)
178+
} else {
179+
log.V(3).Info("latest model applied, not updating anything")
170180
}
171181
}
172182

0 commit comments

Comments
 (0)