diff --git a/changelog/fragments/run-pkgmnfs-writable-dir.yaml b/changelog/fragments/run-pkgmnfs-writable-dir.yaml new file mode 100644 index 0000000000..7dbae3a846 --- /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/internal/olm/operator/registry/configmap/deployment.go b/internal/olm/operator/registry/configmap/deployment.go index 70a0e4cfe6..067169a98f 100644 --- a/internal/olm/operator/registry/configmap/deployment.go +++ b/internal/olm/operator/registry/configmap/deployment.go @@ -31,11 +31,12 @@ const ( 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 { @@ -102,12 +103,10 @@ func withContainerVolumeMounts(volName string, paths ...string) func(*appsv1.Dep // 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 /registry directory. func getDBContainerCmd(dbPath, logPath string) string { - cdCmd := "cd /registry" - initCmd := fmt.Sprintf("/bin/initializer -o %s", dbPath) + 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 && %s", cdCmd, initCmd, srvCmd) + return fmt.Sprintf("%s && %s", initCmd, srvCmd) } // withRegistryGRPCContainer returns a function that appends a container @@ -115,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/sh"}, + 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},