diff --git a/pkg/controller/service/reconciler_status.go b/pkg/controller/service/reconciler_status.go index 4207fdee..b01516e0 100644 --- a/pkg/controller/service/reconciler_status.go +++ b/pkg/controller/service/reconciler_status.go @@ -91,11 +91,24 @@ func (s *ServiceReconciler) UpdateApplyStatus( statusCollector.updateApplyStatus(e.ApplyEvent.Identifier, e.ApplyEvent) gk := e.ApplyEvent.Identifier.GroupKind name := e.ApplyEvent.Identifier.Name + namespace := e.ApplyEvent.Identifier.Namespace if e.ApplyEvent.Status == event.ApplySuccessful { cache.SaveResourceSHA(e.ApplyEvent.Resource, cache.ApplySHA) } if e.ApplyEvent.Error != nil { + // e.ApplyEvent.Resource == nil, create the key to get cache entry + key := cache.ResourceKey{ + Namespace: namespace, + Name: name, + GroupKind: gk, + } + sha, exists := cache.GetResourceCache().GetCacheEntry(key.ObjectIdentifier()) + if exists { + // clear SHA when error occurs + sha.Expire() + cache.GetResourceCache().SetCacheEntry(key.ObjectIdentifier(), sha) + } if e.ApplyEvent.Status == event.ApplyFailed { err = fmt.Errorf("%s apply %s: %s\n", resourceIDToString(gk, name), strings.ToLower(e.ApplyEvent.Status.String()), e.ApplyEvent.Error.Error())