Skip to content

Commit

Permalink
Fix: #4865 (#4867)
Browse files Browse the repository at this point in the history
Signed-off-by: Somefive <yd219913@alibaba-inc.com>

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
  • Loading branch information
Somefive committed Oct 15, 2022
1 parent c15d0e4 commit 18d755e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 9 additions & 4 deletions pkg/controller/core.oam.dev/v1alpha2/application/revision.go
Expand Up @@ -24,7 +24,6 @@ import (
"strings"

"github.com/hashicorp/go-version"
"github.com/kubevela/pkg/util/k8s"
"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -531,8 +530,11 @@ func deepEqualAppSpec(old, new *v1beta1.Application) bool {
// legacy code: KubeVela version before v1.5.7 & v1.6.0-alpha.4 does not
// record workflow in application spec in application revision. The comparison
// need to bypass the equality check of workflow to prevent unintended rerun
curVerNum := k8s.GetAnnotation(old, oam.AnnotationKubeVelaVersion)
publishVersion := k8s.GetAnnotation(old, oam.AnnotationPublishVersion)
var curVerNum, publishVersion string
if annotations := old.GetAnnotations(); annotations != nil {
curVerNum = annotations[oam.AnnotationKubeVelaVersion]
publishVersion = annotations[oam.AnnotationPublishVersion]
}
if publishVersion == "" && curVerNum != "" {
cmpVer, _ := version.NewVersion(velaVersionNumberToCompareWorkflow)
if curVer, err := version.NewVersion(curVerNum); err == nil && curVer.LessThan(cmpVer) {
Expand Down Expand Up @@ -560,7 +562,10 @@ func deepEqualAppInRevision(old, new *v1beta1.ApplicationRevision) bool {
return false
}
}
return deepEqualAppSpec(&old.Spec.Application, &new.Spec.Application)
oldApp, newApp := old.Spec.Application.DeepCopy(), new.Spec.Application.DeepCopy()
oldApp.Spec = filterSkipAffectAppRevTrait(oldApp.Spec, old.Spec.TraitDefinitions)
newApp.Spec = filterSkipAffectAppRevTrait(newApp.Spec, new.Spec.TraitDefinitions)
return deepEqualAppSpec(oldApp, newApp)
}

// HandleComponentsRevision manages Component revisions
Expand Down
Expand Up @@ -25,7 +25,6 @@ import (
"testing"
"time"

workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1179,11 +1178,9 @@ func TestDeepEqualAppInRevision(t *testing.T) {
oldRev := &v1beta1.ApplicationRevision{}
newRev := &v1beta1.ApplicationRevision{}
newRev.Spec.Application.Spec.Workflow = &v1beta1.Workflow{
Steps: []workflowv1alpha1.WorkflowStep{{
WorkflowStepBase: workflowv1alpha1.WorkflowStepBase{
Type: "deploy",
Name: "deploy",
},
Steps: []v1beta1.WorkflowStep{{
Type: "deploy",
Name: "deploy",
}},
}
require.False(t, deepEqualAppInRevision(oldRev, newRev))
Expand Down

0 comments on commit 18d755e

Please sign in to comment.