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

Check for updates for helm operator #1276

Merged
merged 3 commits into from
Aug 14, 2018
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
14 changes: 8 additions & 6 deletions cmd/fluxd/checkpoint.go → checkpoint/checkpoint.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package checkpoint

import (
"time"
Expand All @@ -11,7 +11,7 @@ const (
versionCheckPeriod = 6 * time.Hour
)

func checkForUpdates(clusterString string, gitString string, logger log.Logger) *checkpoint.Checker {
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)
Expand All @@ -25,12 +25,14 @@ func checkForUpdates(clusterString string, gitString string, logger log.Logger)
}

flags := map[string]string{
"kernel-version": getKernelVersion(),
"cluster-version": clusterString,
"git-configured": gitString,
"kernel-version": getKernelVersion(),
}
for k, v := range extra {
flags[k] = v
}

params := checkpoint.CheckParams{
Product: "weave-flux",
Product: product,
Version: version,
SignatureFile: "",
Flags: flags,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package checkpoint

import (
"syscall"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package checkpoint

import (
"syscall"
Expand Down
11 changes: 9 additions & 2 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
k8sclient "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/weaveworks/flux/checkpoint"
"github.com/weaveworks/flux/cluster"
"github.com/weaveworks/flux/cluster/kubernetes"
"github.com/weaveworks/flux/daemon"
Expand All @@ -41,6 +42,8 @@ import (
var version = "unversioned"

const (
product = "weave-flux"

// The number of connections chosen for memcache and remote GETs should match for best performance (hence the single hardcoded value)
// Value chosen through performance tests on sock-shop. I was unable to get higher performance than this.
defaultRemoteConnections = 125 // Chosen performance tests on sock-shop. Unable to get higher performance than this.
Expand Down Expand Up @@ -105,7 +108,7 @@ func main() {
k8sSecretName = fs.String("k8s-secret-name", "flux-git-deploy", "Name of the k8s secret used to store the private SSH key")
k8sSecretVolumeMountPath = fs.String("k8s-secret-volume-mount-path", "/etc/fluxd/ssh", "Mount location of the k8s secret storing the private SSH key")
k8sSecretDataKey = fs.String("k8s-secret-data-key", "identity", "Data key holding the private SSH key within the k8s secret")
k8sNamespaceWhitelist = fs.StringSlice("k8s-namespace-whitelist", []string{}, "Experimental, optional: restrict the view of the cluster to the namespaces listed. All namespaces are included if this is not set.")
k8sNamespaceWhitelist = fs.StringSlice("k8s-namespace-whitelist", []string{}, "Experimental, optional: restrict the view of the cluster to the namespaces listed. All namespaces are included if this is not set.")
// SSH key generation
sshKeyBits = optionalVar(fs, &ssh.KeyBitsValue{}, "ssh-keygen-bits", "-b argument to ssh-keygen (default unspecified)")
sshKeyType = optionalVar(fs, &ssh.KeyTypeValue{}, "ssh-keygen-type", "-t argument to ssh-keygen (default unspecified)")
Expand Down Expand Up @@ -342,7 +345,11 @@ func main() {
// report anything before seeing if it works. So, don't start
// until we have failed or succeeded.
updateCheckLogger := log.With(logger, "component", "checkpoint")
checkForUpdates(clusterVersion, strconv.FormatBool(*gitURL != ""), updateCheckLogger)
checkpointFlags := map[string]string{
"cluster-version": clusterVersion,
"git-configured": strconv.FormatBool(*gitURL != ""),
}
checkpoint.CheckForUpdates(product, version, checkpointFlags, updateCheckLogger)

gitRemote := git.Remote{URL: *gitURL}
gitConfig := git.Config{
Expand Down
15 changes: 15 additions & 0 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

"github.com/weaveworks/flux/checkpoint"
"github.com/weaveworks/flux/git"
clientset "github.com/weaveworks/flux/integrations/client/clientset/versioned"
ifinformers "github.com/weaveworks/flux/integrations/client/informers/externalversions"
Expand All @@ -31,6 +32,8 @@ var (
logger log.Logger
kubectl string

versionFlag *bool

kubeconfig *string
master *string

Expand Down Expand Up @@ -60,11 +63,14 @@ var (
)

const (
product = "weave-flux-helm"
defaultGitChartsPath = "charts"

ErrOperatorFailure = "Operator failure: %q"
)

var version = "unversioned"

func init() {
// Flags processing
fs = pflag.NewFlagSet("default", pflag.ExitOnError)
Expand All @@ -76,6 +82,8 @@ func init() {
fs.PrintDefaults()
}

versionFlag = fs.Bool("version", false, "Print version and exit")

kubeconfig = fs.String("kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
master = fs.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")

Expand Down Expand Up @@ -104,6 +112,11 @@ func main() {

fs.Parse(os.Args)

if *versionFlag {
println(version)
os.Exit(0)
}

// LOGGING ------------------------------------------------------------------------------
{
logger = log.NewLogfmtLogger(os.Stderr)
Expand Down Expand Up @@ -222,6 +235,8 @@ func main() {
// Starts handling k8s events related to the given resource kind
go ifInformerFactory.Start(shutdown)

checkpoint.CheckForUpdates(product, version, nil, log.With(logger, "component", "checkpoint"))

if err = opr.Run(*queueWorkerCount, shutdown, shutdownWg); err != nil {
msg := fmt.Sprintf("Failure to run controller: %s", err.Error())
logger.Log("error", msg)
Expand Down