Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
37 changes: 33 additions & 4 deletions e2e/nomostest/config_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ var (
//
// All paths must be relative to the test file that is running. There is probably
// a more elegant way to do this.
baseDir = filepath.FromSlash("../..")
outputManifestsDir = filepath.Join(baseDir, ".output", "staging", "oss")
configSyncManifest = filepath.Join(outputManifestsDir, "config-sync-manifest.yaml")
multiConfigMaps = filepath.Join(baseDir, "e2e", "raw-nomos", configSyncManifests, multiConfigMapsName)
baseDir = filepath.FromSlash("../..")
outputManifestsDir = filepath.Join(baseDir, ".output", "staging", "oss")
configSyncManifest = filepath.Join(outputManifestsDir, "config-sync-manifest.yaml")
admissionWebhookManifest = filepath.Join(outputManifestsDir, "admission-webhook.yaml")
multiConfigMaps = filepath.Join(baseDir, "e2e", "raw-nomos", configSyncManifests, multiConfigMapsName)
)

var (
Expand Down Expand Up @@ -245,6 +246,34 @@ func InstallConfigSync(nt *NT) error {
return nil
}

// InstallConfigSyncFromManifest installs ConfigSync on the test cluster by directly
// applying the manifest file using kubectl client-side apply
func InstallConfigSyncFromManifest(nt *NT) error {
nt.T.Log("[SETUP] Installing Config Sync directly from manifest file")

nt.T.Logf("Applying Config Sync manifest directly from %s", configSyncManifest)

out, err := nt.Shell.Kubectl("apply", "--server-side=false", "-f", configSyncManifest)
if err != nil {
return fmt.Errorf("failed to apply Config Sync manifest: %v\n%s", err, out)
}

nt.T.Logf("Applying multi-repo configmaps from %s", multiConfigMaps)
out, err = nt.Shell.Kubectl("apply", "--server-side=false", "-f", multiConfigMaps)
if err != nil {
return fmt.Errorf("failed to apply multi-repo configmaps: %v\n%s", err, out)
}

// Apply the admission webhook manifest
nt.T.Logf("Applying admission webhook manifest from %s", admissionWebhookManifest)
out, err = nt.Shell.Kubectl("apply", "--server-side=false", "-f", admissionWebhookManifest)
if err != nil {
return fmt.Errorf("failed to apply admission webhook manifest: %v\n%s", err, out)
}

return nil
}

// uninstallConfigSync uninstalls ConfigSync on the test cluster
func uninstallConfigSync(nt *NT) error {
nt.T.Log("[CLEANUP] Uninstalling Config Sync")
Expand Down
24 changes: 13 additions & 11 deletions e2e/testcases/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,13 +1297,14 @@ func TestApiResourceFormatting(t *testing.T) {
}

func TestNomosMigrate(t *testing.T) {
nt := nomostest.New(t, nomostesting.NomosCLI, ntopts.SkipConfigSyncInstall)
nt := nomostest.New(t, nomostesting.NomosCLI)

nt.T.Cleanup(func() {
// Restore state of Config Sync installation after test
if err := nomostest.InstallConfigSync(nt); err != nil {
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
nt.T.Fatal(err)
}
nt.Must(nt.WatchForAllSyncs())
})
nt.T.Cleanup(func() {
cmObj := &unstructured.Unstructured{
Expand Down Expand Up @@ -1451,11 +1452,11 @@ func TestNomosMigrate(t *testing.T) {
configmanagement.RGControllerName, configmanagement.RGControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.Deployment(),
return nt.Watcher.WatchForCurrentStatus(kinds.Deployment(),
core.RootReconcilerName(configsync.RootSyncName), configsync.ControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.RootSyncV1Beta1(),
return nt.Watcher.WatchForCurrentStatus(kinds.RootSyncV1Beta1(),
configsync.RootSyncName, configsync.ControllerNamespace)
})
if err := tg.Wait(); err != nil {
Expand All @@ -1464,14 +1465,14 @@ func TestNomosMigrate(t *testing.T) {
}

func TestNomosMigrateMonoRepo(t *testing.T) {
nt := nomostest.New(t, nomostesting.NomosCLI, ntopts.SkipConfigSyncInstall)
nt := nomostest.New(t, nomostesting.NomosCLI)

nt.T.Cleanup(func() {
// Restore state of Config Sync installation after test.
// This also emulates upgrading to the current version after migrating
if err := nomostest.InstallConfigSync(nt); err != nil {
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
nt.T.Fatal(err)
}
nt.Must(nt.WatchForAllSyncs())
})
nt.T.Cleanup(func() {
crds := []string{
Expand Down Expand Up @@ -1707,13 +1708,14 @@ func TestNomosMigrateMonoRepo(t *testing.T) {
// This test case validates the behavior of the uninstall script defined
// at installation/uninstall_configmanagement.sh
func TestACMUninstallScript(t *testing.T) {
nt := nomostest.New(t, nomostesting.NomosCLI, ntopts.SkipConfigSyncInstall)
nt := nomostest.New(t, nomostesting.NomosCLI)

nt.T.Cleanup(func() {
// Restore state of Config Sync installation after test
if err := nomostest.InstallConfigSync(nt); err != nil {
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
nt.T.Fatal(err)
}
nt.Must(nt.WatchForAllSyncs())
})
nt.T.Cleanup(func() {
cmObj := &unstructured.Unstructured{
Expand Down Expand Up @@ -1861,11 +1863,11 @@ func TestACMUninstallScript(t *testing.T) {
configmanagement.RGControllerName, configmanagement.RGControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.Deployment(),
return nt.Watcher.WatchForCurrentStatus(kinds.Deployment(),
core.RootReconcilerName(configsync.RootSyncName), configsync.ControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.RootSyncV1Beta1(),
return nt.Watcher.WatchForCurrentStatus(kinds.RootSyncV1Beta1(),
configsync.RootSyncName, configsync.ControllerNamespace)
})
if err := tg.Wait(); err != nil {
Expand Down
4 changes: 0 additions & 4 deletions manifests/otel-agent-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ data:
batch:
resourcedetection:
detectors: [env, gcp]
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [health_check]
pipelines:
metrics:
receivers: [opencensus]
Expand Down
4 changes: 0 additions & 4 deletions manifests/otel-agent-reconciler-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ data:
# the GCE metadata service, if available.
resourcedetection:
detectors: [env, gcp]
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [health_check]
pipelines:
metrics:
receivers: [opencensus]
Expand Down
7 changes: 0 additions & 7 deletions manifests/templates/reconciler-manager-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,9 @@ data:
protocol: TCP
- containerPort: 8888 # Metrics.
protocol: TCP
- containerPort: 13133 # Health check
protocol: TCP
volumeMounts:
- name: otel-agent-config-reconciler-vol
mountPath: /conf
readinessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
scheme: HTTP
imagePullPolicy: IfNotPresent
# These KUBE env vars help populate OTEL_RESOURCE_ATTRIBUTES which
# is used by the otel-agent to populate resource attributes when
Expand Down
5 changes: 0 additions & 5 deletions manifests/templates/reconciler-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ spec:
ports:
- containerPort: 55678 # Default OpenCensus receiver port.
- containerPort: 8888 # Metrics.
- containerPort: 13133 # Health check
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand All @@ -91,10 +90,6 @@ spec:
volumeMounts:
- name: otel-agent-config-vol
mountPath: /conf
readinessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
# These KUBE env vars help populate OTEL_RESOURCE_ATTRIBUTES which
# is used by the otel-agent to populate resource attributes when
# emiting metrics to the otel-collector. This is more efficient than
Expand Down
9 changes: 0 additions & 9 deletions manifests/templates/resourcegroup-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ data:
# the GCE metadata service, if available.
resourcedetection:
detectors: [env, gcp]
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [health_check]
pipelines:
metrics:
receivers: [opencensus]
Expand Down Expand Up @@ -274,11 +270,6 @@ spec:
ports:
- containerPort: 55678
- containerPort: 8888
- containerPort: 13133
readinessProbe:
httpGet:
path: /
port: 13133
resources:
requests:
cpu: 10m
Expand Down
29 changes: 0 additions & 29 deletions test/kustomization/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5650,11 +5650,7 @@ data:
batch:
resourcedetection:
detectors: [env, gcp]
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [health_check]
pipelines:
metrics:
receivers: [opencensus]
Expand Down Expand Up @@ -5708,11 +5704,7 @@ data:
# the GCE metadata service, if available.
resourcedetection:
detectors: [env, gcp]
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [health_check]
pipelines:
metrics:
receivers: [opencensus]
Expand Down Expand Up @@ -5902,16 +5894,9 @@ data:
protocol: TCP
- containerPort: 8888 # Metrics.
protocol: TCP
- containerPort: 13133 # Health check
protocol: TCP
volumeMounts:
- name: otel-agent-config-reconciler-vol
mountPath: /conf
readinessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
scheme: HTTP
imagePullPolicy: IfNotPresent
# These KUBE env vars help populate OTEL_RESOURCE_ATTRIBUTES which
# is used by the otel-agent to populate resource attributes when
Expand Down Expand Up @@ -6034,11 +6019,7 @@ data:
# the GCE metadata service, if available.
resourcedetection:
detectors: [env, gcp]
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [health_check]
pipelines:
metrics:
receivers: [opencensus]
Expand Down Expand Up @@ -6369,11 +6350,6 @@ spec:
ports:
- containerPort: 55678
- containerPort: 8888
- containerPort: 13133
readinessProbe:
httpGet:
path: /
port: 13133
resources:
limits:
cpu: 1
Expand Down Expand Up @@ -6493,11 +6469,6 @@ spec:
ports:
- containerPort: 55678
- containerPort: 8888
- containerPort: 13133
readinessProbe:
httpGet:
path: /
port: 13133
resources:
requests:
cpu: 10m
Expand Down