Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion resourcecontexts/resource_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"k8s.io/utils/ptr"
clientutil "kusionstack.io/kube-utils/client"
"kusionstack.io/kube-utils/controller/expectations"
"kusionstack.io/kube-utils/controller/mixin"
Expand Down Expand Up @@ -160,7 +161,7 @@ func (r *RealResourceContextControl) CleanUnusedIDs(ctx context.Context, xsetObj
ownedIDs[detail.ID] = detail
}
}
needCleanCount = len(ownedIDs) - maxInt(int(*xsetSpec.Replicas), len(objs))
needCleanCount = len(ownedIDs) - maxInt(int(ptr.Deref(xsetSpec.Replicas, 0)), len(objs))

if needCleanCount <= 0 {
return nil
Expand Down
2 changes: 1 addition & 1 deletion synccontrols/sync_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (r *RealSyncControl) SyncTargets(ctx context.Context, instance api.XSetObje
syncContext.OwnedIds = ownedIDs
return err
}); err != nil {
return false, fmt.Errorf("fail to allocate %d IDs using context when sync Targets: %w", xspec.Replicas, err)
return false, fmt.Errorf("fail to allocate %d IDs using context when sync Targets: %w", ptr.Deref(xspec.Replicas, 0), err)
}

// stateless case
Expand Down
Loading