Skip to content

Commit d9d9b49

Browse files
committed
Pod Config Deployment Hash Error
The Pod Config e2e test have been failing because the deployment is not reinstalled when the actual deployment hash does not match the calculated deployment hash. This commit updates OLM to reinstall a deployment when the hash doesn't match the calculated hash.
1 parent 9f126de commit d9d9b49

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

pkg/controller/install/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func IsErrorUnrecoverable(err error) bool {
3838
if err == nil {
3939
return false
4040
}
41-
_, ok := unrecoverableErrors[reasonForError(err)]
41+
_, ok := unrecoverableErrors[ReasonForError(err)]
4242
return ok
4343
}
4444

45-
func reasonForError(err error) string {
45+
func ReasonForError(err error) string {
4646
switch t := err.(type) {
4747
case StrategyError:
4848
return t.Reason

pkg/controller/operators/olm/operator.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,11 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
16851685
}
16861686

16871687
if strategyErr != nil {
1688-
csv.SetPhaseWithEventIfChanged(requeuePhase, requeueConditionReason, fmt.Sprintf("installing: %s", strategyErr), now, a.recorder)
1688+
if install.ReasonForError(strategyErr) == install.StrategyErrDeploymentUpdated {
1689+
csv.SetPhaseWithEventIfChanged(v1alpha1.CSVPhaseInstallReady, requeueConditionReason, fmt.Sprintf("installing: %s", strategyErr), now, a.recorder)
1690+
} else {
1691+
csv.SetPhaseWithEventIfChanged(requeuePhase, requeueConditionReason, fmt.Sprintf("installing: %s", strategyErr), now, a.recorder)
1692+
}
16891693
if err := a.csvQueueSet.Requeue(csv.GetNamespace(), csv.GetName()); err != nil {
16901694
a.logger.Warn(err.Error())
16911695
}

pkg/controller/operators/olm/operator_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,35 @@ func TestTransitionCSV(t *testing.T) {
22442244
},
22452245
},
22462246
},
2247+
{
2248+
name: "SingleCSVInstallingToInstallReady",
2249+
initial: initial{
2250+
csvs: []runtime.Object{
2251+
csvWithAnnotations(csv("csv1",
2252+
namespace,
2253+
"0.0.0",
2254+
"",
2255+
installStrategy("csv1-dep1", nil, nil),
2256+
[]*apiextensionsv1.CustomResourceDefinition{},
2257+
[]*apiextensionsv1.CustomResourceDefinition{},
2258+
v1alpha1.CSVPhaseInstalling,
2259+
), defaultTemplateAnnotations),
2260+
},
2261+
clientObjs: []runtime.Object{defaultOperatorGroup},
2262+
crds: []runtime.Object{},
2263+
objs: []runtime.Object{
2264+
withLabels(
2265+
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2266+
map[string]string{install.DeploymentSpecHashLabelKey: "BadHash"},
2267+
),
2268+
},
2269+
},
2270+
expected: expected{
2271+
csvStates: map[string]csvState{
2272+
"csv1": {exists: true, phase: v1alpha1.CSVPhaseInstallReady, reason: "InstallWaiting"},
2273+
},
2274+
},
2275+
},
22472276
{
22482277
name: "SingleCSVSucceededToSucceeded/UnmanagedDeploymentInNamespace",
22492278
initial: initial{

test/e2e/subscription_e2e_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import (
2525
"k8s.io/apimachinery/pkg/util/wait"
2626
"k8s.io/client-go/discovery"
2727

28+
"github.com/operator-framework/api/pkg/lib/version"
2829
"github.com/operator-framework/api/pkg/operators/v1alpha1"
2930
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
3031
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
3132
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
3233
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver"
3334
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison"
3435
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
35-
"github.com/operator-framework/api/pkg/lib/version"
3636
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
3737
)
3838

@@ -1212,10 +1212,6 @@ var _ = Describe("Subscription", func() {
12121212
require.NotNil(GinkgoT(), subscription)
12131213

12141214
csv, err := fetchCSV(GinkgoT(), crClient, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
1215-
if err != nil {
1216-
// TODO: If OLM doesn't have the subscription in its cache when it initially creates the deployment, the CSV will hang on "Installing" until it reaches the five-minute timeout, then succeed on a retry. It should be possible to skip the wait and retry immediately, but in the meantime, giving this test a little extra patience should mitigate flakes.
1217-
csv, err = fetchCSV(GinkgoT(), crClient, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
1218-
}
12191215
require.NoError(GinkgoT(), err)
12201216

12211217
proxyEnv := proxyEnvVarFunc(GinkgoT(), config)

0 commit comments

Comments
 (0)