Skip to content

Commit a080ad2

Browse files
authored
[v0.19.x] *: fix run packagemanifests (#3894)
1 parent 1f9319d commit a080ad2

File tree

6 files changed

+51
-20
lines changed

6 files changed

+51
-20
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
entries:
2+
- description:
3+
Fixed a bug with `run packagemanifests` that caused the underlying
4+
registry pod to fail to start. Changed the registry pod image from
5+
`quay.io/openshift/origin-operator-registry:latest` to
6+
`quay.io/operator-framework/upstream-registry-builder:latest`
7+
8+
# kind is one of:
9+
# - addition
10+
# - change
11+
# - deprecation
12+
# - removal
13+
# - bugfix
14+
kind: bugfix
15+
16+
# Is this a breaking change?
17+
breaking: false
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
entries:
2+
- description: >
3+
Fix an issue in `run packagemanifests` where the registry server
4+
writes files in locations that require root.
5+
kind: bugfix

hack/tests/integration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ popd
1616
# Install OLM on the cluster if not installed.
1717
olm_latest_exists=0
1818
if ! operator-sdk olm status > /dev/null 2>&1; then
19-
operator-sdk olm install
19+
operator-sdk olm install --version=0.15.1
2020
olm_latest_exists=1
2121
fi
2222

@@ -26,7 +26,7 @@ go test -v ./test/integration
2626

2727
# Uninstall OLM if it was installed for test purposes.
2828
if eval "(( $olm_latest_exists ))"; then
29-
operator-sdk olm uninstall
29+
operator-sdk olm uninstall --version=0.15.1
3030
fi
3131

3232
echo -e "\n=== Integration tests succeeded ===\n"

internal/olm/client/client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,15 @@ func (c Client) DoCSVWait(ctx context.Context, key types.NamespacedName) error {
211211
curPhase = newPhase
212212
log.Printf(" Found ClusterServiceVersion %q phase: %s", key, curPhase)
213213
}
214-
return curPhase == olmapiv1alpha1.CSVPhaseSucceeded, nil
214+
215+
switch curPhase {
216+
case olmapiv1alpha1.CSVPhaseFailed:
217+
return false, fmt.Errorf("csv failed: reason: %q, message: %q", csv.Status.Reason, csv.Status.Message)
218+
case olmapiv1alpha1.CSVPhaseSucceeded:
219+
return true, nil
220+
default:
221+
return false, nil
222+
}
215223
}
216224

217225
return wait.PollImmediateUntil(time.Second, csvPhaseSucceeded, ctx.Done())

internal/olm/operator/internal/deployment.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@ package olm
1717
import (
1818
"fmt"
1919

20-
"github.com/operator-framework/operator-sdk/internal/util/k8sutil"
21-
2220
appsv1 "k8s.io/api/apps/v1"
2321
corev1 "k8s.io/api/core/v1"
2422
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
24+
"github.com/operator-framework/operator-sdk/internal/util/k8sutil"
2525
)
2626

2727
const (
2828
// The image operator-registry's initializer and registry-server binaries
2929
// are run from.
3030
// QUESTION(estroz): version registry image?
31-
registryBaseImage = "quay.io/openshift/origin-operator-registry:latest"
31+
registryBaseImage = "quay.io/operator-framework/upstream-registry-builder:latest"
3232
// The port registry-server will listen on within a container.
3333
registryGRPCPort = 50051
34-
// Path of the bundle database generated by initializer.
35-
regisryDBName = "bundle.db"
36-
// Path of the log file generated by registry-server.
37-
// TODO(estroz): have this log file in an obvious place, ex. /var/log.
38-
registryLogFile = "termination.log"
34+
// Path of the bundle database generated by initializer. Use /tmp since it is
35+
// typically world-writable.
36+
registryDBName = "/tmp/bundle.db"
37+
// Path of the log file generated by registry-server. Use /tmp since it is
38+
// typically world-writable.
39+
registryLogFile = "/tmp/termination.log"
3940
)
4041

4142
func getRegistryServerName(pkgName string) string {
@@ -99,13 +100,12 @@ func withContainerVolumeMounts(volName string, paths ...string) func(*appsv1.Dep
99100
}
100101

101102
// getDBContainerCmd returns a command string that, when run, does two things:
102-
// 1. Runs a database initializer on the manifests in the current working
103+
// 1. Runs a database initializer on the manifests in the /registry
103104
// directory.
104105
// 2. Runs an operator-registry server serving the bundle database.
105-
// The database must be in the current working directory.
106106
func getDBContainerCmd(dbPath, logPath string) string {
107-
initCmd := fmt.Sprintf("/usr/bin/initializer -o %s", dbPath)
108-
srvCmd := fmt.Sprintf("/usr/bin/registry-server -d %s -t %s", dbPath, logPath)
107+
initCmd := fmt.Sprintf("/bin/initializer -o %s -m %s", dbPath, containerManifestsDir)
108+
srvCmd := fmt.Sprintf("/bin/registry-server -d %s -t %s", dbPath, logPath)
109109
return fmt.Sprintf("%s && %s", initCmd, srvCmd)
110110
}
111111

@@ -114,13 +114,14 @@ func getDBContainerCmd(dbPath, logPath string) string {
114114
// pod template spec.
115115
func withRegistryGRPCContainer(pkgName string) func(*appsv1.Deployment) {
116116
container := corev1.Container{
117-
Name: getRegistryServerName(pkgName),
118-
Image: registryBaseImage,
119-
Command: []string{"/bin/bash"},
117+
Name: getRegistryServerName(pkgName),
118+
Image: registryBaseImage,
119+
WorkingDir: "/tmp",
120+
Command: []string{"/bin/sh"},
120121
Args: []string{
121122
"-c",
122123
// TODO(estroz): grab logs and print if error
123-
getDBContainerCmd(regisryDBName, registryLogFile),
124+
getDBContainerCmd(registryDBName, registryLogFile),
124125
},
125126
Ports: []corev1.ContainerPort{
126127
{Name: "registry-grpc", ContainerPort: registryGRPCPort},

test/e2e-new/e2e_suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ var _ = Describe("operator-sdk", func() {
169169
By("building the operator bundle image")
170170
// Use the existing image tag but with a "-bundle" suffix.
171171
imageSplit := strings.SplitN(tc.ImageName, ":", 2)
172-
bundleImage := path.Join("quay.io", imageSplit[0]+"-bundle")
172+
bundleImage := imageSplit[0] + "-bundle"
173173
if len(imageSplit) == 2 {
174174
bundleImage += ":" + imageSplit[1]
175175
}

0 commit comments

Comments
 (0)