Commit Graph

406 Commits

Author SHA1 Message Date
Yong Zhang
0e1af85c0b Fix AWS default credentials (#1963)
Fix a bug where default credentials were erroneously cleared out, which broke several implementations.
2024-05-22 19:15:48 -07:00
Vanes Angelo
900cb4f7c1 Upgrade to AWS SDK v2 (#1938) (#1950)
Upgrades the AWS SDK to v2. AWS S3 bucket urls will now error if they are not prefixed with a schema (example: https://).
2024-04-28 21:38:42 -07:00
Matt
359c119441 Add an introduction page as the home page (#1945)
A default homepage is baked into the server that uses the request host address, or in HTTP 2 the authority. This includes ports. It also checks for schema. The values are used to indicate to users how to configure their go env

Of course, this won't work on all installations - especially enterprise ones. For that, we've introduced ATHENS_HOME_TEMPLATE_PATH as an environment variable along with HomeTemplatePath in the config. This value defaults to /var/lib/athens/home.html but can be configured to any location that Athens can reliably read from. This is a Go HTML template so it should use Go HTML template formatting and logic.
2024-04-20 00:19:34 -07:00
kkHAIKE
81415839ba Fix an issue where contexts are not copied correctly (#1941)
Fix an issue in the Stasher where contexts between the request and log entry are not copied correctly.

Co-authored-by: ouyangxu <ouyangxu@bilibili.com>
2024-04-13 13:35:25 -07:00
kkHAIKE
a5277a3e7a Use errors.AsErr to extract and detect errors.Error (#1936)
Switches from using errors.Is() to errors.As() so the error context is passed correctly.
2024-04-09 14:25:00 -07:00
Matt
b9c8fb7f8a Rework logging defaults (#1927)
Changes default logger back to plain.
2024-03-27 17:48:10 -07:00
tanx
c072f6089a Update mongodb driver (#1928)
Updates the MongoDB driver
2024-03-25 15:39:14 -07:00
Matt
08520bf894 Add log formatting settings (#1926)
Adds a log format setting as ATHENS_LOG_FORMAT that can be either plain or JSON when CloudRuntime is none (the default). Does not break or change any existing behavior.
2024-03-21 09:07:39 -07:00
wozz
3af0d009a8 singleflight go commands (#1877)
* singleflight go commands

* Apply suggestions from code review

Co-authored-by: Brendan Le Glaunec <brendan@glaulabs.com>

---------

Co-authored-by: michael-wozniak <michael.wozniak@snapchat.com>
Co-authored-by: Brendan Le Glaunec <brendan@glaulabs.com>
2023-12-21 15:37:36 +02:00
yatesliang
aca3cc0090 test: unit test for testing KindUnexpected case in Mongo query function (#1883) 2023-09-25 00:24:02 -07:00
Thomas
9a14565152 fix(pkg/stash): close etcd sessions (#1887) 2023-09-18 12:15:41 -07:00
Thomas
1d16cc3070 fix(pkg/stash): don't check status of all etcd endpoints on start (#1889) 2023-09-18 11:54:33 -07:00
Thomas
e248d22892 fix(proxy): don't check TLS file permission (#1880) 2023-09-01 07:44:47 -07:00
Nicholas Wiersma
6be4bebc0c chore: switch from interface{} to any (#1837) 2023-06-23 15:41:27 +02:00
LINKIWI
e5aa5974e1 Support Unix domain sockets for proxy server listener (#1865) 2023-05-06 11:35:06 +02:00
Nicholas Wiersma
7c3e3a0999 fix: relax file permissions (#1866) 2023-04-14 08:25:53 +02:00
Zhongpeng Lin
b72a768a05 use errors.AsErr (#1849)
Co-authored-by: Manu Gupta <manugupt1@gmail.com>
2023-03-12 22:04:12 -07:00
Zhongpeng Lin
5099b30ac6 Removing Exists() check from S3 getters (#1842)
* Atomic access to S3

* fixing linting errors

* make delete return KindNotFound

* restore checker and deleter
2023-03-03 19:46:09 -08:00
Zhongpeng Lin
1f0a460687 Calling HeadObjectWithContext() concurrently to check the existence of a module (#1844)
* Using HeadObject to check the existence of a module

* fixing build

* calling cancel before closing channel

* fixing test

* using waitgroup

* calling cancel

* calling wg.Done

* only return the first error

* Revert "only return the first error"

This reverts commit c0aa18b522.

* clean err if not exist
2023-03-03 14:56:12 -05:00
Nicholas Wiersma
748aa4d165 chore: remove last drone remains (#1839)
* chore: remove drone

* fix: cr suggestions

* fix: cr suggestions
2023-02-28 18:51:12 +08:00
Nicholas Wiersma
d932d50232 chore: lint code with golangci-lint (#1828)
* feat: add golangci-lint linting

* chore: fix linter issues

* feat: add linting into the workflow

* docs: update lint docs

* fix: cr suggestions

* fix: remove old formatting and vetting scripts

* fix: add docker make target

* fix: action go caching

* fix: depreciated actions checkout version

* fix: cr suggestion

* fix: cr suggestions

---------

Co-authored-by: Manu Gupta <manugupt1@gmail.com>
2023-02-24 20:39:17 -08:00
Ashish Ranjan
3f26845cff move to github actions from drone (#1823)
* add github actions workflow for tag releases

* migrate drone build &test step to github actions

* fix minio service

* fix indentation

* fix dependency syntax

* remove needs keyword

* fix service hostnames, add protectedredis

* update protected redis docker image

* fix too many args error

* exclude vendor dir from gofmt

* fix fmt errors

* fix fmt errors

* rm .drone.yml

* rename workflow name

* break test step

* remove vendor step

* use makefile rule

* use buildx
2023-02-22 22:47:37 -08:00
Zhongpeng Lin
6aaf9e5b17 Handle duplicate keys returned by S3 ListObject (#1793)
S3 API sometimes returns duplicate keys, causing the number of file for a specific module greater than 3. This PR makes Athens handle that situation gracefully and log a warning message instead of treating the module as not found.

logging string content

Co-authored-by: Manu Gupta <manugupt1@gmail.com>
Co-authored-by: Ashish Ranjan <ashishranjan2912@gmail.com>
2023-01-30 13:01:09 +08:00
Eng Zer Jun
b3bc773e29 test(pkg/config): use t.Setenv to set env vars (#1821)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Co-authored-by: Ashish Ranjan <ashishranjan2912@gmail.com>
2023-01-30 13:00:37 +08:00
Mike Seplowitz
f35a5406a3 Pass Athens's logger to the Redis package (#1817)
Co-authored-by: Ashish Ranjan <ashishranjan2912@gmail.com>
2023-01-30 12:22:49 +08:00
Nicholas Wiersma
ab64133949 feat: replace ioutil with io and os (#1816) 2023-01-27 20:42:47 +05:30
Rob Prentiss
a1553999bb Make shutdown timeout configurable (#1806)
Currently, when shutting down the server (via SIGINT or SIGTERM), the
shutdown closes any open connections after only 10 seconds (via a
context.WithTimeout). This does not provie a lot of time for longer
operations, such as listing versions, or downloading a larger module zip
file.

When running in Kubernetes, and scaling instances or changing config,
this causes a lot of dropped connections and gateway errors. 10 seconds
is arguably much too short, and should be configurable.

This commit increases that default to 60 seconds, and adds a config
variable to allow users to specify their desired timeout.
2023-01-23 22:02:45 -08:00
Zhongpeng Lin
4c3443328e Adding new fields to RevInfo (#1812)
* Allow unknown fields in RevInfo

* Revert "Allow unknown fields in RevInfo"

This reverts commit 902d791554.

* Adding new fields to rev_info.go

* fixed tests
2023-01-16 12:11:10 -08:00
Jerry Ng
92150d0500 Update s3 checker to iterate through all objects pages (#1802) 2023-01-08 13:46:20 -08:00
Ashish Ranjan
cc496afbf1 read redis lock options from config to support custom TTL & timeout (#1791)
* read redis lock options from config to support custom TTL & timeout

* fix test

* fix typo

* downgrade to bsm/redislock@v0.7.2 to prevent usage of beta go-redis version

* revert test changes

* return error for invalid lock config

* update config parsing test

* udpate docs to include redis lock config

* fix test

* set default max retries to 10

* reduce default redis lock timeout to 15s

* update default TTL to 15mins

Co-authored-by: Manu Gupta <manugupt1@gmail.com>
2022-09-28 22:53:06 -07:00
Zhongpeng Lin
b8d7c4aa79 Register HTTP client views for stats (#1787) 2022-09-22 21:04:51 -07:00
Ashish Ranjan
7d67ee76ce fix default s3 credentials set as anonymous (#1789) 2022-09-15 18:30:54 -07:00
Ashish Ranjan
33777c5cc4 copy context before starting stash operations to prevent ctx cancellations (#1790)
* copy context before starting stash operations to prevent ctx cancellations

* add comment about context cancellation
2022-09-15 11:03:59 -04:00
Rob Prentiss
3fab46905e Resolve memory leaks when using Minio storage (#1777)
When using Minio storage, memory usage constantly increases. After
profiling, it appears that memory usage is building in the minio client,
and not being released.

Finding a similar issue listed in the minio/warp project, I found that
they fixed the issue by closing the *minio.Object instances. In the
athens usage, the minio.Object instances are never closed after reading
the data from them.

This adds deferred 'Close' calls in the 'storageImpl.Info' and
'storageImpl.GoMod' functions so that the objects may be released and
garbage collected. The 'storageImpl.Zip' function does not use defer,
since it has the object embedded into the return value, so the 'Close'
is only called on error.
2022-06-06 19:04:33 -04:00
Manu Gupta
be203340be Remove deprecated GOPROXY in favor of GoBinaryEnvVars (#1759) 2022-02-18 10:24:44 -08:00
Manu Gupta
3a40029ec8 Revert retries in redis-flake as builds are failing again. (#1758) 2022-02-16 12:31:47 -08:00
Manu Gupta
67bb68c45d Update etcd (#1756) 2022-02-15 09:10:51 -08:00
Manu Gupta
533035c40c fix flake on redis-sentinel by depending on redis container / step. (#1748)
* fix: flake on redis-sentinel by depending on redis container / step.

Signed-off-by: Manu Gupta <manugupt1@gmail.com>

* Add retries in an attempt to reduce the number of flakes

Also; update go-redis.

Co-authored-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com>
2022-02-14 14:01:29 -08:00
Rob Lee
918ddfb59a Replace golint with go vet#1743 (#1744)
* Set GO111MODULE to auto in golint script– #1743

As mentioned in #1743 the Go modules environment flag is set to `off`
in the script which appears to cause a warning message for each module
of the codebase that it is "not in GOROOT".

Set to `auto` as this allows the same build to be run the original way
should someone choose to delete the `go.mod` file from the project root.

* Remove redundant code – golint script

Go 1.17 ignores `GO111MODULE` and there are no directories in the
project root called `mock`.

* Replace `golint` with `go vet`

`golint` is deprecated (and frozen) replace with the current `go vet`.
This reported one issue on `main` branch:
```pkg/stash/with_etcd.go:33:28:
loop variable ep captured by func literal```

Fixed loop variable capture with extraction to parameterised anonymous
function passed loop variable and passed in to `errgroup.Go` call.
2021-12-09 22:03:48 -08:00
Abhay Krishna
38a3039a21 Fix typos and comments in config.toml (#1739)
Co-authored-by: Marwan Sulaiman <marwan.sameer@gmail.com>
2021-12-03 01:38:09 -05:00
Aaron Schlesinger
2a8b8eed75 Fixing panic with S3 storage (#1730)
Signed-off-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com>
2021-10-01 13:11:33 -07:00
Marwan Sulaiman
a724fcdddc Update mongo client to address CVE (#1728) 2021-08-18 22:49:44 -04:00
Zhongpeng Lin
4abe908a58 Using directory as prefix for S3 (#1720)
* Using directory as prefix for S3

* address comments

Co-authored-by: Marwan Sulaiman <marwan.sameer@gmail.com>
2021-08-18 21:06:51 -04:00
Marwan Sulaiman
151c4922fb Enable Athens to work in offline mode (#1717)
Co-authored-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com>
2021-08-18 19:09:14 -04:00
Zhongpeng Lin
9b505e9ee0 Use actual content length when it is not available in headers (#1719)
* Use actual content length when it is not available in headers

* Setting Content-Length before writing body

* Using zero value as unknown size
2021-06-18 10:57:46 -04:00
Aaron Schlesinger
1acdf17a4a Reverting passthrough auth (#1700)
* Reverting PR 1650

https://github.com/gomods/athens/pull/1650 was a big change to the
authentication/authorization code, which we have decided to pull
out and potentially move into a separate process/project

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing commented, unused code

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing more commented, unused code

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing more unused code

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
2021-03-11 11:28:15 -08:00
Marwan Sulaiman
6ef4a793c3 Add Content-Length to .zip requests (#1681)
* Add Content-Length to .zip requests

* pr comments

Co-authored-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com>
2020-11-24 10:00:47 -05:00
Abhisek Banerjee
46b68e4da8 Support IRSA for S3 bucket (#1673) 2020-11-20 11:24:54 -08:00
Marwan Sulaiman
dfb7887080 Allow Athens to Propagate Authentication to Mod Download (#1650)
* Allow Athens to Propagate Authentication to Mod Download

* update readme

* add pattern matching to auth propagation

* Propagate authentication to pre declared static host

* quote redis test

* fix flaky redis error message

* fix config tests

* fix config tests

* Update config.dev.toml

Co-authored-by: Ted Wexler <ted@stuckinacan.com>

* gofmt

Co-authored-by: Ted Wexler <ted@stuckinacan.com>
2020-07-30 17:06:53 -04:00
Marwan Sulaiman
81906b918f pkg/requestid: add Request ID to Athens requests and logs (#1655)
Co-authored-by: Ted Wexler <ted@stuckinacan.com>
2020-07-27 12:37:36 -04:00