Skip to content

Commit

Permalink
merge from release 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
pasha-codefresh committed Aug 30, 2024
2 parents 5796a56 + 2b2230a commit f47023b
Show file tree
Hide file tree
Showing 56 changed files with 3,127 additions and 3,104 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.11-2024.7.3-c0941bcb4
2.11-2024.8.29-fa0e3225a
1 change: 0 additions & 1 deletion acr_controller/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (a *ACRServer) healthCheck(r *http.Request) error {
// Init starts informers used by the API server
func (a *ACRServer) Init(ctx context.Context) {
go a.appInformer.Run(ctx.Done())
go a.featureManager.Watch()
svcSet := newApplicationChangeRevisionServiceSet()
a.serviceSet = svcSet
}
Expand Down
68 changes: 7 additions & 61 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4100,52 +4100,6 @@
}
}
},
"/api/v1/stream/events": {
"get": {
"tags": [
"Eventing"
],
"operationId": "Eventing_StartEventSource",
"parameters": [
{
"type": "string",
"description": "The event source name.",
"name": "name",
"in": "query"
},
{
"type": "string",
"format": "byte",
"description": "The event source configuration value.",
"name": "config",
"in": "query"
}
],
"responses": {
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"title": "Stream result of genericEvent",
"properties": {
"error": {
"$ref": "#/definitions/runtimeStreamError"
},
"result": {
"$ref": "#/definitions/genericEvent"
}
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/runtimeError"
}
}
}
}
},
"/api/version": {
"get": {
"tags": [
Expand Down Expand Up @@ -4842,21 +4796,6 @@
}
}
},
"genericEvent": {
"type": "object",
"title": "*\nRepresents an event",
"properties": {
"name": {
"description": "The event source name.",
"type": "string"
},
"payload": {
"description": "The event payload.",
"type": "string",
"format": "byte"
}
}
},
"gpgkeyGnuPGPublicKeyCreateResponse": {
"type": "object",
"title": "Response to a public key creation request",
Expand Down Expand Up @@ -9369,6 +9308,13 @@
"comparedTo": {
"$ref": "#/definitions/v1alpha1ComparedTo"
},
"manifestsChanged": {
"type": "object",
"title": "ManifestsChanged indicates whether the manifests have changed base on argocd.argoproj.io/manifest-generate-paths annotation",
"additionalProperties": {
"type": "boolean"
}
},
"revision": {
"type": "string",
"title": "Revision contains information about the revision the comparison has been performed to"
Expand Down
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.7.20-8eb51f7a6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Fix
- fix event reporter base path for codefresh client
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.7.30-a31bf96bb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- fix: selfheal should work with monorepo
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.7.30-fcda44e7b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- fix: selfheal should work with monorepo
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.19-6be897266.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: removed v1 reporter
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.19-d20b4d9a7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal additional logs in CompareAppState
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.27-53edaf2ef.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal additional logs in CompareAppState
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.27-7144356ed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal additional logs in CompareAppState
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.28-62776e60e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal additional logs in CompareAppState
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.29-fa0e3225a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal bring back revision cache
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.7-10260b1bc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- fix: selfheal should work with monorepo
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.7-b088681c7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- fix: selfheal should work with monorepo
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.8-0c809966a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal should work with monorepo
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.8-9011506bf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal should work with monorepo additional, fix revision persistance
2 changes: 2 additions & 0 deletions changelog/CHANGELOG-2.11-2024.8.8-f3821b5f9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Chore
- chore: selfheal should work with monorepo additional logs
2 changes: 1 addition & 1 deletion changelog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
### Chore
- chore(event-reporter v2): code splitting, created utils package
- chore: selfheal additional logs in CompareAppState
24 changes: 19 additions & 5 deletions controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math"
"math/rand"
"net/http"
"os"
"reflect"
"runtime/debug"
"sort"
Expand Down Expand Up @@ -1868,7 +1869,7 @@ func (ctrl *ApplicationController) autoSync(app *appv1.Application, syncStatus *

desiredCommitSHA := syncStatus.Revision
desiredCommitSHAsMS := syncStatus.Revisions
alreadyAttempted, attemptPhase := alreadyAttemptedSync(app, desiredCommitSHA, desiredCommitSHAsMS, app.Spec.HasMultipleSources())
alreadyAttempted, attemptPhase := alreadyAttemptedSync(app, desiredCommitSHA, desiredCommitSHAsMS, app.Spec.HasMultipleSources(), syncStatus.ManifestsChanged)
selfHeal := app.Spec.SyncPolicy.Automated.SelfHeal
op := appv1.Operation{
Sync: &appv1.SyncOperation{
Expand Down Expand Up @@ -1961,7 +1962,7 @@ func (ctrl *ApplicationController) autoSync(app *appv1.Application, syncStatus *

// alreadyAttemptedSync returns whether the most recent sync was performed against the
// commitSHA and with the same app source config which are currently set in the app
func alreadyAttemptedSync(app *appv1.Application, commitSHA string, commitSHAsMS []string, hasMultipleSources bool) (bool, synccommon.OperationPhase) {
func alreadyAttemptedSync(app *appv1.Application, commitSHA string, commitSHAsMS []string, hasMultipleSources bool, manifestsChangedMap map[string]bool) (bool, synccommon.OperationPhase) {
if app.Status.OperationState == nil || app.Status.OperationState.Operation.Sync == nil || app.Status.OperationState.SyncResult == nil {
return false, ""
}
Expand All @@ -1970,8 +1971,17 @@ func alreadyAttemptedSync(app *appv1.Application, commitSHA string, commitSHAsMS
return false, ""
}
} else {
if app.Status.OperationState.SyncResult.Revision != commitSHA {
return false, ""
manifestChanged, ok := manifestsChangedMap[commitSHA]
featureFlagDisabled := os.Getenv("PERSIST_CHANGE_REVISIONS") != "1"
// If record not exists, we need to do sync
if featureFlagDisabled || !ok || manifestChanged {
log.WithField("application", app.Name).Infof("Executing compare of syncResult.Revision and commitSha because of feature flag disabled or manifest changed: %v", commitSHA)
log.WithField("application", app.Name).Infof("Executing compare of syncResult.Revision and commitSha with context, map: %v, flag: %t, record exists: %t", manifestsChangedMap, featureFlagDisabled, ok)
if app.Status.OperationState.SyncResult.Revision != commitSHA {
return false, ""
}
} else {
log.WithField("application", app.Name).Debugf("Skipping auto-sync: commitSHA %s has no changes", commitSHA)
}
}

Expand All @@ -1994,7 +2004,11 @@ func alreadyAttemptedSync(app *appv1.Application, commitSHA string, commitSHAsMS
specSource.TargetRevision = ""
syncResSource := app.Status.OperationState.SyncResult.Source.DeepCopy()
syncResSource.TargetRevision = ""
return reflect.DeepEqual(app.Spec.GetSource(), app.Status.OperationState.SyncResult.Source), app.Status.OperationState.Phase
equalSource, phase := reflect.DeepEqual(app.Spec.GetSource(), app.Status.OperationState.SyncResult.Source), app.Status.OperationState.Phase
if !equalSource {
log.WithField("application", app.Name).Infof("spec.source and syncResult.source are different")
}
return equalSource, phase
}
}

Expand Down
73 changes: 73 additions & 0 deletions controller/appcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"os"
"testing"
"time"

Expand Down Expand Up @@ -1929,3 +1930,75 @@ func TestAddControllerNamespace(t *testing.T) {
assert.Equal(t, test.FakeArgoCDNamespace, updatedApp.Status.ControllerNamespace)
})
}

func TestAlreadyAttemptSync(t *testing.T) {
app := newFakeApp()
t.Run("same manifest with sync result, with disabled flag", func(t *testing.T) {

manifestChangedMap := make(map[string]bool)
manifestChangedMap["sha"] = false

app.Status.Sync.ManifestsChanged = manifestChangedMap

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, nil)
assert.False(t, attempted)
})

t.Run("same manifest with sync result, with enabled flag", func(t *testing.T) {

_ = os.Setenv("PERSIST_CHANGE_REVISIONS", "1")

manifestChangedMap := make(map[string]bool)
manifestChangedMap["sha"] = false

app.Status.Sync.ManifestsChanged = manifestChangedMap

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, manifestChangedMap)
assert.True(t, attempted)
})

t.Run("different manifest with sync result, with disabled flag", func(t *testing.T) {

manifestChangedMap := make(map[string]bool)
manifestChangedMap["sha"] = true

app.Status.Sync.ManifestsChanged = manifestChangedMap

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, nil)
assert.False(t, attempted)
})

t.Run("different manifest with sync result, with enabled flag", func(t *testing.T) {

_ = os.Setenv("PERSIST_CHANGE_REVISIONS", "1")

manifestChangedMap := make(map[string]bool)
manifestChangedMap["sha"] = true

app.Status.Sync.ManifestsChanged = manifestChangedMap

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, manifestChangedMap)
assert.False(t, attempted)
})

t.Run("different manifest with sync result, with enabled flag", func(t *testing.T) {

_ = os.Setenv("PERSIST_CHANGE_REVISIONS", "1")

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, nil)
assert.False(t, attempted)
})

t.Run("different manifest with sync result, with enabled flag v2", func(t *testing.T) {

_ = os.Setenv("PERSIST_CHANGE_REVISIONS", "1")

manifestChangedMap := make(map[string]bool)
manifestChangedMap["sha"] = false

app.Status.Sync.ManifestsChanged = manifestChangedMap

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, manifestChangedMap)
assert.True(t, attempted)
})
}
2 changes: 1 addition & 1 deletion controller/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (ctrl *ApplicationController) executePostDeleteHooks(app *v1alpha1.Applicat
revisions = append(revisions, src.TargetRevision)
}

targets, _, err := ctrl.appStateManager.GetRepoObjs(app, app.Spec.GetSources(), appLabelKey, revisions, false, false, false, proj)
targets, _, _, err := ctrl.appStateManager.GetRepoObjs(app, app.Spec.GetSources(), appLabelKey, revisions, false, false, false, proj)
if err != nil {
return false, err
}
Expand Down
Loading

0 comments on commit f47023b

Please sign in to comment.