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

Remove telemetry sending #687

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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: 0 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ Portions of this software are licensed as follows:
* All content residing under the "docs/" directory of this repository is licensed under "Creative Commons Attribution Share Alike 4.0 International" (CC-BY-SA-4.0). See docs/LICENCE for details.
* Content outside of the above mentioned directories or restrictions above is available under the "Apache License 2.0" as defined below.

The k0sctl binary will send anonymous telemetry when used.


Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,6 @@ k0sctl completion > /usr/local/share/zsh/site-functions/_k0sctl
k0sctl completion > ~/.config/fish/completions/k0sctl.fish
```

## Anonymous telemetry

K0sctl sends anonymized telemetry data when it is used. This can be disabled via the `--disable-telemetry` flag or by setting the environment variable `DISABLE_TELEMETRY=true`.

The telemetry data includes:

- K0sctl version
- Operating system + CPU architecture ("linux x86", "darwin arm64", ...)
- An anonymous machine ID generated by [denisbrodbeck/machineid](https://github.com/denisbrodbeck/machineid) or if that fails, an md5 sum of the hostname
- Event information:
* Phase name ("Connecting to hosts", "Gathering facts", ...) and the duration how long it took to finish
* Cluster UUID (`kubectl get -n kube-system namespace kube-system -o template={{.metadata.uid}}`)
* Was k0s dynamic config enabled (true/false)
* Was a custom or the default k0s configuration used (true/false)
* In case of a crash, a backtrace with source filenames and line numbers only

The data is used to estimate the number of users and to identify failure hotspots.

## Development status

K0sctl is ready for use and in continuous development. It is still at a stage where maintaining backwards compatibility is not a high priority goal.
Expand Down
5 changes: 0 additions & 5 deletions action/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"time"

"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/phase"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -83,17 +82,13 @@ func (a Apply) Run() error {
&phase.Disconnect{},
)

analytics.Client.Publish("apply-start", map[string]interface{}{})

var result error

if result = a.Manager.Run(); result != nil {
analytics.Client.Publish("apply-failure", map[string]interface{}{"clusterID": a.Manager.Config.Spec.K0s.Metadata.ClusterID})
log.Info(phase.Colorize.Red("==> Apply failed").String())
return result
}

analytics.Client.Publish("apply-success", map[string]interface{}{"duration": time.Since(start), "clusterID": a.Manager.Config.Spec.K0s.Metadata.ClusterID})
if a.KubeconfigOut != nil {
if _, err := a.KubeconfigOut.Write([]byte(a.Manager.Config.Metadata.Kubeconfig)); err != nil {
log.Warnf("failed to write kubeconfig to %s: %v", a.KubeconfigOut, err)
Expand Down
6 changes: 0 additions & 6 deletions action/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"time"

"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/phase"
log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -33,15 +32,10 @@ func (b Backup) Run() error {
&phase.Disconnect{},
)

analytics.Client.Publish("backup-start", map[string]interface{}{})

if err := b.Manager.Run(); err != nil {
analytics.Client.Publish("backup-failure", map[string]interface{}{"clusterID": b.Manager.Config.Spec.K0s.Metadata.ClusterID})
return err
}

analytics.Client.Publish("backup-success", map[string]interface{}{"duration": time.Since(start), "clusterID": b.Manager.Config.Spec.K0s.Metadata.ClusterID})

duration := time.Since(start).Truncate(time.Second)
text := fmt.Sprintf("==> Finished in %s", duration)
log.Infof(phase.Colorize.Green(text).String())
Expand Down
3 changes: 0 additions & 3 deletions action/config_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"os"

"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
"github.com/k0sproject/rig/exec"

Expand All @@ -28,8 +27,6 @@ func (c ConfigEdit) Run() error {
return fmt.Errorf("output is not a terminal")
}

analytics.Client.Publish("config-edit-start", map[string]interface{}{})

editor, err := shellEditor()
if err != nil {
return err
Expand Down
3 changes: 0 additions & 3 deletions action/config_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io"

"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
"github.com/k0sproject/rig/exec"
)
Expand All @@ -17,8 +16,6 @@ type ConfigStatus struct {
}

func (c ConfigStatus) Run() error {
analytics.Client.Publish("config-status-start", map[string]interface{}{})

h := c.Config.Spec.K0sLeader()

if err := h.Connect(); err != nil {
Expand Down
6 changes: 0 additions & 6 deletions action/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"time"

"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/phase"
log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -66,15 +65,10 @@ func (r Reset) Run() error {
&phase.Disconnect{},
)

analytics.Client.Publish("reset-start", map[string]interface{}{})

if err := r.Manager.Run(); err != nil {
analytics.Client.Publish("reset-failure", map[string]interface{}{"clusterID": r.Manager.Config.Spec.K0s.Metadata.ClusterID})
return err
}

analytics.Client.Publish("reset-success", map[string]interface{}{"duration": time.Since(start), "clusterID": r.Manager.Config.Spec.K0s.Metadata.ClusterID})

duration := time.Since(start).Truncate(time.Second)
text := fmt.Sprintf("==> Finished in %s", duration)
log.Infof(phase.Colorize.Green(text).String())
Expand Down
27 changes: 0 additions & 27 deletions analytics/analytics.go

This file was deleted.

28 changes: 0 additions & 28 deletions analytics/machineid.go

This file was deleted.

60 changes: 0 additions & 60 deletions analytics/phase.go

This file was deleted.

4 changes: 1 addition & 3 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ var applyCommand = &cli.Command{
redactFlag,
retryIntervalFlag,
retryTimeoutFlag,
analyticsFlag,
},
Before: actions(initLogging, initConfig, initManager, displayLogo, initAnalytics, displayCopyright, warnOldCache),
After: actions(closeAnalytics),
Before: actions(initLogging, initConfig, initManager, displayLogo, displayCopyright, warnOldCache),
Action: func(ctx *cli.Context) error {
var kubeconfigOut io.Writer

Expand Down
4 changes: 1 addition & 3 deletions cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ var backupCommand = &cli.Command{
redactFlag,
retryIntervalFlag,
retryTimeoutFlag,
analyticsFlag,
},
Before: actions(initLogging, initConfig, initManager, displayLogo, initAnalytics, displayCopyright),
After: actions(closeAnalytics),
Before: actions(initLogging, initConfig, initManager, displayLogo, displayCopyright),
Action: func(ctx *cli.Context) error {
backupAction := action.Backup{
Manager: ctx.Context.Value(ctxManagerKey{}).(*phase.Manager),
Expand Down
4 changes: 1 addition & 3 deletions cmd/config_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ var configEditCommand = &cli.Command{
debugFlag,
traceFlag,
redactFlag,
analyticsFlag,
},
Before: actions(initLogging, initConfig, initAnalytics),
After: actions(closeAnalytics),
Before: actions(initLogging, initConfig),
Action: func(ctx *cli.Context) error {
configEditAction := action.ConfigEdit{
Config: ctx.Context.Value(ctxConfigKey{}).(*v1beta1.Cluster),
Expand Down
4 changes: 1 addition & 3 deletions cmd/config_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ var configStatusCommand = &cli.Command{
debugFlag,
traceFlag,
redactFlag,
analyticsFlag,
&cli.StringFlag{
Name: "output",
Usage: "kubectl output formatting",
Aliases: []string{"o"},
},
},
Before: actions(initLogging, initConfig, initAnalytics),
After: actions(closeAnalytics),
Before: actions(initLogging, initConfig),
Action: func(ctx *cli.Context) error {
configStatusAction := action.ConfigStatus{
Config: ctx.Context.Value(ctxConfigKey{}).(*v1beta1.Cluster),
Expand Down
43 changes: 6 additions & 37 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

"github.com/a8m/envsubst"
"github.com/adrg/xdg"
"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/integration/segment"
"github.com/k0sproject/k0sctl/phase"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
"github.com/k0sproject/k0sctl/pkg/retry"
Expand All @@ -27,9 +25,11 @@ import (
"gopkg.in/yaml.v2"
)

type ctxConfigKey struct{}
type ctxManagerKey struct{}
type ctxLogFileKey struct{}
type (
ctxConfigKey struct{}
ctxManagerKey struct{}
ctxLogFileKey struct{}
)

var (
debugFlag = &cli.BoolFlag{
Expand Down Expand Up @@ -66,12 +66,6 @@ var (
TakesFile: true,
}

analyticsFlag = &cli.BoolFlag{
Name: "disable-telemetry",
Usage: "Do not send anonymous telemetry",
EnvVars: []string{"DISABLE_TELEMETRY"},
}

concurrencyFlag = &cli.IntFlag{
Name: "concurrency",
Usage: "Maximum number of hosts to configure in parallel, set to 0 for unlimited",
Expand Down Expand Up @@ -165,9 +159,6 @@ func initConfig(ctx *cli.Context) error {

func displayCopyright(ctx *cli.Context) error {
fmt.Printf("k0sctl %s Copyright 2023, k0sctl authors.\n", k0sctl.Version)
if !ctx.Bool("disable-telemetry") {
fmt.Println("Anonymized telemetry of usage will be sent to the authors.")
}
fmt.Println("By continuing to use k0sctl you agree to these terms:")
fmt.Println("https://k0sproject.io/licenses/eula")
return nil
Expand All @@ -190,28 +181,6 @@ func warnOldCache(_ *cli.Context) error {
return nil
}

const segmentWriteKey string = "oU2iC4shRUBfEboaO0FDuDIUk49Ime92"

func initAnalytics(ctx *cli.Context) error {
if ctx.Bool("disable-telemetry") {
log.Tracef("disabling telemetry")
return nil
}

client, err := segment.NewClient(segmentWriteKey)
if err != nil {
return err
}
analytics.Client = client

return nil
}

func closeAnalytics(_ *cli.Context) error {
analytics.Client.Close()
return nil
}

func initManager(ctx *cli.Context) error {
c, ok := ctx.Context.Value(ctxConfigKey{}).(*v1beta1.Cluster)
if c == nil || !ok {
Expand Down Expand Up @@ -288,7 +257,7 @@ func LogFile() (*os.File, error) {
}
}

logFile, err := os.OpenFile(fn, os.O_RDWR|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0600)
logFile, err := os.OpenFile(fn, os.O_RDWR|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0o600)
if err != nil {
return nil, fmt.Errorf("Failed to open log %s: %s", fn, err.Error())
}
Expand Down
Loading
Loading