Compare commits

..

8 Commits

Author SHA1 Message Date
Alex Collins
ad7a69a798 Adds flags for codegen and lint 2019-10-23 12:50:11 -07:00
Alex Collins
fc588538bc Increase test timeout to 10s as per master 2019-10-23 10:41:18 -07:00
Alexander Matyushentsev
675ae6a991 Issue #2185 - Manual sync don't trigger hooks (#2477) 2019-10-23 10:33:05 -07:00
Alex Collins
6cc0fd8b8c Increases lint deadline to 4m 2019-10-23 09:33:44 -07:00
Alexander Matyushentsev
26e1cf0438 Issue #2339 - Controller should compare with latest git revision if app has changed (#2543) 2019-10-22 15:28:23 -07:00
Alexander Matyushentsev
30d3fcb84a Unknown child app should not affect app health (#2544) 2019-10-22 15:28:17 -07:00
Alex Collins
3a3a7f5044 Update manifests to v1.2.4 2019-10-22 10:50:42 -07:00
Simon Behar
6c34dd828f Redact secrets in dex logs (#2538)
* Done

* Pre-commit

* Added test

* Pre-commit

* Goimports
2019-10-22 10:46:25 -07:00
17 changed files with 150 additions and 41 deletions

View File

@@ -27,7 +27,9 @@ DEV_IMAGE?=false
LINT_GOGC?=off
LINT_CONCURRENCY?=8
# Set timeout for linter
LINT_DEADLINE?=1m0s
LINT_DEADLINE?=4m0s
CODEGEN=true
LINT=true
override LDFLAGS += \
-X ${PACKAGE}.version=${VERSION} \
@@ -74,7 +76,7 @@ codegen-local: protogen clientgen openapigen manifests-local
.PHONY: codegen
codegen: dev-tools-image
$(call run-in-dev-tool,make codegen-local)
@if [ "$(CODGEN)" = "true" ]; then $(call run-in-dev-tool,make codegen-local) ; fi
.PHONY: cli
cli: clean-debug
@@ -161,7 +163,7 @@ lint-local: build
.PHONY: lint
lint: dev-tools-image
$(call run-in-dev-tool,make lint-local LINT_CONCURRENCY=$(LINT_CONCURRENCY) LINT_DEADLINE=$(LINT_DEADLINE) LINT_GOGC=$(LINT_GOGC))
@if [ "$(LINT)" = "true" ]; then $(call run-in-dev-tool,make lint-local LINT_CONCURRENCY=$(LINT_CONCURRENCY) LINT_DEADLINE=$(LINT_DEADLINE) LINT_GOGC=$(LINT_GOGC)); fi
.PHONY: build
build:

View File

@@ -1 +1 @@
1.2.3
1.2.4

View File

@@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"regexp"
"syscall"
"github.com/ghodss/yaml"
@@ -108,7 +109,7 @@ func NewRunDexCommand() *cobra.Command {
} else {
err = ioutil.WriteFile("/tmp/dex.yaml", dexCfgBytes, 0644)
errors.CheckError(err)
log.Info(string(dexCfgBytes))
log.Info(redactor(string(dexCfgBytes)))
cmd = exec.Command("dex", "serve", "/tmp/dex.yaml")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
@@ -554,6 +555,11 @@ func NewClusterConfig() *cobra.Command {
return command
}
func redactor(dirtyString string) string {
dirtyString = regexp.MustCompile("(clientSecret: )[^ \n]*").ReplaceAllString(dirtyString, "$1********")
return regexp.MustCompile("(secret: )[^ \n]*").ReplaceAllString(dirtyString, "$1********")
}
func main() {
if err := NewCommand().Execute(); err != nil {
fmt.Println(err)

View File

@@ -0,0 +1,73 @@
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
var textToRedact = `
- config:
clientID: aabbccddeeff00112233
clientSecret: $dex.github.clientSecret
orgs:
- name: your-github-org
redirectURI: https://argocd.example.com/api/dex/callback
id: github
name: GitHub
type: github
grpc:
addr: 0.0.0.0:5557
issuer: https://argocd.example.com/api/dex
oauth2:
skipApprovalScreen: true
staticClients:
- id: argo-cd
name: Argo CD
redirectURIs:
- https://argocd.example.com/auth/callback
secret: Dis9M-GA11oTwZVQQWdDklPQw-sWXZkWJFyyEhMs
- id: argo-cd-cli
name: Argo CD CLI
public: true
redirectURIs:
- http://localhost
storage:
type: memory
web:
http: 0.0.0.0:5556`
var expectedRedaction = `
- config:
clientID: aabbccddeeff00112233
clientSecret: ********
orgs:
- name: your-github-org
redirectURI: https://argocd.example.com/api/dex/callback
id: github
name: GitHub
type: github
grpc:
addr: 0.0.0.0:5557
issuer: https://argocd.example.com/api/dex
oauth2:
skipApprovalScreen: true
staticClients:
- id: argo-cd
name: Argo CD
redirectURIs:
- https://argocd.example.com/auth/callback
secret: ********
- id: argo-cd-cli
name: Argo CD CLI
public: true
redirectURIs:
- http://localhost
storage:
type: memory
web:
http: 0.0.0.0:5556`
func TestSecretsRedactor(t *testing.T) {
assert.Equal(t, expectedRedaction, redactor(textToRedact))
}

View File

@@ -762,23 +762,22 @@ func (ctrl *ApplicationController) needRefreshAppStatus(app *appv1.Application,
compareWith := CompareWithLatest
refreshType := appv1.RefreshTypeNormal
expired := app.Status.ReconciledAt == nil || app.Status.ReconciledAt.Add(statusRefreshTimeout).Before(time.Now().UTC())
if requestedType, ok := app.IsRefreshRequested(); ok || expired {
if ok {
refreshType = requestedType
reason = fmt.Sprintf("%s refresh requested", refreshType)
} else if expired {
reason = fmt.Sprintf("comparison expired. reconciledAt: %v, expiry: %v", app.Status.ReconciledAt, statusRefreshTimeout)
}
} else if requested, level := ctrl.isRefreshRequested(app.Name); requested {
compareWith = level
reason = fmt.Sprintf("controller refresh requested")
} else if app.Status.Sync.Status == appv1.SyncStatusCodeUnknown && expired {
reason = "comparison status unknown"
if requestedType, ok := app.IsRefreshRequested(); ok {
// user requested app refresh.
refreshType = requestedType
reason = fmt.Sprintf("%s refresh requested", refreshType)
} else if expired {
reason = fmt.Sprintf("comparison expired. reconciledAt: %v, expiry: %v", app.Status.ReconciledAt, statusRefreshTimeout)
} else if !app.Spec.Source.Equals(app.Status.Sync.ComparedTo.Source) {
reason = "spec.source differs"
} else if !app.Spec.Destination.Equals(app.Status.Sync.ComparedTo.Destination) {
reason = "spec.destination differs"
} else if requested, level := ctrl.isRefreshRequested(app.Name); requested {
compareWith = level
reason = fmt.Sprintf("controller refresh requested")
}
if reason != "" {
logCtx.Infof("Refreshing app status (%s), level (%d)", reason, compareWith)
return true, refreshType, compareWith

View File

@@ -550,4 +550,22 @@ func TestNeedRefreshAppStatus(t *testing.T) {
assert.Equal(t, argoappv1.RefreshTypeHard, refreshType)
assert.Equal(t, CompareWithLatest, compareWith)
}
{
app := app.DeepCopy()
// ensure that CompareWithLatest level is used if application source has changed
ctrl.requestAppRefresh(app.Name, ComparisonWithNothing)
// sample app source change
app.Spec.Source.Helm = &argoappv1.ApplicationSourceHelm{
Parameters: []argoappv1.HelmParameter{{
Name: "foo",
Value: "bar",
}},
}
needRefresh, refreshType, compareWith = ctrl.needRefreshAppStatus(app, 1*time.Hour)
assert.True(t, needRefresh)
assert.Equal(t, argoappv1.RefreshTypeNormal, refreshType)
assert.Equal(t, CompareWithLatest, compareWith)
}
}

View File

@@ -12,7 +12,7 @@ bases:
images:
- name: argoproj/argocd
newName: argoproj/argocd
newTag: v1.2.3
newTag: v1.2.4
- name: argoproj/argocd-ui
newName: argoproj/argocd-ui
newTag: v1.2.3
newTag: v1.2.4

View File

@@ -18,7 +18,7 @@ bases:
images:
- name: argoproj/argocd
newName: argoproj/argocd
newTag: v1.2.3
newTag: v1.2.4
- name: argoproj/argocd-ui
newName: argoproj/argocd-ui
newTag: v1.2.3
newTag: v1.2.4

View File

@@ -2901,7 +2901,7 @@ spec:
- argocd-redis-ha-announce-2:26379
- --sentinelmaster
- argocd
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2955,7 +2955,7 @@ spec:
- cp
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -3011,7 +3011,7 @@ spec:
- argocd-redis-ha-announce-2:26379
- --sentinelmaster
- argocd
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -3085,7 +3085,7 @@ spec:
- argocd-redis-ha-announce-2:26379
- --sentinelmaster
- argocd
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -2816,7 +2816,7 @@ spec:
- argocd-redis-ha-announce-2:26379
- --sentinelmaster
- argocd
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2870,7 +2870,7 @@ spec:
- cp
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2926,7 +2926,7 @@ spec:
- argocd-redis-ha-announce-2:26379
- --sentinelmaster
- argocd
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -3000,7 +3000,7 @@ spec:
- argocd-redis-ha-announce-2:26379
- --sentinelmaster
- argocd
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -2665,7 +2665,7 @@ spec:
- "20"
- --operation-processors
- "10"
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2719,7 +2719,7 @@ spec:
- cp
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2783,7 +2783,7 @@ spec:
- argocd-repo-server
- --redis
- argocd-redis:6379
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -2834,7 +2834,7 @@ spec:
- argocd-server
- --staticassets
- /shared/app
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -2580,7 +2580,7 @@ spec:
- "20"
- --operation-processors
- "10"
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:
@@ -2634,7 +2634,7 @@ spec:
- cp
- /usr/local/bin/argocd-util
- /shared
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
name: copyutil
volumeMounts:
@@ -2698,7 +2698,7 @@ spec:
- argocd-repo-server
- --redis
- argocd-redis:6379
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 5
@@ -2749,7 +2749,7 @@ spec:
- argocd-server
- --staticassets
- /shared/app
image: argoproj/argocd:v1.2.3
image: argoproj/argocd:v1.2.4
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -35,7 +35,7 @@ type Context struct {
func Given(t *testing.T) *Context {
fixture.EnsureCleanState(t)
return &Context{t: t, destServer: KubernetesInternalAPIServerAddr, repoURLType: fixture.RepoURLTypeFile, name: fixture.Name(), timeout: 5, project: "default", prune: true}
return &Context{t: t, destServer: KubernetesInternalAPIServerAddr, repoURLType: fixture.RepoURLTypeFile, name: fixture.Name(), timeout: 10, project: "default", prune: true}
}
func (c *Context) CustomCACertAdded() *Context {

View File

@@ -29,6 +29,7 @@ func TestPostSyncHookSuccessful(t *testing.T) {
// make sure we can run a standard sync hook
func testHookSuccessful(t *testing.T, hookType HookType, podHookPhase OperationPhase) {
Given(t).
Timeout(10).
Path("hook").
When().
PatchFile("hook.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/hook": "%s"}}]`, hookType)).

View File

@@ -16,7 +16,7 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {
const [form, setForm] = React.useState<FormApi>(null);
const isVisible = !!(selectedResource && application);
const appResources = (application && selectedResource && application.status && application.status.resources || []).sort(
(first, second) => nodeKey(first).localeCompare(nodeKey(second)));
(first, second) => nodeKey(first).localeCompare(nodeKey(second))).filter((item) => !item.hook);
const syncResIndex = appResources.findIndex((item) => nodeKey(item) === selectedResource);
const syncStrategy = {} as models.SyncStrategy;
@@ -36,7 +36,7 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {
<Form
defaultValues={{
revision: application.spec.source.targetRevision || 'HEAD',
resources: appResources.filter((item) => !item.hook).map((_, i) => i === syncResIndex || syncResIndex === -1),
resources: appResources.map((_, i) => i === syncResIndex || syncResIndex === -1),
}}
validateError={(values) => ({
resources: values.resources.every((item: boolean) => !item) && 'Select at least one resource',

View File

@@ -63,7 +63,7 @@ func ignoreLiveObjectHealth(liveObj *unstructured.Unstructured, resHealth appv1.
return true
}
gvk := liveObj.GroupVersionKind()
if gvk.Group == "argoproj.io" && gvk.Kind == "Application" && resHealth.Status == appv1.HealthStatusMissing {
if gvk.Group == "argoproj.io" && gvk.Kind == "Application" && (resHealth.Status == appv1.HealthStatusMissing || resHealth.Status == appv1.HealthStatusUnknown) {
// Covers the app-of-apps corner case where child app is deployed but that app itself
// has a status of 'Missing', which we don't want to cause the parent's health status
// to also be Missing

View File

@@ -115,6 +115,7 @@ func TestAppOfAppsHealth(t *testing.T) {
}
missingApp, missingStatus := newAppLiveObj("foo", appv1.HealthStatusMissing)
unknownApp, unknownStatus := newAppLiveObj("fooz", appv1.HealthStatusUnknown)
healthyApp, healthyStatus := newAppLiveObj("bar", appv1.HealthStatusHealthy)
degradedApp, degradedStatus := newAppLiveObj("baz", appv1.HealthStatusDegraded)
@@ -127,6 +128,15 @@ func TestAppOfAppsHealth(t *testing.T) {
assert.Equal(t, appv1.HealthStatusHealthy, healthStatus.Status)
}
// verify unknown child app does not affect app health
{
unknownAndHealthyStatuses := []appv1.ResourceStatus{unknownStatus, healthyStatus}
unknownAndHealthyLiveObjects := []*unstructured.Unstructured{unknownApp, healthyApp}
healthStatus, err := SetApplicationHealth(unknownAndHealthyStatuses, unknownAndHealthyLiveObjects, nil, noFilter)
assert.NoError(t, err)
assert.Equal(t, appv1.HealthStatusHealthy, healthStatus.Status)
}
// verify degraded does affect
{
degradedAndHealthyStatuses := []appv1.ResourceStatus{degradedStatus, healthyStatus}