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

feat(controller): Add audit logs to workflows. Fixes #1769 #1930

Merged
merged 22 commits into from
Jan 22, 2020

Conversation

amarrella
Copy link
Contributor

@amarrella amarrella commented Jan 9, 2020

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes. -> it was proposed by one of the maintainers in Add audit logging for Workflow resources #1769
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234". Why? for the release notes.
  • Optional. I've added My organization is added to the README.
  • I've signed the CLA and required builds are green.

I pretty much ported the argo-cd implementation in https://github.com/argoproj/argo-cd/blob/0675ff2fb25fe97856171230f150e6ba5a2563d5/util/argo/audit_logger.go

@alexec alexec self-assigned this Jan 9, 2020
util/argo/audit_logger.go Outdated Show resolved Hide resolved
workflow/controller/operator.go Outdated Show resolved Hide resolved
util/argo/audit_logger.go Show resolved Hide resolved
util/argo/audit_logger.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 9, 2020

Codecov Report

Merging #1930 into master will decrease coverage by 0.13%.
The diff coverage is 8.06%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1930      +/-   ##
=========================================
- Coverage    9.02%   8.89%   -0.14%     
=========================================
  Files          53      61       +8     
  Lines       33698   34083     +385     
=========================================
- Hits         3042    3030      -12     
- Misses      30267   30662     +395     
- Partials      389     391       +2
Impacted Files Coverage Δ
persist/sqldb/null_workflow_archive.go 0% <ø> (ø)
pkg/apis/workflow/v1alpha1/openapi_generated.go 0% <0%> (ø) ⬆️
persist/sqldb/sqldb.go 0% <0%> (ø)
...ersist/sqldb/explosive_offload_node_status_repo.go 0% <0%> (ø)
pkg/apis/workflow/v1alpha1/generated.pb.go 0.45% <0%> (-0.01%) ⬇️
cmd/server/auth/gatekeeper.go 30.5% <0%> (+0.5%) ⬆️
persist/sqldb/migrate.go 0% <0%> (ø)
pkg/apis/workflow/v1alpha1/workflow_types.go 7.04% <0%> (-0.2%) ⬇️
persist/sqldb/workflow_archive.go 0% <0%> (ø)
persist/sqldb/backfill_cluster_name.go 0% <0%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de38d56...ac4d732. Read the comment docs.

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good so far. I've added a few comments, but I think they're mostly minor.

templates:
- name: exit
container:
image: docker/whalesay:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for using this image - makes for faster tests

@@ -67,6 +70,23 @@ func (t *Then) ExpectWorkflowList(listOptions metav1.ListOptions, block func(t *
return t
}

func (t *Then) ExpectAuditEvents(block func(*testing.T, *apiv1.EventList)) *Then {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@@ -93,6 +97,69 @@ func (s *FunctionalSuite) TestFastFailOnPodTermination() {
})
}

func (s *FunctionalSuite) TestEventOnNodeFail() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to state what this test is meant to do

test/e2e/functional_test.go Outdated Show resolved Hide resolved
test/e2e/functional_test.go Show resolved Hide resolved
util/argo/audit_logger.go Show resolved Hide resolved
util/argo/audit_logger.go Show resolved Hide resolved
workflow/controller/operator_test.go Show resolved Hide resolved
workflow/controller/operator_test.go Show resolved Hide resolved
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I think you need to do just one more thing before we merge, run make lint. The CI listing is currently broken on master

@amarrella
Copy link
Contributor Author

amarrella commented Jan 22, 2020

@alexec I just ran it and nothing happened. My golangci-lint version is

golangci-lint has version 1.23.1 built from 567904e on 2020-01-20T07:57:48Z

This is the output:

