Skip to content

Commit

Permalink
Merge pull request #657 from rancher/fix-sync-loop
Browse files Browse the repository at this point in the history
Fix node sync loop
  • Loading branch information
alexandreLamarre authored Oct 13, 2022
2 parents 2587292 + 26153c4 commit fd27a0a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion plugins/logging/pkg/agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func (l *LoggingNode) doSync(ctx context.Context) {
case node.ConfigStatus_NeedsUpdate:
l.logger.Info("updating logging node config")
l.updateConfig(syncResp.UpdatedConfig)
go l.doSync(ctx)
}

l.conditions.Clear(CondConfigSync)
Expand Down
5 changes: 3 additions & 2 deletions plugins/logging/pkg/backend/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"

"github.com/google/go-cmp/cmp"
capabilityv1 "github.com/rancher/opni/pkg/apis/capability/v1"
opnicorev1 "github.com/rancher/opni/pkg/apis/core/v1"
"github.com/rancher/opni/pkg/auth/cluster"
Expand All @@ -15,7 +16,7 @@ import (
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
)

func (b *LoggingBackend) Status(ctx context.Context, req *capabilityv1.StatusRequest) (*capabilityv1.NodeCapabilityStatus, error) {
Expand Down Expand Up @@ -94,7 +95,7 @@ func (b *LoggingBackend) Sync(ctx context.Context, req *node.SyncRequest) (*node
}

func (b *LoggingBackend) buildResponse(old, new *node.LoggingCapabilityConfig) *node.SyncResponse {
if proto.Equal(old, new) {
if cmp.Equal(old, new, protocmp.Transform()) {
return &node.SyncResponse{
ConfigStatus: node.ConfigStatus_UpToDate,
}
Expand Down
1 change: 0 additions & 1 deletion plugins/metrics/pkg/agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func (m *MetricsNode) doSync(ctx context.Context) {
case node.ConfigStatus_NeedsUpdate:
m.logger.Info("updating metrics node config")
m.updateConfig(syncResp.UpdatedConfig)
go m.doSync(ctx)
}

m.conditions.Clear(CondConfigSync)
Expand Down
5 changes: 3 additions & 2 deletions plugins/metrics/pkg/backend/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/google/go-cmp/cmp"
capabilityv1 "github.com/rancher/opni/pkg/apis/capability/v1"
corev1 "github.com/rancher/opni/pkg/apis/core/v1"
managementv1 "github.com/rancher/opni/pkg/apis/management/v1"
Expand Down Expand Up @@ -349,7 +350,7 @@ func (m *MetricsBackend) Sync(ctx context.Context, req *node.SyncRequest) (*node

// the calling function must have exclusive ownership of both old and new
func buildResponse(old, new *node.MetricsCapabilityConfig) *node.SyncResponse {
if proto.Equal(old, new) {
if cmp.Equal(old, new, protocmp.Transform()) {
return &node.SyncResponse{
ConfigStatus: node.ConfigStatus_UpToDate,
}
Expand Down

0 comments on commit fd27a0a

Please sign in to comment.