Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 committer: fix equality check in statusless committer #2602

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/reconciler/committer/statusless_committer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ limitations under the License.
package committer

import (
"bytes"
"context"
"encoding/json"
"fmt"

jsonpatch "github.com/evanphx/json-patch"
"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -100,6 +100,10 @@ func NewStatuslessCommitterScoped[R StatuslessResource](patcher Patcher[R], shal
}

func generateStatusLessPatchAndSubResources[R StatuslessResource](shallowCopy ObjectMetaShallowCopy[R], old, obj R) ([]byte, error) {
if equality.Semantic.DeepEqual(old, obj) {
return nil, nil
}

clusterName := logicalcluster.From(old)
name := old.GetName()

Expand All @@ -123,10 +127,6 @@ func generateStatusLessPatchAndSubResources[R StatuslessResource](shallowCopy Ob
return nil, fmt.Errorf("failed to Marshal new data for %s|%s: %w", clusterName, name, err)
}

if bytes.Equal(oldData, newData) {
return nil, nil
}

patchBytes, err := jsonpatch.CreateMergePatch(oldData, newData)
if err != nil {
return nil, fmt.Errorf("failed to create patch for %s|%s: %w", clusterName, name, err)
Expand Down