Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.19.x] *: fix run packagemanifests #3894

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
17 changes: 17 additions & 0 deletions changelog/fragments/fix-run-packagemanifests-e2e.yaml
Original file line number Diff line number Diff line change
@@ -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
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
4 changes: 2 additions & 2 deletions hack/tests/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
10 changes: 9 additions & 1 deletion internal/olm/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
33 changes: 17 additions & 16 deletions internal/olm/operator/internal/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand All @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-new/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down