Skip to content
Merged
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
5 changes: 5 additions & 0 deletions changelog/fragments/run-pkgmnfs-writable-dir.yaml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 13 additions & 13 deletions internal/olm/operator/registry/configmap/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -102,26 +103,25 @@ 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
// running an operator-registry GRPC server to the Deployment argument's
// 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},
Expand Down