Skip to content

Commit

Permalink
refactor: Replace status.observedAt with redis pub/sub channels for…
Browse files Browse the repository at this point in the history
… resource tree updates (#1340) (#4208)
  • Loading branch information
Alexander Matyushentsev authored Aug 31, 2020
1 parent edf2904 commit fca0f69
Show file tree
Hide file tree
Showing 25 changed files with 467 additions and 188 deletions.
50 changes: 50 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,56 @@
}
}
},
"/api/v1/stream/applications/{applicationName}/resource-tree": {
"get": {
"tags": [
"ApplicationService"
],
"summary": "Watch returns stream of application resource tree",
"operationId": "WatchResourceTree",
"parameters": [
{
"type": "string",
"name": "applicationName",
"in": "path",
"required": true
},
{
"type": "string",
"name": "namespace",
"in": "query"
},
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "string",
"name": "version",
"in": "query"
},
{
"type": "string",
"name": "group",
"in": "query"
},
{
"type": "string",
"name": "kind",
"in": "query"
}
],
"responses": {
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"$ref": "#/x-stream-definitions/v1alpha1ApplicationTree"
}
}
}
}
},
"/api/version": {
"get": {
"tags": [
Expand Down
7 changes: 2 additions & 5 deletions controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,6 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
appv1.ApplicationConditionComparisonError: true,
})
}
now := metav1.Now()
app.Status.ObservedAt = &now
ctrl.persistAppStatus(origApp, &app.Status)
return
}
Expand All @@ -1055,7 +1053,7 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
revision = app.Status.Sync.Revision
}

observedAt := metav1.Now()
now := metav1.Now()
compareResult := ctrl.appStateManager.CompareAppState(app, project, revision, app.Spec.Source, refreshType == appv1.RefreshTypeHard, localManifests)
for k, v := range compareResult.timings {
logCtx = logCtx.WithField(k, v.Milliseconds())
Expand Down Expand Up @@ -1088,9 +1086,8 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
}

if app.Status.ReconciledAt == nil || comparisonLevel == CompareWithLatest {
app.Status.ReconciledAt = &observedAt
app.Status.ReconciledAt = &now
}
app.Status.ObservedAt = &observedAt
app.Status.Sync = *compareResult.syncStatus
app.Status.Health = *compareResult.healthStatus
app.Status.Resources = compareResult.resources
Expand Down
4 changes: 2 additions & 2 deletions controller/appcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ func TestUpdateReconciledAt(t *testing.T) {

_, updated, err = unstructured.NestedString(receivedPatch, "status", "observedAt")
assert.NoError(t, err)
assert.True(t, updated)
assert.False(t, updated)
})

t.Run("NotUpdatedOnPartialReconciliation", func(t *testing.T) {
Expand All @@ -978,7 +978,7 @@ func TestUpdateReconciledAt(t *testing.T) {

_, updated, err = unstructured.NestedString(receivedPatch, "status", "observedAt")
assert.NoError(t, err)
assert.True(t, updated)
assert.False(t, updated)
})

}
Expand Down
2 changes: 1 addition & 1 deletion manifests/crds/application-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ spec:
type: object
type: array
observedAt:
description: ObservedAt indicates when the application state was updated without querying latest git state
description: 'ObservedAt indicates when the application state was updated without querying latest git state Deprecated: controller no longer updates ObservedAt field'
format: date-time
type: string
operationState:
Expand Down
5 changes: 3 additions & 2 deletions manifests/ha/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,9 @@ spec:
type: object
type: array
observedAt:
description: ObservedAt indicates when the application state was updated
without querying latest git state
description: 'ObservedAt indicates when the application state was updated
without querying latest git state Deprecated: controller no longer
updates ObservedAt field'
format: date-time
type: string
operationState:
Expand Down
5 changes: 3 additions & 2 deletions manifests/ha/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,9 @@ spec:
type: object
type: array
observedAt:
description: ObservedAt indicates when the application state was updated
without querying latest git state
description: 'ObservedAt indicates when the application state was updated
without querying latest git state Deprecated: controller no longer
updates ObservedAt field'
format: date-time
type: string
operationState:
Expand Down
5 changes: 3 additions & 2 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,9 @@ spec:
type: object
type: array
observedAt:
description: ObservedAt indicates when the application state was updated
without querying latest git state
description: 'ObservedAt indicates when the application state was updated
without querying latest git state Deprecated: controller no longer
updates ObservedAt field'
format: date-time
type: string
operationState:
Expand Down
5 changes: 3 additions & 2 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,9 @@ spec:
type: object
type: array
observedAt:
description: ObservedAt indicates when the application state was updated
without querying latest git state
description: 'ObservedAt indicates when the application state was updated
without querying latest git state Deprecated: controller no longer
updates ObservedAt field'
format: date-time
type: string
operationState:
Expand Down
Loading

0 comments on commit fca0f69

Please sign in to comment.