Skip to content

Commit cce4a36

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 fd7b441 commit cce4a36

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
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
@@ -1617,7 +1617,11 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
16171617
}
16181618

16191619
if strategyErr != nil {
1620-
csv.SetPhaseWithEventIfChanged(requeuePhase, requeueConditionReason, fmt.Sprintf("installing: %s", strategyErr), now, a.recorder)
1620+
if install.ReasonForError(strategyErr) == install.StrategyErrDeploymentUpdated {
1621+
csv.SetPhaseWithEventIfChanged(v1alpha1.CSVPhaseInstallReady, requeueConditionReason, fmt.Sprintf("installing: %s", strategyErr), now, a.recorder)
1622+
} else {
1623+
csv.SetPhaseWithEventIfChanged(requeuePhase, requeueConditionReason, fmt.Sprintf("installing: %s", strategyErr), now, a.recorder)
1624+
}
16211625
if err := a.csvQueueSet.Requeue(csv.GetNamespace(), csv.GetName()); err != nil {
16221626
a.logger.Warn(err.Error())
16231627
}

pkg/controller/operators/olm/operator_test.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"crypto/x509"
99
"crypto/x509/pkix"
1010
"fmt"
11-
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/queueinformer"
1211
"math"
1312
"math/big"
1413
"reflect"
@@ -60,6 +59,7 @@ import (
6059
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
6160
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
6261
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
62+
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/queueinformer"
6363
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/scoped"
6464
)
6565

@@ -258,7 +258,7 @@ func NewFakeOperator(ctx context.Context, options ...fakeOperatorOption) (*Opera
258258
// Apply options to default config
259259
config := &fakeOperatorConfig{
260260
operatorConfig: &operatorConfig{
261-
resyncPeriod: queueinformer.ResyncWithJitter(5 * time.Minute, 0.1),
261+
resyncPeriod: queueinformer.ResyncWithJitter(5*time.Minute, 0.1),
262262
operatorNamespace: "default",
263263
watchedNamespaces: []string{metav1.NamespaceAll},
264264
clock: &utilclock.RealClock{},
@@ -2243,6 +2243,35 @@ func TestTransitionCSV(t *testing.T) {
22432243
},
22442244
},
22452245
},
2246+
{
2247+
name: "SingleCSVInstallingToInstallReady",
2248+
initial: initial{
2249+
csvs: []runtime.Object{
2250+
csvWithAnnotations(csv("csv1",
2251+
namespace,
2252+
"0.0.0",
2253+
"",
2254+
installStrategy("csv1-dep1", nil, nil),
2255+
[]*v1beta1.CustomResourceDefinition{},
2256+
[]*v1beta1.CustomResourceDefinition{},
2257+
v1alpha1.CSVPhaseInstalling,
2258+
), defaultTemplateAnnotations),
2259+
},
2260+
clientObjs: []runtime.Object{defaultOperatorGroup},
2261+
crds: []runtime.Object{},
2262+
objs: []runtime.Object{
2263+
withLabels(
2264+
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2265+
map[string]string{install.DeploymentSpecHashLabelKey: "BadHash"},
2266+
),
2267+
},
2268+
},
2269+
expected: expected{
2270+
csvStates: map[string]csvState{
2271+
"csv1": {exists: true, phase: v1alpha1.CSVPhaseInstallReady, reason: "InstallWaiting"},
2272+
},
2273+
},
2274+
},
22462275
{
22472276
name: "SingleCSVSucceededToSucceeded/UnmanagedDeploymentInNamespace",
22482277
initial: initial{

test/e2e/subscription_e2e_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,10 +1353,6 @@ func TestCreateNewSubscriptionWithPodConfig(t *testing.T) {
13531353
require.NotNil(t, subscription)
13541354

13551355
csv, err := fetchCSV(t, crClient, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
1356-
if err != nil {
1357-
// 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.
1358-
csv, err = fetchCSV(t, crClient, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
1359-
}
13601356
require.NoError(t, err)
13611357

13621358
proxyEnv := proxyEnvVarFunc(t, config)

0 commit comments

Comments
 (0)