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/changelog/fragments/run-pkgmnfs-writable-dir.yaml b/changelog/fragments/run-pkgmnfs-writable-dir.yaml new file mode 100644 index 00000000000..7dbae3a846e --- /dev/null +++ b/changelog/fragments/run-pkgmnfs-writable-dir.yaml @@ -0,0 +1,5 @@ +entries: + - description: > + Fix an issue in `run packagemanifests` where the registry server + writes files in locations that require root. + kind: bugfix diff --git a/hack/tests/integration.sh b/hack/tests/integration.sh index 05b98136216..4d6de154184 100755 --- a/hack/tests/integration.sh +++ b/hack/tests/integration.sh @@ -16,7 +16,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 @@ -26,7 +26,7 @@ go test -v ./test/integration # 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 echo -e "\n=== Integration tests succeeded ===\n" diff --git a/internal/olm/client/client.go b/internal/olm/client/client.go index 9cfb7341fd0..2a80e978398 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/internal/deployment.go b/internal/olm/operator/internal/deployment.go index 3538be6bc2d..a69c7609bad 100644 --- a/internal/olm/operator/internal/deployment.go +++ b/internal/olm/operator/internal/deployment.go @@ -17,25 +17,26 @@ package olm 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. - regisryDBName = "bundle.db" - // Path of the log file generated by registry-server. - // TODO(estroz): have this log file in an obvious place, ex. /var/log. - registryLogFile = "termination.log" + // Path of the bundle database generated by initializer. Use /tmp since it is + // typically world-writable. + registryDBName = "/tmp/bundle.db" + // Path of the log file generated by registry-server. Use /tmp since it is + // typically world-writable. + registryLogFile = "/tmp/termination.log" ) func getRegistryServerName(pkgName string) string { @@ -99,13 +100,12 @@ 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. 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) + initCmd := fmt.Sprintf("/bin/initializer -o %s -m %s", dbPath, containerManifestsDir) + srvCmd := fmt.Sprintf("/bin/registry-server -d %s -t %s", dbPath, logPath) return fmt.Sprintf("%s && %s", initCmd, srvCmd) } @@ -114,13 +114,14 @@ func getDBContainerCmd(dbPath, logPath string) string { // pod template spec. func withRegistryGRPCContainer(pkgName string) func(*appsv1.Deployment) { container := corev1.Container{ - Name: getRegistryServerName(pkgName), - Image: registryBaseImage, - Command: []string{"/bin/bash"}, + Name: getRegistryServerName(pkgName), + Image: registryBaseImage, + WorkingDir: "/tmp", + Command: []string{"/bin/sh"}, Args: []string{ "-c", // TODO(estroz): grab logs and print if error - getDBContainerCmd(regisryDBName, registryLogFile), + getDBContainerCmd(registryDBName, registryLogFile), }, Ports: []corev1.ContainerPort{ {Name: "registry-grpc", ContainerPort: registryGRPCPort}, diff --git a/test/e2e-new/e2e_suite.go b/test/e2e-new/e2e_suite.go index af46fe26de2..6a445967c36 100644 --- a/test/e2e-new/e2e_suite.go +++ b/test/e2e-new/e2e_suite.go @@ -169,7 +169,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] }