❯ make lint                                                                                                                                                                         ~/go/src/github.com/argoproj/argo
# Lint Go files
golangci-lint run --fix --verbose
INFO [config_reader] Config search paths: [./ /Users/amarrella/go/src/github.com/argoproj/argo /Users/amarrella/go/src/github.com/argoproj /Users/amarrella/go/src/github.com /Users/amarrella/go/src /Users/amarrella/go /Users/amarrella /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 11 linters: [deadcode errcheck goimports gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [lintersdb] Active 11 linters: [deadcode errcheck goimports gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (exports_file|files|name|types_sizes|compiled_files|deps|imports) took 7.486166956s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 173.551976ms
INFO [runner/unused/goanalysis] analyzers took 17.777373207s with top 10 stages: buildssa: 16.830737181s, U1000: 946.636026ms
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 2m13.29470776s with top 10 stages: buildssa: 1m14.9986216s, goimports: 8.507892103s, inspect: 3.881872092s, fact_deprecated: 3.356206081s, ctrlflow: 2.915250939s, printf: 2.649455586s, ineffassign: 2.51055655s, fact_purity: 1.685895698s, isgenerated: 1.182617992s, varcheck: 1.149710809s
INFO [runner/skip dirs] Skipped 2 issues from dir pkg/client/clientset/versioned/scheme by pattern pkg/client
INFO [runner/skip dirs] Skipped 6 issues from dir pkg/client/listers/workflow/v1alpha1 by pattern pkg/client
INFO [runner/skip dirs] Skipped 8 issues from dir pkg/client/clientset/versioned/typed/workflow/v1alpha1 by pattern pkg/client
INFO [runner/skip dirs] Skipped 2 issues from dir examples/example-golang by pattern (^|/)examples($|/)
INFO [runner/skip dirs] Skipped 6 issues from dir pkg/client/informers/externalversions/workflow/v1alpha1 by pattern pkg/client
INFO [runner/skip dirs] Skipped 4 issues from dir pkg/client/informers/externalversions by pattern pkg/client
INFO [runner/skip dirs] Skipped 7 issues from dir pkg/client/clientset/versioned/fake by pattern pkg/client
INFO [runner/skip dirs] Skipped 8 issues from dir pkg/client/clientset/versioned/typed/workflow/v1alpha1/fake by pattern pkg/client
INFO [runner/skip dirs] Skipped 2 issues from dir pkg/client/clientset/versioned by pattern pkg/client
INFO [runner/skip dirs] Skipped 2 issues from dir pkg/client/informers/externalversions/internalinterfaces by pattern pkg/client
INFO [runner] Issues before processing: 106, after processing: 0
INFO [runner] Processors filtering stat (out/in): exclude: 2/25, exclude-rules: 2/2, nolint: 0/2, filename_unadjuster: 106/106, path_prettifier: 106/106, cgo: 106/106, skip_files: 102/106, identifier_marker: 25/25, skip_dirs: 55/102, autogenerated_exclude: 25/55
INFO [runner] processing took 4.441321ms with stages: path_prettifier: 1.585795ms, autogenerated_exclude: 1.000538ms, exclude: 704.18µs, nolint: 445.513µs, identifier_marker: 327.313µs, skip_dirs: 323.097µs, skip_files: 27.718µs, cgo: 17.069µs, filename_unadjuster: 7.165µs, max_same_issues: 956ns, uniq_by_line: 416ns, source_code: 375ns, max_from_linter: 334ns, diff: 257ns, exclude-rules: 237ns, max_per_file_from_linter: 208ns, path_shortener: 150ns
INFO [runner] linters took 18.625441178s with stages: goanalysis_metalinter: 13.588482523s, unused: 5.032434385s
INFO fixer took 0s with no stages
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 251 samples, avg is 1866.5MB, max is 3433.7MB
INFO Execution took 26.305625645s
# Lint UI files
yarn --cwd ui lint
yarn run v1.21.1
$ tslint --fix -p ./src/app
✨  Done in 3.90s.

@alexec alexec merged commit 5c98a14 into argoproj:master Jan 22, 2020
@alexec
Copy link
Contributor

alexec commented Jan 22, 2020

Merged! This will be in v2.5

@amarrella
Copy link
Contributor Author

Thanks @alexec ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants