fix: return finalizer readiness errors

Signed-off-by: immanuwell <pchpr.00@list.ru>
This commit is contained in:
immanuwell
2026-07-01 15:14:25 +04:00
parent d626c09d2f
commit 2663b97180
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -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)
+29
View File
@@ -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")
}