mirror of
https://github.com/fluxcd/flagger.git
synced 2026-09-05 02:47:17 +00:00
fix: return finalizer readiness errors
Signed-off-by: immanuwell <pchpr.00@list.ru>
This commit is contained in:
@@ -80,7 +80,7 @@ func (c *Controller) finalize(old interface{}) error {
|
||||
Cap: canary.GetAnalysisInterval(),
|
||||
Steps: 4,
|
||||
}
|
||||
retry.OnError(backoff, func(err error) bool {
|
||||
err = retry.OnError(backoff, func(err error) bool {
|
||||
return err.Error() == "retriable error"
|
||||
}, func() error {
|
||||
retriable, err := canaryController.IsCanaryReady(canary)
|
||||
|
||||
@@ -17,10 +17,13 @@ limitations under the License.
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
k8sTesting "k8s.io/client-go/testing"
|
||||
|
||||
@@ -104,3 +107,29 @@ func TestFinalizer_removeFinalizer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalizer_finalizeReturnsReadinessError(t *testing.T) {
|
||||
mocks := newDeploymentFixture(nil)
|
||||
mocks.canary.Spec.Provider = flaggerv1.KubernetesProvider
|
||||
|
||||
dep, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo", metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
dep.Status = appsv1.DeploymentStatus{
|
||||
ObservedGeneration: dep.Generation,
|
||||
Conditions: []appsv1.DeploymentCondition{
|
||||
{
|
||||
Type: appsv1.DeploymentProgressing,
|
||||
Status: "False",
|
||||
Reason: "ProgressDeadlineExceeded",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep, metav1.UpdateOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = mocks.ctrl.finalize(mocks.canary)
|
||||
require.Error(t, err)
|
||||
require.ErrorContains(t, err, "canary not ready during finalizing")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user