Compare commits

...

5 Commits

Author SHA1 Message Date
Alexander Matyushentsev
f9f1bdaabe Update manifests to v1.5.0-rc2 2020-03-25 22:12:54 -07:00
Alexander Matyushentsev
e66b6109f7 fix: implement workaround for helm/helm#6870 bug (#3290)
* fix: implement workaround for  helm/helm#6870 bug

* Update app_management_test.go
2020-03-25 22:11:46 -07:00
Jesse Suen
53897e5019 improvement: remove app name and project labels from reconcliation histogram to reduce cardinality (#3271) 2020-03-25 12:42:23 -07:00
Alexander Matyushentsev
7e0d8a490c fix: increase max connections count to support clusters with very large number of CRDs (#3278) 2020-03-25 10:03:40 -07:00
Alexander Matyushentsev
3684a10332 Update manifests to v1.5.0-rc1 2020-03-20 13:48:19 -07:00
19 changed files with 159 additions and 62 deletions

View File

@@ -1 +1 @@
1.5.0
1.5.0-rc2

View File

@@ -20,6 +20,7 @@ import (
"github.com/argoproj/argo-cd/common"
"github.com/argoproj/argo-cd/controller"
"github.com/argoproj/argo-cd/errors"
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
"github.com/argoproj/argo-cd/reposerver/apiclient"
appstatecache "github.com/argoproj/argo-cd/util/cache/appstate"
@@ -59,8 +60,7 @@ func newCommand() *cobra.Command {
config, err := clientConfig.ClientConfig()
errors.CheckError(err)
config.QPS = common.K8sClientConfigQPS
config.Burst = common.K8sClientConfigBurst
errors.CheckError(v1alpha1.SetK8SConfigDefaults(config))
kubeClient := kubernetes.NewForConfigOrDie(config)
appClient := appclientset.NewForConfigOrDie(config)

View File

@@ -11,6 +11,7 @@ import (
"github.com/argoproj/argo-cd/common"
"github.com/argoproj/argo-cd/errors"
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
"github.com/argoproj/argo-cd/reposerver/apiclient"
"github.com/argoproj/argo-cd/server"
@@ -48,8 +49,7 @@ func NewCommand() *cobra.Command {
config, err := clientConfig.ClientConfig()
errors.CheckError(err)
config.QPS = common.K8sClientConfigQPS
config.Burst = common.K8sClientConfigBurst
errors.CheckError(v1alpha1.SetK8SConfigDefaults(config))
namespace, _, err := clientConfig.Namespace()
errors.CheckError(err)

View File

@@ -141,6 +141,8 @@ const (
EnvK8sClientQPS = "ARGOCD_K8S_CLIENT_QPS"
// EnvK8sClientBurst is the burst value used for the kubernetes client (default: twice the client QPS)
EnvK8sClientBurst = "ARGOCD_K8S_CLIENT_BURST"
// EnvK8sClientMaxIdleConnections is the number of max idle connections in K8s REST client HTTP transport (default: 500)
EnvK8sClientMaxIdleConnections = "ARGOCD_K8S_CLIENT_MAX_IDLE_CONNECTIONS"
)
const (
@@ -158,6 +160,8 @@ var (
K8sClientConfigQPS float32 = 50
// K8sClientConfigBurst controls the burst to be used in K8s REST client configs
K8sClientConfigBurst int = 100
// K8sMaxIdleConnections controls the number of max idle connections in K8s REST client HTTP transport
K8sMaxIdleConnections = 500
)
func init() {
@@ -173,4 +177,10 @@ func init() {
} else {
K8sClientConfigBurst = 2 * int(K8sClientConfigQPS)
}
if envMaxConn := os.Getenv(EnvK8sClientMaxIdleConnections); envMaxConn != "" {
if maxConn, err := strconv.Atoi(envMaxConn); err != nil {
K8sMaxIdleConnections = maxConn
}
}
}

View File

@@ -101,7 +101,7 @@ var (
// Buckets chosen after observing a ~2100ms mean reconcile time
Buckets: []float64{0.25, .5, 1, 2, 4, 8, 16},
},
append(descAppDefaultLabels, "dest_server"),
[]string{"namespace", "dest_server"},
)
clusterEventsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
@@ -191,7 +191,7 @@ func (m *MetricsServer) IncKubernetesRequest(app *argoappv1.Application, server,
// IncReconcile increments the reconcile counter for an application
func (m *MetricsServer) IncReconcile(app *argoappv1.Application, duration time.Duration) {
m.reconcileHistogram.WithLabelValues(app.Namespace, app.Name, app.Spec.GetProject(), app.Spec.Destination.Server).Observe(duration.Seconds())
m.reconcileHistogram.WithLabelValues(app.Namespace, app.Spec.Destination.Server).Observe(duration.Seconds())
}
type appCollector struct {

View File

@@ -260,16 +260,16 @@ func TestReconcileMetrics(t *testing.T) {
appReconcileMetrics := `
# HELP argocd_app_reconcile Application reconciliation performance.
# TYPE argocd_app_reconcile histogram
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="0.25"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="0.5"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="1"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="2"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="4"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="8"} 1
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="16"} 1
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project",le="+Inf"} 1
argocd_app_reconcile_sum{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project"} 5
argocd_app_reconcile_count{dest_server="https://localhost:6443",name="my-app",namespace="argocd",project="important-project"} 1
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="0.25"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="0.5"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="1"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="2"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="4"} 0
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="8"} 1
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="16"} 1
argocd_app_reconcile_bucket{dest_server="https://localhost:6443",namespace="argocd",le="+Inf"} 1
argocd_app_reconcile_sum{dest_server="https://localhost:6443",namespace="argocd"} 5
argocd_app_reconcile_count{dest_server="https://localhost:6443",namespace="argocd"} 1
`
fakeApp := newFakeApp(fakeApp)
metricsServ.IncReconcile(fakeApp, 5*time.Second)

View File

@@ -47,6 +47,7 @@ type syncContext struct {
proj *v1alpha1.AppProject
compareResult *comparisonResult
config *rest.Config
rawConfig *rest.Config
dynamicIf dynamic.Interface
disco discovery.DiscoveryInterface
extensionsclientset *clientset.Clientset
@@ -173,6 +174,7 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha
proj: proj,
compareResult: compareResult,
config: restConfig,
rawConfig: clst.RawRestConfig(),
dynamicIf: dynamicIf,
disco: disco,
extensionsclientset: extensionsclientset,
@@ -549,7 +551,7 @@ func (sc *syncContext) ensureCRDReady(name string) {
// applyObject performs a `kubectl apply` of a single resource
func (sc *syncContext) applyObject(targetObj *unstructured.Unstructured, dryRun, force, validate bool) (v1alpha1.ResultCode, string) {
message, err := sc.kubectl.ApplyResource(sc.config, targetObj, targetObj.GetNamespace(), dryRun, force, validate)
message, err := sc.kubectl.ApplyResource(sc.rawConfig, targetObj, targetObj.GetNamespace(), dryRun, force, validate)
if err != nil {
return v1alpha1.ResultCodeSyncFailed, err.Error()
}

View File

@@ -44,6 +44,7 @@ func newTestSyncCtx(resources ...*v1.APIResourceList) *syncContext {
})
sc := syncContext{
config: &rest.Config{},
rawConfig: &rest.Config{},
namespace: test.FakeArgoCDNamespace,
server: test.FakeClusterURL,
syncRes: &v1alpha1.SyncOperationResult{

View File

@@ -12,4 +12,4 @@ bases:
images:
- name: argoproj/argocd
newName: argoproj/argocd
newTag: latest
newTag: v1.5.0-rc2

View File

@@ -18,4 +18,4 @@ bases:
images:
- name: argoproj/argocd
newName: argoproj/argocd
newTag: latest
newTag: v1.5.0-rc2

View File

@@ -2827,7 +2827,7 @@ spec:
- "10"
- --redis
- argocd-redis-ha-haproxy:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2882,7 +2882,7 @@ spec:
- -n
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2932,7 +2932,7 @@ spec:
- argocd-repo-server
- --redis
- argocd-redis-ha-haproxy:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -3000,7 +3000,7 @@ spec:
- /shared/app
- --redis
- argocd-redis-ha-haproxy:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -2742,7 +2742,7 @@ spec:
- "10"
- --redis
- argocd-redis-ha-haproxy:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2797,7 +2797,7 @@ spec:
- -n
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2847,7 +2847,7 @@ spec:
- argocd-repo-server
- --redis
- argocd-redis-ha-haproxy:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -2915,7 +2915,7 @@ spec:
- /shared/app
- --redis
- argocd-redis-ha-haproxy:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -2327,7 +2327,7 @@ spec:
- "20"
- --operation-processors
- "10"
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2382,7 +2382,7 @@ spec:
- -n
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2446,7 +2446,7 @@ spec:
- argocd-repo-server
- --redis
- argocd-redis:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -2497,7 +2497,7 @@ spec:
- argocd-server
- --staticassets
- /shared/app
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -2242,7 +2242,7 @@ spec:
- "20"
- --operation-processors
- "10"
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2297,7 +2297,7 @@ spec:
- -n
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2361,7 +2361,7 @@ spec:
- argocd-repo-server
- --redis
- argocd-redis:6379
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -2412,7 +2412,7 @@ spec:
- argocd-server
- --staticassets
- /shared/app
image: argoproj/argocd:latest
image: argoproj/argocd:v1.5.0-rc2
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -3,6 +3,8 @@ package v1alpha1
import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"os"
"path/filepath"
@@ -22,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
@@ -2172,8 +2175,40 @@ func (proj AppProject) IsDestinationPermitted(dst ApplicationDestination) bool {
return false
}
// RESTConfig returns a go-client REST config from cluster
func (c *Cluster) RESTConfig() *rest.Config {
// SetK8SConfigDefaults sets Kubernetes REST config default settings
func SetK8SConfigDefaults(config *rest.Config) error {
config.QPS = common.K8sClientConfigQPS
config.Burst = common.K8sClientConfigBurst
tlsConfig, err := rest.TLSConfigFor(config)
if err != nil {
return err
}
// set default tls config since we use it in a custom transport
config.TLSClientConfig = rest.TLSClientConfig{}
dial := (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext
transport := utilnet.SetTransportDefaults(&http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSHandshakeTimeout: 10 * time.Second,
TLSClientConfig: tlsConfig,
MaxIdleConns: common.K8sMaxIdleConnections,
MaxIdleConnsPerHost: common.K8sMaxIdleConnections,
MaxConnsPerHost: common.K8sMaxIdleConnections,
DialContext: dial,
DisableCompression: config.DisableCompression,
})
tr, err := rest.HTTPWrappersForConfig(config, transport)
if err != nil {
return err
}
config.Transport = tr
return nil
}
// RawRestConfig returns a go-client REST config from cluster that might be serialized into the file using kube.WriteKubeConfig method.
func (c *Cluster) RawRestConfig() *rest.Config {
var config *rest.Config
var err error
if c.Server == common.KubernetesInternalAPIServerAddr && os.Getenv(common.EnvVarFakeInClusterConfig) == "true" {
@@ -2220,8 +2255,16 @@ func (c *Cluster) RESTConfig() *rest.Config {
if err != nil {
panic(fmt.Sprintf("Unable to create K8s REST config: %v", err))
}
config.QPS = common.K8sClientConfigQPS
config.Burst = common.K8sClientConfigBurst
return config
}
// RESTConfig returns a go-client REST config from cluster with tuned throttling and HTTP client settings.
func (c *Cluster) RESTConfig() *rest.Config {
config := c.RawRestConfig()
err := SetK8SConfigDefaults(config)
if err != nil {
panic(fmt.Sprintf("Unable to apply K8s REST config defaults: %v", err))
}
return config
}

View File

@@ -6,6 +6,8 @@ import (
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"github.com/argoproj/argo-cd/util"
@@ -188,6 +190,14 @@ func cleanSetParameters(val string) string {
}
func (c *Cmd) template(chartPath string, opts *TemplateOpts) (string, error) {
if c.HelmVer.getPostTemplateCallback != nil {
if callback, err := c.HelmVer.getPostTemplateCallback(filepath.Clean(path.Join(c.WorkDir, chartPath))); err == nil {
defer callback()
} else {
return "", err
}
}
args := []string{"template", chartPath, c.templateNameArg, opts.Name}
if opts.Namespace != "" {

View File

@@ -3,6 +3,7 @@ package helm
import (
"fmt"
"io/ioutil"
"os"
"path"
"gopkg.in/yaml.v2"
@@ -21,15 +22,36 @@ var (
}
// HelmV3 represents helm V3 specific settings
HelmV3 = HelmVer{
binaryName: "helm",
templateNameArg: "--name-template",
kubeVersionSupported: false,
showCommand: "show",
pullCommand: "pull",
initSupported: false,
binaryName: "helm",
templateNameArg: "--name-template",
kubeVersionSupported: false,
showCommand: "show",
pullCommand: "pull",
initSupported: false,
getPostTemplateCallback: cleanupChartLockFile,
}
)
// workaround for Helm3 bug. Remove after https://github.com/helm/helm/issues/6870 is fixed.
// The `helm template` command generates Chart.lock after which `helm dependency build` does not work
// As workaround removing lock file unless it exists before running helm template
func cleanupChartLockFile(chartPath string) (func(), error) {
exists := true
lockPath := path.Join(chartPath, "Chart.lock")
if _, err := os.Stat(lockPath); err != nil {
if os.IsNotExist(err) {
exists = false
} else {
return nil, err
}
}
return func() {
if !exists {
_ = os.Remove(lockPath)
}
}, nil
}
func getHelmVersion(chartPath string) (*HelmVer, error) {
data, err := ioutil.ReadFile(path.Join(chartPath, "Chart.yaml"))
if err != nil {
@@ -53,10 +75,11 @@ func getHelmVersion(chartPath string) (*HelmVer, error) {
// HelmVer contains Helm version specific settings such as helm binary and command names
type HelmVer struct {
binaryName string
initSupported bool
templateNameArg string
showCommand string
pullCommand string
kubeVersionSupported bool
binaryName string
initSupported bool
templateNameArg string
showCommand string
pullCommand string
kubeVersionSupported bool
getPostTemplateCallback func(chartPath string) (func(), error)
}

View File

@@ -9,13 +9,13 @@ import (
func TestGetHelmVersion_Helm3(t *testing.T) {
ver, err := getHelmVersion("./testdata/minio")
assert.NoError(t, err)
assert.Equal(t, *ver, HelmV3)
assert.Equal(t, ver.binaryName, HelmV3.binaryName)
}
func TestGetHelmVersion_Helm2(t *testing.T) {
ver, err := getHelmVersion("./testdata/helm2-dependency")
assert.NoError(t, err)
assert.Equal(t, *ver, HelmV2)
assert.Equal(t, ver.binaryName, HelmV2.binaryName)
}
func TestGetHelmVersion_InvalidVersion(t *testing.T) {

View File

@@ -1,10 +1,18 @@
apiVersion: v2
version: 1.0.0
name: has-dependency
name: foobar
description: A Helm chart for Kubernetes
home: https://localhost
dependencies:
- name: mariadb
version: 4.x.x
repository: https://kubernetes-charts.storage.googleapis.com/
condition: mariadb.enabled
tags:
- wordpress-database
- name: mongodb
version: 7.8.10
repository: https://charts.bitnami.com/bitnami
condition: mongodb.enabled
- name: eventstore
version: 0.2.5
repository: https://eventstore.github.io/EventStore.Charts
condition: eventstore.enabled
maintainers:
- name: estahn
type: application
version: 0.1.0
appVersion: 1.16.0