-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(build): check for env vars in all dirs #12652
Conversation
- previously, some of the `cmd/` subdirs were missed - and `server/` was missed in the `check-documented` func - instead use a variable to have consistent directories for both - `env.Get*(` calls were missed as well - add missing env vars to doc - `ARGO_DEBUG_PAUSE_*`, `ALLOWED_LINK_PROTOCOL`, `ARGO_ARTIFACT_SERVER`, `ARGO_PPROF`, `ARGO_SERVER_METRICS_AUTH`, `BASE_HREF` - link to `pprof` docs when referencing it - also consistently alphabetize the Server env vars -- `GRPC_MESSAGE_SIZE` is not last alphabetically - remove some no longer used env vars - `ARGO_SERVER_PPROF` was no longer used, meanwhile `ARGO_PPROF` was undocumented for the Server (was only documented for the Controller) - it was added in e566c10 and then replaced in 8678f00 but this code was leftover - refactor `check-env-doc.sh` - consistent 2 space indentation, not mixed 2 or 4 space - UX: list out all missed variables before exiting - previously it would exit after the first miss, meaning you'd have to fix -> run -> fix -> run until you got everything - and it's not the fastest script given how many files there are to parse through, so it's a productivity increase - fix some shellcheck issues with loops / arrays: https://www.shellcheck.net/wiki/SC2031 and https://www.shellcheck.net/wiki/SC2207 - something something "portable shell code" something something "maybe use Python instead next time" Future Work: - Still not quite all env vars are found by this script; in particular, dynamically named env vars are missing - such as those in [`common.go`](https://github.com/argoproj/argo-workflows/blob/7d70fe264fb0dbf42fbdf64cf94539408806a76d/workflow/common/common.go#L125), although there are others too Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
cmd.PersistentFlags().StringVar(&ArgoServerOpts.Path, "argo-base-href", os.Getenv("ARGO_BASE_HREF"), "An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.") | ||
cmd.PersistentFlags().StringVar(&ArgoServerOpts.Path, "argo-base-href", os.Getenv("ARGO_BASE_HREF"), "Path to use with HTTP client due to BASE_HREF. Defaults to the ARGO_BASE_HREF environment variable.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd personally prefer if we kept PRs atomic. I think documentation correction like this can be fixed in it's own separate PR even if it's minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just makes it a bit harder to review for the issue in question itself, which in this case is checking for missing env vars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I agree, which is why the vast majority of my PRs are small and split into independent chunks. (there are some that carry a different opinion though).
I changed this line because I had to create the docs for the BASE_HREF
env var for this PR and so referenced these and found the mistakes. So it is related to the purpose, and this PR does already change/add docs for BASE_HREF
specifically.
Unfortunately this one-liner causes a fairly large diff due to the codegen.
Also I'm not sure if "atomicity" is the right term here. As technically all commits and PRs are atomic. "Small, independent, singular purpose" are all terms I've used to describe this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved although I have a minor nit
@agilgur5 we seem to just generally be doing a lot of programming as a part of the build process via the hack directory, wonder if we should maybe just use something like this: https://magefile.org/ and get rid of the hacks alltogether? I guess my reasoning here is that I find the sed/awk/grep combos a bit hard to parse and understand. I'd rather write more easy to understand code instead. |
Oh I agree 100%, and I say this having had to write a ton of bash at my last two jobs for fleet management... and also having written proposals for two of those teams to "use a programming language instead of hard-to-maintain shell hackery" (there's a lot more issues with shell than it being hard to read, including directory awareness, arg parsing, (lack of) dependency management, portability, etc etc etc etc). In the PR description I did also literally write: "something something 'portable shell code' something something 'maybe use Python instead next time'"
A few things:
|
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com> Signed-off-by: Isitha Subasinghe <isubasinghe@student.unimelb.edu.au>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Motivation
cmd/
subdirs were missedserver/
was missed in thecheck-documented
funcenv.Get*(
calls were missed as wellI was responding to this Slack thread in
#argo-sig-scalability
and reviewing argoproj/argo-cd#17068 when I re-checked the Server'spprof
code and found an undocumented flag. So began the whole process of fixing the reason why it and other env vars were undocumented etcModifications
add missing env vars to doc
ARGO_DEBUG_PAUSE_*
,ALLOWED_LINK_PROTOCOL
,ARGO_ARTIFACT_SERVER
,ARGO_PPROF
,ARGO_SERVER_METRICS_AUTH
,BASE_HREF
pprof
docs when referencing itGRPC_MESSAGE_SIZE
is not last alphabeticallyremove some no longer used env vars
ARGO_SERVER_PPROF
was no longer used, meanwhileARGO_PPROF
was undocumented for the Server (was only documented for the Controller)gosec
warnings, disable pprof by default. Fixes #6594 #6596 but this code was leftoverrefactor
check-env-doc.sh
Verification
Script
devcontainer
(for a somewhat standardized version ofbash
), ran:bash hack/check-env-doc.sh
Docs
mkdocs build
open site/environment-variables/index.html
Notes to Reviewers
docs/cli
changes as it's all generated one-liner changes due to theconn.go
description changehack/check-env-doc.sh
refactor to (mostly) ignore the indentation fixesFuture Work
common.go
, although there are others tooGRPC_MESSAGE_SIZE
I moved in docs: full copy-edit ofenvironment-variables.md
#12148) and some env vars that are used by multiple Argo components/binaries.BASE_HREF
andALLOWED_LINK_PROTOCOL
are no longer needed since all flags can be env vars since feat: Add env vars config for argo-server and workflow-controller #6767 (ARGO_BASE_HREF
andARGO_ALLOWED_LINK_PROTOCOL
can be used instead). might be some others.--basehref
->--base-href
#12653 as this breaking change