Skip to content

Commit 5816d87

Browse files
committed
fix copy packages destination to match import images
1 parent 34e02da commit 5816d87

File tree

5 files changed

+111
-78
lines changed

5 files changed

+111
-78
lines changed

test/e2e/constants.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
)
88

99
const (
10-
EksaPackagesRegistryMirrorAlias = "curated-packages"
11-
EksaPackagesSourceRegistry = "public.ecr.aws/x3k6m8v0"
12-
EksaPackageBundleURI = "oci://" + EksaPackagesSourceRegistry + "/eks-anywhere-packages-bundles"
13-
EksaPackagesNamespace = "eksa-packages"
14-
EksaPackagesRegistry = "067575901363.dkr.ecr.us-west-2.amazonaws.com"
10+
EksaPackagesDevPublicRegistryAlias = "x3k6m8v0"
11+
EksaPackagesStagingPublicRegistryAlias = "w9m0f3l5"
12+
EksaPackagesDevPrivateRegistry = "067575901363.dkr.ecr.us-west-2.amazonaws.com"
13+
EksaPackagesStagingPrivateRegistry = "724423470321.dkr.ecr.us-west-2.amazonaws.com"
14+
EksaPackagesNamespace = "eksa-packages"
1515

1616
clusterNamespace = "test-namespace"
1717

test/e2e/curatedpackages.go

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,66 @@ func runDisabledCuratedPackageInstallSimpleFlow(test *framework.ClusterE2ETest)
5151
test.WithCluster(runDisabledCuratedPackage)
5252
}
5353

54+
// addDefaultOCINamespacesFromEnv adds default OCI namespaces from environment variables if they're not already set.
55+
func addDefaultOCINamespacesFromEnv(test *framework.ClusterE2ETest) {
56+
if test.ClusterConfig.Cluster.Spec.RegistryMirrorConfiguration == nil {
57+
return
58+
}
59+
60+
if len(test.ClusterConfig.Cluster.Spec.RegistryMirrorConfiguration.OCINamespaces) > 0 {
61+
return
62+
}
63+
64+
test.T.Log("Adding default OCI namespaces from environment variables")
65+
test.ClusterConfig.Cluster.Spec.RegistryMirrorConfiguration.OCINamespaces = framework.DefaultOciNamespaces(test)
66+
}
67+
5468
func runCuratedPackageInstallSimpleFlowRegistryMirror(test *framework.ClusterE2ETest) {
55-
test.WithClusterRegistryMirror(EksaPackagesRegistryMirrorAlias, EksaPackagesSourceRegistry, EksaPackagesRegistry, runCuratedPackageInstall)
69+
test.GenerateClusterConfig()
70+
test.DownloadArtifacts()
71+
test.ExtractDownloadedArtifacts()
72+
73+
// Determine the correct alias from the bundle after download
74+
packageControllerChartRepo, err := test.GetPackageControlleChartRepo()
75+
if err != nil {
76+
test.T.Fatalf("Failed to determine package controller repo: %v", err)
77+
}
78+
79+
var pkgRegistry, alias string
80+
if strings.Contains(packageControllerChartRepo, EksaPackagesDevPublicRegistryAlias) {
81+
pkgRegistry = EksaPackagesDevPrivateRegistry
82+
alias = EksaPackagesDevPublicRegistryAlias
83+
}
84+
if strings.Contains(packageControllerChartRepo, EksaPackagesStagingPublicRegistryAlias) {
85+
pkgRegistry = EksaPackagesStagingPrivateRegistry
86+
alias = EksaPackagesStagingPublicRegistryAlias
87+
}
88+
89+
// Add default OCI namespaces from env vars, then append the curated packages one
90+
if test.ClusterConfig.Cluster.Spec.RegistryMirrorConfiguration != nil {
91+
addDefaultOCINamespacesFromEnv(test)
92+
93+
test.ClusterConfig.Cluster.Spec.RegistryMirrorConfiguration.OCINamespaces = append(
94+
test.ClusterConfig.Cluster.Spec.RegistryMirrorConfiguration.OCINamespaces,
95+
v1alpha1.OCINamespace{
96+
Registry: pkgRegistry,
97+
Namespace: alias,
98+
},
99+
)
100+
}
101+
test.UpdateClusterConfig()
102+
103+
test.DownloadImages()
104+
test.ImportImages()
105+
test.CopyPackages(alias, pkgRegistry)
106+
107+
bundlePath := "./eks-anywhere-downloads/bundle-release.yaml"
108+
test.CreateCluster(framework.WithBundlesOverride(bundlePath))
109+
defer func() {
110+
test.GenerateSupportBundleIfTestFailed()
111+
test.DeleteCluster(framework.WithBundlesOverride(bundlePath))
112+
}()
113+
runCuratedPackageInstall(test)
56114
}
57115

