Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Disable telemetry
Browse files Browse the repository at this point in the history
We are removing all of the telemetry code as it is not needed, and being
on by default it may be contrary to CNCF policies around telemetry.

* remove check function

With no telemetry, there's no need for these function implementations or
this syscall in this package anymore.

We need to preserve the cadence of checkpoint.go to avoid disturbing any
thing that would constitute a breaking change, but basically all of the
underlying behavior of check can go away, since every Flux v1 version is
out of date every time, we don't need any remote service or lookup to
tell if an update is needed. (It's always needed)

Users should follow the link to upgrade (eg. the migration guide)

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
  • Loading branch information
Kingdon Barrett committed Aug 26, 2022
1 parent f6a3aff commit 6d294c8
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 100 deletions.
6 changes: 3 additions & 3 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,10 @@ func main() {
// until we have failed or succeeded.
updateCheckLogger := log.With(logger, "component", "checkpoint")
checkpointFlags := map[string]string{
"cluster-version": clusterVersion,
"git-configured": strconv.FormatBool(*gitURL != ""),
"cluster-version": "XXXXX",
"git-configured": "XXXXX",
}
checkpoint.CheckForUpdates(product, version, checkpointFlags, updateCheckLogger)
checkpoint.CheckForUpdates(product, "XXXXX", checkpointFlags, updateCheckLogger)

gitRemote := git.Remote{URL: *gitURL}
gitConfig := git.Config{
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ require (
github.com/stretchr/testify v1.8.0
// Latest versions of github.com/weaveworks/common are not supporterd by Flux.
github.com/weaveworks/common v0.0.0-20190410110702-87611edc252e
github.com/weaveworks/go-checkpoint v0.0.0-20220223124739-fd9899e2b4f2
github.com/whilp/git-urls v1.0.0
github.com/xeipuuv/gojsonschema v1.2.0
go.mozilla.org/sops/v3 v3.7.3
Expand Down
53 changes: 38 additions & 15 deletions pkg/checkpoint/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,62 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/weaveworks/go-checkpoint"
)

const (
versionCheckPeriod = 6 * time.Hour
)

func CheckForUpdates(product, version string, extra map[string]string, logger log.Logger) *checkpoint.Checker {
handleResponse := func(r *checkpoint.CheckResponse, err error) {
if err != nil {
logger.Log("err", err)
return
}
if r.Outdated {
logger.Log("msg", "update available", "latest", r.CurrentVersion, "URL", r.CurrentDownloadURL)
return
}
logger.Log("msg", "up to date", "latest", r.CurrentVersion)
func CheckForUpdates(product, version string, extra map[string]string, logger log.Logger) *checker {
handleResponse := func() {
logger.Log("msg", "update available", "latest", "v0.33.0", "URL", "https://fluxcd.io/docs/migration/")
}

flags := map[string]string{
"kernel-version": getKernelVersion(),
"kernel-version": "XXXXX",
}
for k, v := range extra {
flags[k] = v
}

params := checkpoint.CheckParams{
params := checkParams{
Product: product,
Version: version,
SignatureFile: "",
Flags: flags,
}

return checkpoint.CheckInterval(&params, versionCheckPeriod, handleResponse)
return checkInterval(&params, versionCheckPeriod, handleResponse)
}

func checkInterval(p *checkParams, interval time.Duration,
cb func()) *checker {

state := &checker{
doneCh: make(chan struct{}),
}

if isCheckDisabled() {
return state
}

go func() {
cb()

for {
after := randomStagger(interval)
state.nextCheckAtLock.Lock()
state.nextCheckAt = time.Now().Add(after)
state.nextCheckAtLock.Unlock()

select {
case <-time.After(after):
cb()
case <-state.doneCh:
return
}
}
}()

return state
}
13 changes: 0 additions & 13 deletions pkg/checkpoint/checkpoint_darwin.go

This file was deleted.

23 changes: 0 additions & 23 deletions pkg/checkpoint/checkpoint_linux_amd64.go

This file was deleted.

23 changes: 0 additions & 23 deletions pkg/checkpoint/checkpoint_linux_arm.go

This file was deleted.

22 changes: 0 additions & 22 deletions pkg/checkpoint/checkpoint_linux_arm64.go

This file was deleted.

31 changes: 31 additions & 0 deletions pkg/checkpoint/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package checkpoint

import (
"sync"
"time"
)

type flag struct {
Key string
Value string
}

type checkParams struct {
Product string
Version string
Flags map[string]string
ExtraFlags func() []flag
Arch string
OS string
Signature string
SignatureFile string
CacheFile string
CacheDuration time.Duration
Force bool
}

type checker struct {
doneCh chan struct{}
nextCheckAt time.Time
nextCheckAtLock sync.RWMutex
}
16 changes: 16 additions & 0 deletions pkg/checkpoint/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package checkpoint

import (
mrand "math/rand"
"os"
"time"
)

func isCheckDisabled() bool {
return os.Getenv("CHECKPOINT_DISABLE") != ""
}

func randomStagger(interval time.Duration) time.Duration {
stagger := time.Duration(mrand.Int63()) % (interval / 2)
return 3*(interval/4) + stagger
}

0 comments on commit 6d294c8

Please sign in to comment.