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

Chaos testing #6

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0e2135
move projects
pasha-codefresh Dec 6, 2021
7a82176
Revert "move projects"
pasha-codefresh Dec 6, 2021
c7f55e5
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 10, 2021
c0db07a
rbac changes
reggie-k Dec 13, 2021
27f1b48
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 13, 2021
d7b4701
rbacpolicy getProject also checks for ResourceLogs
reggie-k Dec 14, 2021
ef8542d
argocd_account_can-i.md changes for ResourceLogs
reggie-k Dec 14, 2021
2d82a34
Merge branch 'master' of https://github.com/argoproj/argo-cd
reggie-k Dec 14, 2021
7e90d1a
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 16, 2021
f3fd16b
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 17, 2021
b3c5af3
Merge branch 'master' of https://github.com/argoproj/argo-cd
reggie-k Dec 21, 2021
64251fb
SERVER_RBAC_LOG_ENFORCE_ENABLE switch
reggie-k Dec 28, 2021
71afa78
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 28, 2021
0898b49
Merge branch 'master' of https://github.com/argoproj/argo-cd
reggie-k Dec 29, 2021
efc404a
new e2e account tests and more unit account tests
reggie-k Jan 6, 2022
f53882e
Merge branch 'master' of https://github.com/argoproj/argo-cd
pasha-codefresh Jan 14, 2022
a972604
Merge branch 'argoproj:master' into master
pasha-codefresh Jan 15, 2022
c81aa64
upstream sync
reggie-k Jan 16, 2022
41721da
Merge branch 'master' of https://github.com/argoproj/argo-cd
reggie-k Jan 16, 2022
5e6a122
Merge branch 'argoproj:master' into master
pasha-codefresh Jan 19, 2022
a84b3e9
Merge branch 'master' of https://github.com/reggie-k/argo-cd
pasha-codefresh Jan 19, 2022
e37ead9
Merge branch 'argoproj:master' into master
pasha-codefresh Jan 24, 2022
eae5bf2
Merge remote-tracking branch 'origin/master'
pasha-codefresh Jan 24, 2022
dcf3a1a
Merge branch 'argoproj:master' into master
pasha-codefresh Jan 25, 2022
56a558c
Merge remote-tracking branch 'origin/master'
pasha-codefresh Jan 25, 2022
58d1459
testing tool
pasha-codefresh Jan 25, 2022
b707f4b
test
pasha-codefresh Jan 25, 2022
7405e03
improve testing tool
pasha-codefresh Jan 26, 2022
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ clidocsgen: ensure-gopath


.PHONY: codegen-local
codegen-local: ensure-gopath mod-vendor-local notification-docs notification-catalog gogen protogen clientgen openapigen clidocsgen manifests-local
codegen-local: ensure-gopath mod-vendor-local gogen protogen clientgen openapigen clidocsgen manifests-local notification-docs notification-catalog
rm -rf vendor/

