Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/argoproj/argo-cd/v3

go 1.24.4

replace github.com/argoproj/gitops-engine => github.com/agaudreault/gitops-engine v0.7.1-0.20250606141133-32f56cd438c3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: revert when merge


require (
code.gitea.io/sdk/gitea v0.21.0
dario.cat/mergo v1.0.2
Expand All @@ -11,8 +13,8 @@ require (
github.com/Masterminds/semver/v3 v3.3.1
github.com/Masterminds/sprig/v3 v3.3.0
github.com/TomOnTime/utfutil v1.0.0
github.com/alicebob/miniredis/v2 v2.35.0
github.com/argoproj/gitops-engine v0.7.1-0.20250420064138-d65e9d92277d
github.com/alicebob/miniredis/v2 v2.34.0
github.com/argoproj/gitops-engine v0.0.0-00010101000000-000000000000
github.com/argoproj/notifications-engine v0.4.1-0.20250309174002-87bf0576a872
github.com/argoproj/pkg v0.13.6
github.com/argoproj/pkg/v2 v2.0.1
Expand Down Expand Up @@ -141,6 +143,7 @@ require (
github.com/PagerDuty/go-pagerduty v1.8.0 // indirect
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20240116134246-a8cbe886bab0 // indirect
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect
github.com/aws/aws-sdk-go-v2/config v1.29.9 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,21 @@ github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20240116134246-a8cbe886bab0 h1:z
github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20240116134246-a8cbe886bab0/go.mod h1:rjP7sIipbZcagro/6TCk6X0ZeFT2eyudH5+fve/cbBA=
github.com/TomOnTime/utfutil v1.0.0 h1:/0Ivgo2OjXJxo8i7zgvs7ewSFZMLwCRGm3P5Umowb90=
github.com/TomOnTime/utfutil v1.0.0/go.mod h1:l9lZmOniizVSuIliSkEf87qivMRlSNzbdBFKjuLRg1c=
github.com/agaudreault/gitops-engine v0.7.1-0.20250606141133-32f56cd438c3 h1:XLeiAn1wXFK1DCSXiZPT9yD92I0GmT0+nKWp/h54D4Y=
github.com/agaudreault/gitops-engine v0.7.1-0.20250606141133-32f56cd438c3/go.mod h1:duVhxDW7M7M7+19IBCVth2REOS11gmqzTWwj4u8N7aQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI=
github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.34.0 h1:mBFWMaJSNL9RwdGRyEDoAAv8OQc5UlEhLDQggTglU/0=
github.com/alicebob/miniredis/v2 v2.34.0/go.mod h1:kWShP4b58T1CW0Y5dViCd5ztzrDqRWqM3nksiyXk5s8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/appscode/go v0.0.0-20191119085241-0887d8ec2ecc/go.mod h1:OawnOmAL4ZX3YaPdN+8HTNwBveT1jMsqP74moa9XUbE=
github.com/argoproj/gitops-engine v0.7.1-0.20250420064138-d65e9d92277d h1:NbaCC4ZX8aBB1gGByMf8CcSgL9ACwLSbXGKBl80XSa4=
github.com/argoproj/gitops-engine v0.7.1-0.20250420064138-d65e9d92277d/go.mod h1:8bIs7jN5U7iKEWU4fMzZfsYWa8ere+iU1rcTiwAtL3A=
github.com/argoproj/notifications-engine v0.4.1-0.20250309174002-87bf0576a872 h1:ADGAdyN9ty0+RmTT/yn+xV9vwkqvLn9O1ccqeP0Zeas=
github.com/argoproj/notifications-engine v0.4.1-0.20250309174002-87bf0576a872/go.mod h1:d1RazGXWvKRFv9//rg4MRRR7rbvbE7XLgTSMT5fITTE=
github.com/argoproj/pkg v0.13.6 h1:36WPD9MNYECHcO1/R1pj6teYspiK7uMQLCgLGft2abM=
Expand Down
61 changes: 0 additions & 61 deletions test/e2e/app_sync_options_test.go

This file was deleted.

125 changes: 122 additions & 3 deletions test/e2e/sync_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,89 @@ import (
"os"
"testing"

"github.com/argoproj/gitops-engine/pkg/health"
. "github.com/argoproj/gitops-engine/pkg/sync/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
. "github.com/argoproj/argo-cd/v3/test/e2e/fixture"
. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
"github.com/argoproj/argo-cd/v3/util/errors"
)

// TestSyncWithCreateNamespace verifies that the namespace is created when the
// CreateNamespace=true is provided as part of the normal sync resources
func TestSyncWithCreateNamespace(t *testing.T) {
newNamespace := getNewNamespace(t)
defer func() {
if !t.Skipped() {
errors.NewHandler(t).FailOnErr(fixture.Run("", "kubectl", "delete", "namespace", newNamespace))
}
}()

Given(t).
Path(guestbookPath).
When().
CreateFromFile(func(app *Application) {
app.Spec.Destination.Namespace = newNamespace
app.Spec.SyncPolicy = &SyncPolicy{
SyncOptions: SyncOptions{
"CreateNamespace=true",
},
}
}).
Then().
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
When().
Sync().
Then().
// Only one resource should be in sync result
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy)).
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(ResourceResultNumbering(3))
}

// TestSyncWithCreateNamespaceAndDryRunError verifies that the namespace is created before the
// DryRun validation is made on the resources, even if the sync fails. This allows transient errors
// to be resolved on sync retries
func TestSyncWithCreateNamespaceAndDryRunError(t *testing.T) {
newNamespace := getNewNamespace(t)
defer func() {
if !t.Skipped() {
errors.NewHandler(t).FailOnErr(fixture.Run("", "kubectl", "delete", "namespace", newNamespace))
}
}()

Given(t).
Path("failure-during-sync").
When().
CreateFromFile(func(app *Application) {
app.Spec.Destination.Namespace = newNamespace
app.Spec.SyncPolicy = &SyncPolicy{
SyncOptions: SyncOptions{
"CreateNamespace=true",
},
}
}).
Then().
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
When().
IgnoreErrors().
Sync().
Then().
// Only one resource should be in sync result
Expect(OperationPhaseIs(OperationFailed)).
Expect(ResourceResultNumbering(2)).
Expect(ResourceSyncStatusIs("Namespace", newNamespace, SyncStatusCodeSynced)).
Expect(ResourceSyncStatusWithNamespaceIs("ServiceAccount", newNamespace, "failure-during-sync", ""))
}

// TestSyncOptionsValidateFalse verifies we can disable validation during kubectl apply, using the
// 'argocd.argoproj.io/sync-options: Validate=false' sync option
func TestSyncOptionsValidateFalse(t *testing.T) {
Expand Down Expand Up @@ -53,7 +125,7 @@ func TestSyncWithStatusIgnored(t *testing.T) {
Path(guestbookPath).
When().
And(func() {
require.NoError(t, fixture.SetResourceOverrides(map[string]ResourceOverride{
require.NoError(t, SetResourceOverrides(map[string]ResourceOverride{
"/": {
IgnoreDifferences: OverrideIgnoreDiff{JSONPointers: []string{"/status"}},
},
Expand All @@ -73,7 +145,7 @@ func TestSyncWithStatusIgnored(t *testing.T) {
// app should remain synced if k8s change detected
When().
And(func() {
errors.NewHandler(t).FailOnErr(fixture.KubeClientset.AppsV1().Deployments(fixture.DeploymentNamespace()).Patch(t.Context(),
errors.NewHandler(t).FailOnErr(KubeClientset.AppsV1().Deployments(DeploymentNamespace()).Patch(t.Context(),
"guestbook-ui", types.JSONPatchType, []byte(`[{ "op": "replace", "path": "/status/observedGeneration", "value": 2 }]`), metav1.PatchOptions{}))
}).
Then().
Expand Down Expand Up @@ -104,7 +176,7 @@ func TestSyncWithApplyOutOfSyncOnly(t *testing.T) {
}

func TestSyncWithSkipHook(t *testing.T) {
fixture.SkipOnEnv(t, "OPENSHIFT")
SkipOnEnv(t, "OPENSHIFT")
Given(t).
Path(guestbookPath).
When().
Expand Down Expand Up @@ -146,3 +218,50 @@ func TestSyncWithForceReplace(t *testing.T) {
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced))
}

// Given application is set with --sync-option CreateNamespace=true and --sync-option ServerSideApply=true
//
// application --dest-namespace exists
//
// Then, --dest-namespace is created with server side apply
// application is synced and healthy with resource
// application resources created with server side apply in the newly created namespace.
func TestNamespaceCreationWithSSA(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test was moved and not changed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: test was updated because for some reason the e2e fails with error creating application: namespaces \"argocd-e2e-external\" not found which was not required for this test anyway.

SkipOnEnv(t, "OPENSHIFT")
namespace := "guestbook-ui-with-ssa"
defer func() {
if !t.Skipped() {
_, err := Run("", "kubectl", "delete", "namespace", namespace)
assert.NoError(t, err)
}
}()

ctx := Given(t)
ctx.
SetAppNamespace(AppNamespace()).
Timeout(30).
Path("guestbook").
When().
CreateFromFile(func(app *Application) {
app.Spec.SyncPolicy = &SyncPolicy{
SyncOptions: SyncOptions{"CreateNamespace=true", "ServerSideApply=true"},
}
}).
Then().
Expect(NoNamespace(namespace)).
When().
AppSet("--dest-namespace", namespace).
Sync().
Then().
Expect(Success("")).
Expect(Namespace(namespace, func(_ *Application, ns *corev1.Namespace) {
assert.NotContains(t, ns.Annotations, "kubectl.kubernetes.io/last-applied-configuration")
})).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy)).
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(ResourceHealthWithNamespaceIs("Deployment", "guestbook-ui", namespace, health.HealthStatusHealthy)).
Expect(ResourceSyncStatusWithNamespaceIs("Deployment", "guestbook-ui", namespace, SyncStatusCodeSynced)).
Expect(ResourceHealthWithNamespaceIs("Service", "guestbook-ui", namespace, health.HealthStatusHealthy)).
Expect(ResourceSyncStatusWithNamespaceIs("Service", "guestbook-ui", namespace, SyncStatusCodeSynced))
}