Skip to content

Commit

Permalink
chore: update version to 2.9-2024.2.15-03fa32937
Browse files Browse the repository at this point in the history
  • Loading branch information
pasha-codefresh committed Feb 15, 2024
1 parent 03fa329 commit a545756
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9-2024.2.14-9beee4cca
2.9-2024.2.15-03fa32937
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.9-2024.2.15-03fa32937.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Features
- feat: additional logs to controller that explains why resource is out of sync
2 changes: 1 addition & 1 deletion controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (ctrl *ApplicationController) handleObjectUpdated(managedByApp map[string]b
"kind": ref.Kind,
"server": app.Spec.Destination.Server,
"cluster-name": app.Spec.Destination.Name,
}).Debug("Requesting app refresh caused by object update")
}).Debugf("Requesting app refresh caused by object update")

ctrl.requestAppRefresh(app.QualifiedName(), &level, nil)
}
Expand Down
10 changes: 10 additions & 0 deletions controller/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,16 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
ref = oldRes.Ref
}

if newRes == nil {
log.WithFields(log.Fields{
"server": cluster.Server,
"namespace": ref.Namespace,
"name": ref.Name,
"api-version": ref.APIVersion,
"kind": ref.Kind,
}).Debug("Resource was deleted")
}

c.lock.RLock()
cacheSettings := c.cacheSettings
c.lock.RUnlock()
Expand Down
19 changes: 13 additions & 6 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,14 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1

liveObjByKey, err := m.liveStateCache.GetManagedLiveObjs(app, targetObjs)
if err != nil {
logCtx.Errorf("Failed to load live state: %v", err)
liveObjByKey = make(map[kubeutil.ResourceKey]*unstructured.Unstructured)
msg := fmt.Sprintf("Failed to load live state: %s", err.Error())
conditions = append(conditions, v1alpha1.ApplicationCondition{Type: v1alpha1.ApplicationConditionComparisonError, Message: msg, LastTransitionTime: &now})
failedToLoadObjs = true
}

logCtx.Debugf("Retrieved live manifests")
logCtx.Debugf("Retrieved live manifests, amount of live objects: %d", len(liveObjByKey))

// filter out all resources which are not permitted in the application project
for k, v := range liveObjByKey {
Expand All @@ -492,6 +493,7 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
})

if err != nil {
logCtx.Infof("Failed to check if live resource %q is permitted in project %q: %v", k.String(), app.Spec.Project, err)
msg := fmt.Sprintf("Failed to check if live resource %q is permitted in project %q: %s", k.String(), app.Spec.Project, err.Error())
conditions = append(conditions, v1alpha1.ApplicationCondition{Type: v1alpha1.ApplicationConditionComparisonError, Message: msg, LastTransitionTime: &now})
failedToLoadObjs = true
Expand Down Expand Up @@ -551,6 +553,8 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
}
}

logCtx.Debugf("Resources before reconciliation: target %d, live %d", len(targetObjs), len(liveObjByKey))

reconciliation := sync.Reconcile(targetObjs, liveObjByKey, app.Spec.Destination.Namespace, infoProvider)
ts.AddCheckpoint("live_ms")

Expand Down Expand Up @@ -606,6 +610,9 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1
syncCode := v1alpha1.SyncStatusCodeSynced
managedResources := make([]managedResource, len(reconciliation.Target))
resourceSummaries := make([]v1alpha1.ResourceStatus, len(reconciliation.Target))

logCtx.Debugf("Resources after reconciliation: target %d, live %d", len(reconciliation.Target), len(reconciliation.Live))

for i, targetObj := range reconciliation.Target {
liveObj := reconciliation.Live[i]
obj := liveObj
Expand Down Expand Up @@ -657,13 +664,13 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *v1

// logging for precisely, can be removed in future
if diffResult.Modified {
logCtx.Infof("Resource %s is out of sync, because diff between live and desired state", resState.Name)
logCtx.Infof("Live state: %s", string(diffResult.NormalizedLive))
logCtx.Infof("Desired state: %s", string(diffResult.PredictedLive))
logCtx.Debugf("Resource %s is out of sync, because diff between live and desired state", resState.Name)
logCtx.Debugf("Live state: %s", string(diffResult.NormalizedLive))
logCtx.Debugf("Desired state: %s", string(diffResult.PredictedLive))
} else if targetObj == nil {
logCtx.Infof("Resource %s is out of sync, because target object is nil", resState.Name)
logCtx.Debugf("Resource %s is out of sync, because target object is nil", resState.Name)
} else if liveObj == nil {
logCtx.Infof("Resource %s is out of sync, because live object is nil", resState.Name)
logCtx.Debugf("Resource %s is out of sync, because live object is nil", resState.Name)
}

// Set resource state to OutOfSync since one of the following is true:
Expand Down

0 comments on commit a545756

Please sign in to comment.