58116
func runCuratedPackageRemoteClusterInstallSimpleFlow(test *framework.MulticlusterE2ETest) {
@@ -215,13 +273,6 @@ func GetLatestBundleFromCluster(test *framework.ClusterE2ETest) (string, error)
215273
return strings.Trim(bundle, "'"), nil
216274
}
217275

218-
// packageBundleURI uses a KubernetesVersion argument to complete a package
219-
// bundle URI by adding the approprate tag.
220-
func packageBundleURI(version v1alpha1.KubernetesVersion) string {
221-
tag := "v" + strings.Replace(string(version), ".", "-", 1) + "-latest"
222-
return fmt.Sprintf("%s:%s", EksaPackageBundleURI, tag)
223-
}
224-
225276
func withCluster(cluster *framework.ClusterE2ETest) *types.Cluster {
226277
return &types.Cluster{
227278
Name: cluster.ClusterName,

test/e2e/vsphere_test.go

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,11 +2930,7 @@ func TestVSphereKubernetes129UbuntuAuthenticatedRegistryMirrorCuratedPackagesSim
29302930
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
29312931
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
29322932
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube129)),
2933-
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName,
2934-
v1alpha1.OCINamespace{
2935-
Registry: EksaPackagesRegistry,
2936-
Namespace: EksaPackagesRegistryMirrorAlias,
2937-
}),
2933+
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName),
29382934
)
29392935
runCuratedPackageInstallSimpleFlowRegistryMirror(test)
29402936
}
@@ -2948,11 +2944,7 @@ func TestVSphereKubernetes134UbuntuAuthenticatedRegistryMirrorCuratedPackagesSim
29482944
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
29492945
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
29502946
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube134)),
2951-
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName,
2952-
v1alpha1.OCINamespace{
2953-
Registry: EksaPackagesRegistry,
2954-
Namespace: EksaPackagesRegistryMirrorAlias,
2955-
}),
2947+
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName),
29562948
)
29572949
runCuratedPackageInstallSimpleFlowRegistryMirror(test)
29582950
}
@@ -2966,11 +2958,7 @@ func TestVSphereKubernetes130UbuntuAuthenticatedRegistryMirrorCuratedPackagesSim
29662958
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
29672959
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
29682960
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube130)),
2969-
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName,
2970-
v1alpha1.OCINamespace{
2971-
Registry: EksaPackagesRegistry,
2972-
Namespace: EksaPackagesRegistryMirrorAlias,
2973-
}),
2961+
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName),
29742962
)
29752963
runCuratedPackageInstallSimpleFlowRegistryMirror(test)
29762964
}
@@ -2984,11 +2972,7 @@ func TestVSphereKubernetes131UbuntuAuthenticatedRegistryMirrorCuratedPackagesSim
29842972
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
29852973
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
29862974
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube131)),
2987-
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName,
2988-
v1alpha1.OCINamespace{
2989-
Registry: EksaPackagesRegistry,
2990-
Namespace: EksaPackagesRegistryMirrorAlias,
2991-
}),
2975+
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName),
29922976
)
29932977
runCuratedPackageInstallSimpleFlowRegistryMirror(test)
29942978
}
@@ -3002,11 +2986,7 @@ func TestVSphereKubernetes132UbuntuAuthenticatedRegistryMirrorCuratedPackagesSim
30022986
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
30032987
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
30042988
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube132)),
3005-
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName,
3006-
v1alpha1.OCINamespace{
3007-
Registry: EksaPackagesRegistry,
3008-
Namespace: EksaPackagesRegistryMirrorAlias,
3009-
}),
2989+
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName),
30102990
)
30112991
runCuratedPackageInstallSimpleFlowRegistryMirror(test)
30122992
}
@@ -3020,11 +3000,7 @@ func TestVSphereKubernetes133UbuntuAuthenticatedRegistryMirrorCuratedPackagesSim
30203000
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
30213001
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
30223002
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube133)),
3023-
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName,
3024-
v1alpha1.OCINamespace{
3025-
Registry: EksaPackagesRegistry,
3026-
Namespace: EksaPackagesRegistryMirrorAlias,
3027-
}),
3003+
framework.WithAuthenticatedRegistryMirror(constants.VSphereProviderName),
30283004
)
30293005
runCuratedPackageInstallSimpleFlowRegistryMirror(test)
30303006
}