.PHONY: codegen
Expand Down
1 change: 1 addition & 0 deletions assets/builtin-policy.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ p, role:readonly, repositories, get, *, allow
p, role:readonly, projects, get, *, allow
p, role:readonly, accounts, get, *, allow
p, role:readonly, gpgkeys, get, *, allow
p, role:readonly, logs, get, */*, allow

p, role:admin, applications, create, */*, allow
p, role:admin, applications, update, */*, allow
Expand Down
3 changes: 3 additions & 0 deletions cmd/argocd/commands/admin/settings_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var resourceMap map[string]string = map[string]string{
"cluster": rbacpolicy.ResourceClusters,
"gpgkey": rbacpolicy.ResourceGPGKeys,
"key": rbacpolicy.ResourceGPGKeys,
"log": rbacpolicy.ResourceLogs,
"logs": rbacpolicy.ResourceLogs,
"proj": rbacpolicy.ResourceProjects,
"projs": rbacpolicy.ResourceProjects,
"project": rbacpolicy.ResourceProjects,
Expand All @@ -48,6 +50,7 @@ var validRBACResources map[string]bool = map[string]bool{
rbacpolicy.ResourceCertificates: true,
rbacpolicy.ResourceClusters: true,
rbacpolicy.ResourceGPGKeys: true,
rbacpolicy.ResourceLogs: true,
rbacpolicy.ResourceProjects: true,
rbacpolicy.ResourceRepositories: true,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data:
p, role:user, applications, create, */*, allow
p, role:user, applications, delete, *, allow
p, role:user, applications, delete, */guestbook, deny
p, role:user, logs, get, */*, allow
g, test, role:user
policy.default: role:unknown
kind: ConfigMap
Expand Down
1 change: 1 addition & 0 deletions cmd/argocd/commands/admin/testdata/rbac/policy.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ p, role:user, applications, create, */*, allow
p, role:user, applications, delete, *, allow
p, role:user, applications, delete, */guestbook, deny
p, role:test, certificates, get, *, allow
p, role:test, logs, get, */*, allow
g, test, role:user
8 changes: 5 additions & 3 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ const (

// Kubernetes ConfigMap and Secret resource names which hold Argo CD settings
const (
ArgoCDConfigMapName = "argocd-cm"
ArgoCDSecretName = "argocd-secret"
ArgoCDRBACConfigMapName = "argocd-rbac-cm"
ArgoCDConfigMapName = "argocd-cm"
ArgoCDSecretName = "argocd-secret"
ArgoCDRBACConfigMapName = "argocd-rbac-cm"
ArgoCDCmdParamsConfigMapName = "argocd-cmd-params-cm"

// Contains SSH known hosts data for connecting repositories. Will get mounted as volume to pods
ArgoCDKnownHostsConfigMapName = "argocd-ssh-known-hosts-cm"
// Contains TLS certificate data for connecting repositories. Will get mounted as volume to pods
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/commands/argocd_account_can-i.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ argocd account can-i update projects 'default'
argocd account can-i create clusters '*'

Actions: [get create update delete sync override]
Resources: [clusters projects applications repositories certificates]
Resources: [clusters projects applications repositories certificates logs]

```

Expand Down
127 changes: 126 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/argoproj/argo-cd/v2

go 1.16
go 1.17

require (
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible
Expand Down Expand Up @@ -92,6 +92,131 @@ require (
sigs.k8s.io/yaml v1.3.0
)

require (
cloud.google.com/go v0.81.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20210112200207-10ab4d695d60 // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/antonmedv/expr v1.8.9 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.0.0 // indirect
github.com/go-openapi/analysis v0.19.5 // indirect
github.com/go-openapi/errors v0.19.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/strfmt v0.19.3 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.4.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/go-github/v41 v41.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gregdel/pushover v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/huandu/xstrings v1.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/itchyny/timefmt-go v0.1.2 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.13.5 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20210610120745-9d4ed1856297 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opsgenie/opsgenie-go-sdk-v2 v1.0.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.28.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/slack-go/slack v0.6.6 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/vmihailenco/go-tinylfu v0.2.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.mongodb.org/mongo-driver v1.1.2 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/exp v0.0.0-20210901193431-a062eea981d2 // indirect
golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4 // indirect
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gomodules.xyz/envconfig v1.3.1-0.20190308184047-426f31af0d45 // indirect
gomodules.xyz/notify v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.2.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiserver v0.23.1 // indirect
k8s.io/cli-runtime v0.23.1 // indirect
k8s.io/component-helpers v0.23.1 // indirect
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
k8s.io/kube-aggregator v0.23.1 // indirect
k8s.io/kubernetes v1.23.1 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/kustomize/api v0.10.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.0 // indirect
)

replace (
// https://github.com/golang/go/issues/33546#issuecomment-519656923
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
Expand Down
106 changes: 106 additions & 0 deletions hack/chaos-testing/cmd/commands/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package commands

import (
"fmt"

"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"

util2 "github.com/argoproj/argo-cd/v2/util"

"github.com/spf13/cobra"

"github.com/argoproj/argo-cd/v2/hack/chaos-testing/util"

cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
"github.com/argoproj/argo-cd/v2/util/cli"
)

const (
cliName = "argocd-chaos-testing"
)

func init() {
cobra.OnInitialize(initConfig)
}

func initConfig() {
cli.SetLogFormat(cmdutil.LogFormat)
cli.SetLogLevel(cmdutil.LogLevel)
}

func simulateReplicasChanges(token string, argoApi *util.ArgoApi, app v1alpha1.Application) {

fmt.Printf("Pick application with name %s \n", app.Name)

i := 0
for {
fmt.Printf("Execute replication emulation number: %v \n", i)

fmt.Println("Scale to 2")

_, err := argoApi.UpdateReplicas(token, 2, app.Name)
if err != nil {
fmt.Printf(err.Error())
return
}

util2.Wait(30, func(bools chan<- bool) {

})

fmt.Println("Scale to 1")

_, err = argoApi.UpdateReplicas(token, 1, app.Name)
if err != nil {
fmt.Printf(err.Error())
return
}

i++

}

}

// NewCommand returns a new instance of an argocd command
func NewCommand() *cobra.Command {

var host, username, password string
var threads int

var command = &cobra.Command{
Use: cliName,
Short: "Chaos testing",
Run: func(c *cobra.Command, args []string) {
argoApi := util.NewArgoApi(host)
token, err := argoApi.GetToken(username, password)
if err != nil {
return
}

apps, err := argoApi.ListApplications(token)
if err != nil {
fmt.Printf(err.Error())
return
}

for i := 0; i < threads; i++ {
_, _ = argoApi.Sync(token, apps[i].Name)
util2.Wait(5, func(bools chan<- bool) {
})
go simulateReplicasChanges(token, argoApi, apps[i])
}

select {}

},
DisableAutoGenTag: true,
}

command.PersistentFlags().StringVar(&host, "host", "http://localhost:8080", "Argo server host")
command.PersistentFlags().StringVar(&username, "username", "admin", "Username")
command.PersistentFlags().StringVar(&password, "password", "", "Argo server host")
command.PersistentFlags().IntVar(&threads, "threads", 1, "Amount of threads")

return command
}
16 changes: 16 additions & 0 deletions hack/chaos-testing/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
"os"

"github.com/argoproj/argo-cd/v2/hack/chaos-testing/cmd/commands"
)

func main() {
command := commands.NewCommand()
if err := command.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Loading
Loading