diff --git a/changelog/fragments/fix-run-packagemanifests-e2e.yaml b/changelog/fragments/fix-run-packagemanifests-e2e.yaml new file mode 100644 index 00000000000..0416698865d --- /dev/null +++ b/changelog/fragments/fix-run-packagemanifests-e2e.yaml @@ -0,0 +1,17 @@ +entries: + - description: + Fixed a bug with `run packagemanifests` that caused the underlying + registry pod to fail to start. Changed the registry pod image from + `quay.io/openshift/origin-operator-registry:latest` to + `quay.io/operator-framework/upstream-registry-builder:latest` + + # kind is one of: + # - addition + # - change + # - deprecation + # - removal + # - bugfix + kind: bugfix + + # Is this a breaking change? + breaking: false diff --git a/hack/tests/integration.sh b/hack/tests/integration.sh index 49ded33a4b4..836b82c7707 100755 --- a/hack/tests/integration.sh +++ b/hack/tests/integration.sh @@ -42,7 +42,7 @@ popd # Install OLM on the cluster if not installed. olm_latest_exists=0 if ! operator-sdk olm status > /dev/null 2>&1; then - operator-sdk olm install + operator-sdk olm install --version=0.15.1 olm_latest_exists=1 fi @@ -58,5 +58,5 @@ header_text "Integration tests succeeded" # Uninstall OLM if it was installed for test purposes. if eval "(( $olm_latest_exists ))"; then - operator-sdk olm uninstall + operator-sdk olm uninstall --version=0.15.1 fi diff --git a/internal/olm/client/client.go b/internal/olm/client/client.go index 0bf36877f66..5edfb4f8734 100644 --- a/internal/olm/client/client.go +++ b/internal/olm/client/client.go @@ -211,7 +211,15 @@ func (c Client) DoCSVWait(ctx context.Context, key types.NamespacedName) error { curPhase = newPhase log.Printf(" Found ClusterServiceVersion %q phase: %s", key, curPhase) } - return curPhase == olmapiv1alpha1.CSVPhaseSucceeded, nil + + switch curPhase { + case olmapiv1alpha1.CSVPhaseFailed: + return false, fmt.Errorf("csv failed: reason: %q, message: %q", csv.Status.Reason, csv.Status.Message) + case olmapiv1alpha1.CSVPhaseSucceeded: + return true, nil + default: + return false, nil + } } return wait.PollImmediateUntil(time.Second, csvPhaseSucceeded, ctx.Done()) diff --git a/internal/olm/operator/registry/configmap/deployment.go b/internal/olm/operator/registry/configmap/deployment.go index ebca08875ab..70a0e4cfe6e 100644 --- a/internal/olm/operator/registry/configmap/deployment.go +++ b/internal/olm/operator/registry/configmap/deployment.go @@ -17,18 +17,18 @@ package configmap import ( "fmt" - "github.com/operator-framework/operator-sdk/internal/util/k8sutil" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/operator-framework/operator-sdk/internal/util/k8sutil" ) const ( // The image operator-registry's initializer and registry-server binaries // are run from. // QUESTION(estroz): version registry image? - registryBaseImage = "quay.io/openshift/origin-operator-registry:latest" + registryBaseImage = "quay.io/operator-framework/upstream-registry-builder:latest" // The port registry-server will listen on within a container. registryGRPCPort = 50051 // Path of the bundle database generated by initializer. @@ -99,14 +99,15 @@ func withContainerVolumeMounts(volName string, paths ...string) func(*appsv1.Dep } // getDBContainerCmd returns a command string that, when run, does two things: -// 1. Runs a database initializer on the manifests in the current working +// 1. Runs a database initializer on the manifests in the /registry // directory. // 2. Runs an operator-registry server serving the bundle database. -// The database must be in the current working directory. +// The database must be in /registry directory. func getDBContainerCmd(dbPath, logPath string) string { - initCmd := fmt.Sprintf("/usr/bin/initializer -o %s", dbPath) - srvCmd := fmt.Sprintf("/usr/bin/registry-server -d %s -t %s", dbPath, logPath) - return fmt.Sprintf("%s && %s", initCmd, srvCmd) + cdCmd := "cd /registry" + initCmd := fmt.Sprintf("/bin/initializer -o %s", dbPath) + srvCmd := fmt.Sprintf("/bin/registry-server -d %s -t %s", dbPath, logPath) + return fmt.Sprintf("%s && %s && %s", cdCmd, initCmd, srvCmd) } // withRegistryGRPCContainer returns a function that appends a container @@ -116,7 +117,7 @@ func withRegistryGRPCContainer(pkgName string) func(*appsv1.Deployment) { container := corev1.Container{ Name: getRegistryServerName(pkgName), Image: registryBaseImage, - Command: []string{"/bin/bash"}, + Command: []string{"/bin/sh"}, Args: []string{ "-c", // TODO(estroz): grab logs and print if error diff --git a/test/e2e-ansible/e2e_ansible_olm_test.go b/test/e2e-ansible/e2e_ansible_olm_test.go index a3b33f4e984..c7ba8f0f1aa 100644 --- a/test/e2e-ansible/e2e_ansible_olm_test.go +++ b/test/e2e-ansible/e2e_ansible_olm_test.go @@ -18,14 +18,13 @@ import ( "encoding/json" "fmt" "os/exec" - "path" "path/filepath" "strings" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/operator-framework/api/pkg/apis/scorecard/v1alpha3" + testutils "github.com/operator-framework/operator-sdk/test/internal" ) @@ -55,16 +54,18 @@ var _ = Describe("Integrating ansible Projects with OLM", func() { By("building the operator bundle image") // Use the existing image tag but with a "-bundle" suffix. imageSplit := strings.SplitN(tc.ImageName, ":", 2) - bundleImage := path.Join("quay.io", imageSplit[0]+"-bundle") + bundleImage := imageSplit[0] + "-bundle" if len(imageSplit) == 2 { bundleImage += ":" + imageSplit[1] } err = tc.Make("bundle-build", "BUNDLE_IMG="+bundleImage) Expect(err).NotTo(HaveOccurred()) - By("loading the project image into Kind cluster") - err = tc.LoadImageToKindClusterWithName(bundleImage) - Expect(err).Should(Succeed()) + if isRunningOnKind() { + By("loading the bundle image into Kind cluster") + err = tc.LoadImageToKindClusterWithName(bundleImage) + Expect(err).Should(Succeed()) + } By("adding the 'packagemanifests' rule to the Makefile") err = tc.AddPackagemanifestsTarget() diff --git a/test/e2e-helm/e2e_helm_olm_test.go b/test/e2e-helm/e2e_helm_olm_test.go index a09631336f5..121c7de55ea 100644 --- a/test/e2e-helm/e2e_helm_olm_test.go +++ b/test/e2e-helm/e2e_helm_olm_test.go @@ -18,7 +18,6 @@ import ( "encoding/json" "fmt" "os/exec" - "path" "path/filepath" "strings" @@ -55,16 +54,18 @@ var _ = Describe("Integrating Helm Projects with OLM", func() { By("building the operator bundle image") // Use the existing image tag but with a "-bundle" suffix. imageSplit := strings.SplitN(tc.ImageName, ":", 2) - bundleImage := path.Join("quay.io", imageSplit[0]+"-bundle") + bundleImage := imageSplit[0] + "-bundle" if len(imageSplit) == 2 { bundleImage += ":" + imageSplit[1] } err = tc.Make("bundle-build", "BUNDLE_IMG="+bundleImage) Expect(err).NotTo(HaveOccurred()) - By("loading the project image into Kind cluster") - err = tc.LoadImageToKindClusterWithName(bundleImage) - Expect(err).Should(Succeed()) + if isRunningOnKind() { + By("loading the bundle image into Kind cluster") + err = tc.LoadImageToKindClusterWithName(bundleImage) + Expect(err).Should(Succeed()) + } By("adding the 'packagemanifests' rule to the Makefile") err = tc.AddPackagemanifestsTarget() diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 1ded91a44c9..1e13c222ef9 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -184,7 +184,7 @@ var _ = Describe("operator-sdk", func() { By("building the operator bundle image") // Use the existing image tag but with a "-bundle" suffix. imageSplit := strings.SplitN(tc.ImageName, ":", 2) - bundleImage := path.Join("quay.io", imageSplit[0]+"-bundle") + bundleImage := imageSplit[0] + "-bundle" if len(imageSplit) == 2 { bundleImage += ":" + imageSplit[1] }