55 Commits

Author SHA1 Message Date
Alexandr Hacicheant
ab1775afee Redis Sentinel SingeFlight: support of Redis master node username and password (#2039)
* Add support for Redis Username and Password configuration

Introduced Redis master authentication parameters (username and password) to the Redis Sentinel setup. This enhances compatibility with Redis environments that require authentication for both sentinel and master nodes.

* Add support for protected Redis Sentinel configuration and related unit tests
2025-04-01 07:34:13 +02:00
Taylor Chen
3856c6feee add timeout to vcsLister.List() (#1986) 2024-09-20 08:19:47 +02:00
Derek Buitenhuis
0ef761cc8b gcp/saver: Only return errors.KindAlreadyExists if all three exist (#1957)
* gcp/saver: Only return errors.KindAlreadyExists if all three exist

In #1124, a GCP lock type was added as a singleflight backend. As part of this work, the GCP backend's Save() was made serial, likely because moduploader.Upload requires a call to Exists() before it, rendering the GCP lock less useful, by doubling the calls to GCS.

However, by doing this, the existence check was now only checking the existence of the mod file, and not the info or zip. This meant that if during a Save, the zip or info uploads failed, on subsequent rquests, that when using the GCP singleflight backend, Athens would assume everything had been stashed and saved properly, and then fail to serve up the info or zip that had failed upload, meaning the cache was in an unhealable broklen state, requiring a manual intervention.

To fix this, without breaking the singleflight behavior, introduce a metadata key that is set on the mod file during its initial upload, indicating that a Stash is still in progress on subsequent files, which gets removed once all three files are uploaded successfully, which can be checked if it it is determined that the mod file already exists. That way we can return a errors.KindAlreadyExists if a Stash is in progress, but also properly return it when a Stash is *not* currently in progress if and only if all three files exist on GCS, which prevents the cache from becoming permanently poisoned.

One note is that it is possible the GCS call to remove the metadata key fails, which would mean it is left on the mod object forever. To avoid this, consider it stale after 2 minutes.

---------

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Co-authored-by: Matt <matt.ouille@protonmail.com>
2024-06-02 19:32:54 +00: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
Nicholas Wiersma
6be4bebc0c chore: switch from interface{} to any (#1837) 2023-06-23 15:41:27 +02: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
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
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
Manu Gupta
be203340be Remove deprecated GOPROXY in favor of GoBinaryEnvVars (#1759) 2022-02-18 10:24:44 -08: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
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
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
ef15c3458b Allow users to specify the module fetcher's temporary directory (#1636) 2020-06-25 17:15:15 -04:00
Marwan Sulaiman
52934cfa46 implement /index endpoint (#1630)
* implement /index endpoint

* rename to Module to Path
2020-06-24 14:29:30 -04:00
Elliot Morrison-Reed
c08aa890cb Fix sumdb/* paths when config.PathPrefix is set (#1620)
* Fix sumdb/* paths when config.PathPrefix is set

http.StripPrefix will look at the entire request path when called,
if we do not include config.PathPrefix then the StripPrefix call
will never receive a valid path from the application and the user
will always get a 404 error.

There were no test where I could easily check this regression so
I also added a few endpoint tests, the last test will fail with
a 404 instead of 403 if this change in not applied.

* Update cmd/proxy/actions/app_proxy.go

Co-authored-by: Marwan Sulaiman <marwan-at-work@github.com>

* Update cmd/proxy/actions/app_proxy_test.go

Co-authored-by: Marwan Sulaiman <marwan-at-work@github.com>

* Update cmd/proxy/actions/app_proxy_test.go

Co-authored-by: Marwan Sulaiman <marwan-at-work@github.com>

* Update cmd/proxy/actions/app_proxy_test.go

Co-authored-by: Marwan Sulaiman <marwan-at-work@github.com>

* Removed unneeded import of logrus

Co-authored-by: Marwan Sulaiman <marwan-at-work@github.com>
2020-06-05 12:01:38 -04:00
Aaron Schlesinger
94a97fe9e9 "sumdbPoxy" ==> "sumdbProxy" (#1569)
Co-authored-by: Ted Wexler <ted@stuckinacan.com>
2020-03-20 15:18:51 -04:00
Marwan Sulaiman
0bb95c7351 pkg/storage: make Checker optional in storage.Backend (#1580)
* pkg/storage: make Checker optional in storage.Backend

* pass storage
2020-03-18 19:07:00 -04:00
Ted Wexler
939e695526 Adds redis sentinel support (#1554)
* Adds redis sentinel support

Fixes #1553

* Fix redis-sentinel test hostnames

* Fix redis master name again

* Fix redis sentinel port in tests

* Upgrade the redis client

* Rmoeve accidental config change

* Fix default config

* Addresses review comments

* Add documentation on single flight mechanisms

* Fix spelling issues

* Fix formatting

Co-authored-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com>
2020-03-17 13:04:37 -07:00
Matthew Plachter
71c57ef7ee add config options for redis password (#1545)
* add config options for redis password

* redis password test and failure test

* changed redis name and made a minimal redis.conf

add drone volume

volume fix

remove volumes from drone.

repoint redis path

Co-authored-by: Aaron Schlesinger <70865+arschles@users.noreply.github.com>
Co-authored-by: Marwan Sulaiman <marwan.sameer@gmail.com>
2020-02-25 16:18:04 -08:00
Marwan Sulaiman
298c6cd74d cmd/proxy/actions: pass NoSumPatterns to GoGetFetcher (#1391)
* cmd/proxy/actions: pass NoSumPatterns to GoGetFetcher

* add gosum unit tests

* upgrade appveyor to 1.13

* fix test typo

* check appveyor version

* AppVeyor has no 1.13

* use logger
2019-09-23 12:47:40 -04:00
oliverch
874d27158d feat: add /robots.txt (#1355)
* feat: add /robots.txt

* disallow all crawler by default.
2019-09-16 16:21:08 -05:00
Yi Tang
ca10728887 ref: upstream lister and it's impl to module pkg (#1309) 2019-07-25 20:40:03 -04:00
Yi Tang
7de77889ad support goproxy for list/download command (#1304) 2019-07-15 14:07:24 -04:00
Marwan Sulaiman
76fb786324 downloadProtocol: support multi-proxy environments with DownloadFile (#1230)
* downloadProtocol: support multi-proxy environments with DownloadFile

* remove debugging lines

* update config tests

* download/mode: add tests for DownloadFile and friends

* add documentation to Download File
2019-06-08 00:30:07 -04:00
Marwan Sulaiman
0cac0edbf1 actions: support proxying sum db urls (#1208)
* actions: support proxying sum db urls

* remove proxy prefix

* add docs for checksum db

* more docs

* typo

* typo

* typo

* typo

* typo

* typo

* typo

* typo

* move checksum db into its own section
2019-05-08 17:09:07 -07:00
marpio
9974c16093 pkg/stash: Add Azure Blob implementation (#1162)
* add azblob sf stasher

* use http status const

* rm line

* cleanup, comments

* add test

* fix test

* skip test it no account key provided

* fix stash

* introduce stash timeout
2019-04-01 21:53:59 -07:00
Marwan Sulaiman
081ec9126e pkg/stash: Add GCS implementation (#1124)
* pkg/stash: Add GCS implementation

* fix docs
2019-03-13 11:07:07 -07:00
Marwan Sulaiman
fb9437ddff pkg/stash: implement a Redis lock for stashing (#1116)
* pkg/stash: implement a Redis lock for stashing

* fix tests

* fix op
2019-03-11 02:48:04 -04:00
Marwan Sulaiman
12ce2a6499 pkg/stash: add Etcd as a SingleFlight backend (#1070)
* pkg/stash: add Etcd as a SingleFlight backend

* fix config tests

* fmt

* pr fixes

* fix conflicts
2019-02-22 11:35:45 -08:00
Marwan Sulaiman
0d94af2503 catalog: clean up unused interfaces (#1027)
* catalog: clean up unused interfaces

* fix op name
2019-01-05 15:04:46 -05:00
Manu Gupta
3b621caa85 Move catalog handler out of download protocol (#1020)
* Move catalog handler out of download protocol

* Bring back logger

* update comment
2019-01-02 21:55:07 -08:00
Marwan Sulaiman
5870aeee8d Remove Buffalo (#1010)
* Remove Buffalo

* gofmt

* pr fixes

* fix subrouter

* bring back secure middleware + pr fixes

* better place for subrouter

* vendor
2018-12-22 20:24:25 -05:00
Tomasz Tomalak
fb696b2d84 Add prometheus metrics collectors for http handlers (#958)
* Add prometheus metrics exporter for http handlers

* Use prometheus from opencensus

* Add comment to unused func() param

* Add package names to operation description in observ package

* Sort exported/unexported functions
2018-12-20 10:19:22 +01:00
Audrius Karabanovas
154c993c42 Readiness probe (#942)
* Adding readiness endpoint for readinessProbe in k8s

* liveness and readiness probes added to deployment template

* Changing endpoint to /readyz, onelining checks

* Removing DNS check as that will be covered by storage.List() call
2018-11-22 18:14:23 -05:00
Marwan Sulaiman
132a75579b cmd/proxy: add /version endpoint to probe the server version (#908) 2018-11-16 10:07:48 -05:00
marpio
6af44242fb Fix list (#607)
* merge list from storage with the one from go list

* fix and rename

* move stuff to semver pkg

* fix gofmt

* move union out of semver pkg

* add tests

* fix err msg

* fix tests

* error handling

* error handling, go list refactoring

* fix list

* cleanup

* fix gofmt
2018-09-13 14:12:17 -07:00
Rohan Chakravarthy
0e470d0294 Plumb config - Latest (#627)
* switch proxy to config file

pull in single flight changes

* changes for single-flight

* intermediate stage. All tests passing. pkg still has env refs

* remove all env references

* delete config/env entirely

* fix failing tests

* create the config.toml file as part of dev setup

* create config file only if it doesn't exist

* update Dockerfiles to use config file

* move composing elements to the top

* verbose parameter naming

* newline

* add flag for config file path

* update docs with config file flag

* remove unnecessary nil check

* use filepath.join

* rename redis port to address

* fix path.join

* fix issues after merge

* add vendor dir
2018-09-11 15:04:20 -07:00
Marwan Sulaiman
ea96158f8f Athens: introduce Single Flight (#573)
* Athens: introduce singleflight

* fix ci

* small fixes

* Remove unnecessary method

* simplify folder structure

* dcoument stasher iface

* fixes

* Fix olympus

* Remove Version from Download Protocol

* fix olympus

* refactor fetcher

* consolodate wrapping styles

* fix olympus

* Further refactoring

* fix typo
2018-09-03 16:31:13 -04:00
Marwan Sulaiman
d749465e35 pkg/download: use worker pool to limit concurrent gogets (#524)
* pkg/download: use worker pool to limit concurrent gogets

* fix test closure

* use workers env
2018-08-20 11:30:12 -04:00
Marwan Sulaiman
493945c13a Athens: add health check endpoint (#514) 2018-08-19 16:34:46 -04:00
Marwan Sulaiman
1ac2cf1317 Proxy: remove unused arguments (#512)
* Proxy: remove unused arguments

* remove debugging info
2018-08-19 15:17:08 -04:00
Marwan Sulaiman
6b766c3f72 Download: introduce sane Entry defaults (#398) 2018-08-04 12:27:24 -04:00
Dinesh Kumar
85213f20b3 Goget Fetcher should error out if gobinpath is not valid (#377)
* Goget fetcher should error out if gobinpath is not valid

* Propogating the error from goget initialisation to main, to stop application

* wrapping errors with op, using exec.command(gobin).Run to verify gobin, clean up

* Inlining afero fs to goget call, and new go getfetcher

* Revert "Inlining afero fs to goget call, and new go getfetcher"

This reverts commit ae31fe6a2b.

* Fixing example test
2018-08-02 10:00:37 -04:00
Aaron Schlesinger
59d5d5ffac Cleaning up unused code (#352)
* removing pkg/repo

Fixes https://github.com/gomods/athens/issues/335

* removing the gomod parser
2018-07-30 14:06:17 -07:00
Marwan Sulaiman
add15e68cd download: clean up Kahona (#345) 2018-07-27 15:18:14 -07:00
Carolyn Van Slyck
fd7c1326d3 Backfill the cache on a miss (#342)
* add middlewares to fill the cache and to populate contexts with module and versions

* Carolyn tries to fix Aaron's code

* #DOINSTUFF

* updated env var

* fix all the things

* magic patch for olympus

* Add latest handler

* Remove deprecated return param

* go fmt all the things
2018-07-27 14:37:23 -07:00
Marwan Sulaiman
7b590b1885 download: add list from go cli (#336)
* download: add list from go cli

* download: include goget tests + hacky hack

* download: move dummyMod to pkg/module

* Olympus: pass dp and lggr to /list

* download: add Version to interface

* download: document Protocol
2018-07-27 11:56:32 -07:00
Marwan Sulaiman
0853f073f2 Athens: introduce pkg/errors (#320)
* Athens: introduce pkg/errors

* errors: fix Ops loop

* pkg/errors: introduce M and V types to get rid of unstable parsing

* fix build

* errors: fix text + add tests

* pr updates
2018-07-25 13:18:58 -05:00
Marwan Sulaiman
084e906804 Athens: remove c.Error (#278)
* Athens: remove c.Error

* Download: return err string on VersionModuleHandler
2018-07-15 19:40:45 -07:00
Marwan Sulaiman
650577a6da Athens: introduce log package (#274)
* Athens: introduce log package

* log: add buffalo doc note

* log: add cloud runtime based formatting

* log: add log level to constructor

* log: remove nil err from fmtBuffaloErr

* log: use switch statement in buffaloFormatter.Format

* log: rearrange .go files

* log: change cloudruntime development to none

* Olympus: add buffalo logger
2018-07-15 11:13:02 -04:00