test/framework/cluster.go

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -651,17 +651,18 @@ func (e *ClusterE2ETest) CleanupDownloadedArtifactsAndImages(opts ...CommandOpt)
651651
e.Run("rm", "-rf", defaultDownloadArtifactsOutputLocation, defaultDownloadImagesOutputLocation)
652652
}
653653

654+
func getBundleManifestLocation() string {
655+
if _, err := os.Stat(defaultDownloadArtifactsOutputLocation); err == nil {
656+
return bundleReleasePathFromArtifacts
657+
}
658+
return defaultBundleReleaseManifestFile
659+
}
660+
654661
// DownloadImages runs the EKS-A `download images` command with appropriate args.
655662
func (e *ClusterE2ETest) DownloadImages(opts ...CommandOpt) {
656663
downloadImagesArgs := []string{"download", "images", "-o", defaultDownloadImagesOutputLocation}
657664
if getBundlesOverride() == "true" {
658-
var bundleManifestLocation string
659-
if _, err := os.Stat(defaultDownloadArtifactsOutputLocation); err == nil {
660-
bundleManifestLocation = bundleReleasePathFromArtifacts
661-
} else {
662-
bundleManifestLocation = defaultBundleReleaseManifestFile
663-
}
664-
downloadImagesArgs = append(downloadImagesArgs, "--bundles-override", bundleManifestLocation)
665+
downloadImagesArgs = append(downloadImagesArgs, "--bundles-override", getBundleManifestLocation())
665666
}
666667
e.RunEKSA(downloadImagesArgs, opts...)
667668
if _, err := os.Stat(defaultDownloadImagesOutputLocation); err != nil {
@@ -676,18 +677,38 @@ func (e *ClusterE2ETest) ImportImages(opts ...CommandOpt) {
676677
clusterConfig := e.ClusterConfig.Cluster
677678
registyMirrorEndpoint, registryMirrorPort := clusterConfig.Spec.RegistryMirrorConfiguration.Endpoint, clusterConfig.Spec.RegistryMirrorConfiguration.Port
678679
registryMirrorHost := net.JoinHostPort(registyMirrorEndpoint, registryMirrorPort)
679-
var bundleManifestLocation string
680-
if _, err := os.Stat(defaultDownloadArtifactsOutputLocation); err == nil {
681-
bundleManifestLocation = bundleReleasePathFromArtifacts
682-
} else {
683-
bundleManifestLocation = defaultBundleReleaseManifestFile
684-
}
680+
bundleManifestLocation := getBundleManifestLocation()
685681
importImagesArgs := []string{"import images", "--input", defaultDownloadImagesOutputLocation, "--bundles", bundleManifestLocation, "--registry", registryMirrorHost, "--insecure"}
686682
e.RunEKSA(importImagesArgs, opts...)
687683
}
688684

685+
// GetPackageControllerRepo returns the bundle's package controller chart image.
686+
func (e *ClusterE2ETest) GetPackageControlleChartRepo() (string, error) {
687+
bundleManifestLocation := getBundleManifestLocation()
688+
689+
// Read the bundle file
690+
bundleData, err := os.ReadFile(bundleManifestLocation)
691+
if err != nil {
692+
return "", fmt.Errorf("failed to read bundle file %s: %w", bundleManifestLocation, err)
693+
}
694+
695+
// Parse the bundle
696+
var bundles releasev1.Bundles
697+
if err := yaml.Unmarshal(bundleData, &bundles); err != nil {
698+
return "", fmt.Errorf("failed to parse bundle file: %w", err)
699+
}
700+
701+
// Get the package controller chart image from the first version bundle
702+
if len(bundles.Spec.VersionsBundles) == 0 {
703+
return "", fmt.Errorf("no version bundles found in bundle file")
704+
}
705+
706+
return bundles.Spec.VersionsBundles[0].PackageController.HelmChart.Image(), nil
707+
708+
}
709+
689710
// CopyPackages runs the EKS-A `copy packages` command to copy curated packages to the registry mirror.
690-
func (e *ClusterE2ETest) CopyPackages(packageMirrorAlias string, packageChartRegistry string, packageRegistry string, opts ...CommandOpt) {
711+
func (e *ClusterE2ETest) CopyPackages(packageMirrorAlias string, packageRegistry string, opts ...CommandOpt) {
691712
clusterConfig := e.ClusterConfig.Cluster
692713
registyMirrorEndpoint, registryMirrorPort := clusterConfig.Spec.RegistryMirrorConfiguration.Endpoint, clusterConfig.Spec.RegistryMirrorConfiguration.Port
693714
registryMirrorHost := net.JoinHostPort(registyMirrorEndpoint, registryMirrorPort)
@@ -700,12 +721,12 @@ func (e *ClusterE2ETest) CopyPackages(packageMirrorAlias string, packageChartReg
700721
"copy", "packages",
701722
registryMirrorHost + "/" + packageMirrorAlias,
702723
"--kube-version", kubeVersion,
703-
"--src-chart-registry", packageChartRegistry,
724+
"--src-chart-registry", packageRegistry,
704725
"--src-image-registry", packageRegistry,
705726
"--dst-insecure",
706727
}
707728

708-
e.T.Logf("Copying curated packages to registry mirror: %s", registryMirrorHost)
729+
e.T.Logf("Copying curated packages to registry mirror: %s/%s", registryMirrorHost, packageMirrorAlias)
709730
e.RunEKSA(copyPackagesArgs, opts...)
710731
}
711732

@@ -1327,22 +1348,6 @@ func (e *ClusterE2ETest) WithCluster(f func(e *ClusterE2ETest)) {
13271348
f(e)
13281349
}
13291350

1330-
// WithClusterRegistryMirror helps with bringing up and tearing down E2E test clusters when using registry mirror.
1331-
func (e *ClusterE2ETest) WithClusterRegistryMirror(packageMirrorAlias string, packageChartRegistry string, packageRegistry string, f func(e *ClusterE2ETest)) {
1332-
e.GenerateClusterConfig()
1333-
e.DownloadArtifacts()
1334-
e.ExtractDownloadedArtifacts()
1335-
e.DownloadImages()
1336-
e.ImportImages()
1337-
e.CopyPackages(packageMirrorAlias, packageChartRegistry, packageRegistry)
1338-
e.CreateCluster(WithBundlesOverride(bundleReleasePathFromArtifacts))
1339-
defer func() {
1340-
e.GenerateSupportBundleIfTestFailed()
1341-
e.DeleteCluster(WithBundlesOverride(bundleReleasePathFromArtifacts))
1342-
}()
1343-
f(e)
1344-
}
1345-
13461351
// Like WithCluster but does not delete the cluster. Useful for debugging.
13471352
func (e *ClusterE2ETest) WithPersistentCluster(f func(e *ClusterE2ETest)) {
13481353
configPath := e.KubeconfigFilePath()

test/framework/registry_mirror.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ func WithRegistryMirrorEndpointAndCert(providerName string) ClusterE2ETestOpt {
6767
// WithRegistryMirrorOciNamespaces sets up e2e for registry mirrors with ocinamespaces.
6868
func WithRegistryMirrorOciNamespaces(providerName string) ClusterE2ETestOpt {
6969
return func(e *ClusterE2ETest) {
70-
ociNamespaces := defaultOciNamespaces(e)
70+
ociNamespaces := DefaultOciNamespaces(e)
7171
setupRegistryMirrorEndpointAndCert(e, providerName, false, ociNamespaces...)
7272
}
7373
}
7474

75-
func defaultOciNamespaces(e *ClusterE2ETest) []v1alpha1.OCINamespace {
75+
// DefaultOciNamespaces returns the default OCI namespaces from environment variables.
76+
func DefaultOciNamespaces(e *ClusterE2ETest) []v1alpha1.OCINamespace {
7677
var ociNamespaces []v1alpha1.OCINamespace
7778

7879
checkRequiredEnvVars(e.T, registryMirrorOciNamespacesRequiredEnvVars)
@@ -139,7 +140,7 @@ func WithAuthenticatedRegistryMirror(providerName string, optNamespaces ...v1alp
139140

140141
var ociNamespaces []v1alpha1.OCINamespace
141142
if len(optNamespaces) > 0 {
142-
ociNamespaces = append(defaultOciNamespaces(e), optNamespaces...)
143+
ociNamespaces = append(DefaultOciNamespaces(e), optNamespaces...)
143144
}
144145

145146
certificate, err := base64.StdEncoding.DecodeString(registryCert)

0 commit comments

Comments
 (0)