Skip to content

Commit

Permalink
Use reflect.DeepEqual for CoreDNS config comparison
Browse files Browse the repository at this point in the history
Since k0s uses a PDB for CoreDNS, the simple double equals equality
check wasn't appropriate to check if the CoreDNS configuration has
changed. The struct now contains a pointer which is always different for
newly constructed structs.

This caused a useless manifest regeneration every ten seconds.

Fixes: c802ffd ("Add a PodDisruptionBudget for CoreDNS")
Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Jan 5, 2024
1 parent 016cda2 commit e003915
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/component/controller/coredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math"
"path"
"path/filepath"
"reflect"
"time"

"github.com/k0sproject/k0s/pkg/component/manager"
Expand Down Expand Up @@ -429,7 +430,7 @@ func (c *CoreDNS) Reconcile(ctx context.Context, clusterConfig *v1beta1.ClusterC
if err != nil {
return fmt.Errorf("error calculating coredns configs: %v. will retry", err)
}
if cfg == c.previousConfig {
if reflect.DeepEqual(c.previousConfig, cfg) {
c.log.Infof("current cfg matches existing, not gonna do anything")
return nil
}
Expand Down

0 comments on commit e003915

Please sign in to comment.