Giter Club home page Giter Club logo

up's Introduction

docker compose based Storj environment

storj-up is a swiss-army tool to create / customize Storj clusters with the help of docker compose (not just storagenode but all satellite and edge services).

This is useful for Storj development and not for Storage Node operator.

Getting started

It is recommended that you use Docker Compose V2 as well as enable Docker BuildKit builds for all features to work correctly.

Install the tool:

go install storj.io/storj-up@latest

Go to an empty directory and initialize docker compose:

storj-up init db,core,admin,edge,minimal

If you're on a Mac, or running on a remote box, you'll need to tell some services your IP address:

storj-up env setenv satellite-api STORJ_CONSOLE_GATEWAY_CREDENTIALS_REQUEST_URL=http://ipaddr:8888
storj-up env setenv satellite-api STORJ_CONSOLE_LINKSHARING_URL=http://ipaddr:9090
storj-up env setenv authservice STORJ_ENDPOINT=http://ipaddr:9999
storj-up env setenv linksharing STORJ_PUBLIC_URL=http://ipaddr:9090

Start the cluster:

docker compose up -d
docker compose ps

You can check the generated credentials with:

storj-up credentials

You can set the required environment variables with eval $(storj-up credentials -e) (at least on Linux/OSX)

Or you can update the credentials of local rclone setup with storj-up credentials -w

More features

While the basic storj-up init command will give you a barebones local Storj network, which can be used for testing file upload and download, you can also add more services to the network for testing things like the edge services, and admin API console. Just add the desired services to the init command, for example

storj-up init minimal,satellite-core,satellite-admin,edge,db,billing

Will give you all the services required to test the Web UI, the Admin API, and even the billing services. Additionally, there are dedicated subcommands to modify the services within the docker-compose.yaml file easily. The generic form of these commands:

storj-up <subcommand> <selector> <argument>

Here selector can be either a service (like storagenode) or a name of a service group. (like edge). To find out all the groups, please use storj-up recipes

Other services include:

  • mailserver: a mock smtp server that can be used to view emails sent from the satellite at localhost:1080

Example: Building specific binaries based on a Gerrit change

After running storj-up init, you can use the following command to replace binaries based on a specific Gerrit changeset:

storj-up build remote gerrit -f refs/changes/65/6365/1 satellite-api satellite-core satellite-admin uplink

You will need to change refs/changes/65/6365/1 to the Gerrit patchset you want to use, and change the binaries that follow it based on what you are trying to replace.

Then, run docker compose build followed by docker compose up in order to spin everything up.

Example: Modify the configuration variable of a service

You can modify configuration variable by setting the environment variables:

storj-up env setenv satellite-api STORJ_CONSOLE_CREDENTIALS_REQUEST_URL=http://myservername

Available configuration (for selected services) can be listed by storj-up configs <service>, for example:

storj-up configs storagenode

STORJ_IDENTITY_CERT_PATH                                               path to the certificate chain for this identity (default: $IDENTITYDIR/identity.cert)
STORJ_IDENTITY_KEY_PATH                                                path to the private key for this identity (default: $IDENTITYDIR/identity.key)
STORJ_SERVER_CONFIG_REVOCATION_DBURL                                   url for revocation database (e.g. bolt://some.db OR redis://127.0.0.1:6378?db=2&password=abc123) *(default: bolt://$CONFDIR/revocations.db)
STORJ_SERVER_CONFIG_PEER_CAWHITELIST_PATH                              path to the CA cert whitelist (peer identities must be signed by one these to be verified). this will override the default peer whitelist
...

Example: Using your local satellite installation rather than a remote change

Backend

After running storj-up init, you can use the following command to replace binaries from your local machine:

On Linux:

This will mount the correct binaries from your $GOPATH/bin

storj-up local-bin satellite-core satellite-admin satellite-api

Mac and Windows:

This will mount the correct binaries from your $GOPATH/bin/linux_amd64

storj-up local-bin -s linux_amd64 satellite-core satellite-admin satellite-api

You will also need to cross-compile to Linux when you update your local satellite, e.g.

GOOS=linux GOARCH=amd64 go install -race ./cmd/satellite

Then if you are not currently running the containers, run

docker compose up -d

to start the containers.

Or run

docker restart up-satellite-core-1 up-satellite-api-1 up-satellite-admin-1

(the "up" prefix may be different depending on the location of your docker-compose.yaml file)

to restart already-running containers.

Local Development Environment

During development, changes to the code will require building a new binary and restarting the containers. To simplify this workflow during development, you can supply ENV variables either in the service config or at the OS level to automatically rebuild the binaries and restart the containers when you use the storj-up start command.

storj-up local-bin satellite-core satellite-admin satellite-api
storj-up env set satellite-core satellite-admin satellite-api STORJ_UP_LOCAL_BINARY_SOURCE=<path_to_storj>/cmd/satellite
storj-up start

This will build the source specified and then start the services. Make sure your local binary is mounted in the service using the storj-up local-bin command and that the location mounted is the same location as your default go/bin directory. If you are not on a Linux OS, the command will automatically attempt to cross-compile the source.

If you wish to always use a local binary across all storj-up instances, you can also set the ENV variable at the OS level STORJ_UP_LOCAL_<service_name>=<path_to_build_service> for a particular service. After setting this, anytime you have a local binary mounted for this service, you can use storj-up start to rebuild the binary and start the services.

Remote Development Environment

If you are developing on a remote machine, or you are using a remote docker daemon on your local machine, you can set the STORJ_DOCKER_HOST environment variable to point to the location of the docker daemon you're using. The IP or hostname you assign to the env variable will be used by the services for all external API connections. For example,

  • local dev remote daemon: Set the STORJ_DOCKER_HOST environment variable on the local machine to the IP or hostname of the remote docker daemon you're using.

  • remote dev and daemon: Set the STORJ_DOCKER_HOST environment variable on the remote machine to the IP or hostname of that machine. Do not use localhost.

Without this setting, or manually adjusting the service config, localhost will be used for all external API calls, and may return errors when trying to use the services.

Frontend

Here, you will need to attach your local web/satellite directory as a volume. Do this with

storj-up local-ws /path/to/storj/web/satellite/

When you run npm run build from your local web/satellite directory, the webapp should be automatically updated, no need to restart any docker containers.

The exception is if you are making a frontend change in web/satellite that requires a corresponding backend change. In this case, you will need to also run go install ./cmd/satellite followed by a restart of the relevant containers (see command at the end of the "Backend" section above).

Interacting with and resetting your Satellite database

docker compose ps will list your running containers. Find the one that looks like <prefix>-cockroach-1

To run sql on this container,

docker exec -it <prefix>-cockroach-1 ./cockroach sql --insecure

show databases; will list all the databases you can query from. master will contain most satellite tables, and metainfo contains... metainfo tables.

use <database>; will switch to one of those.

show tables; will give a list of tables accessible from the selected database.

Then you can run queries like update users set project_limit=3 where ...;

Resetting

There is a chance that due to going back and forth between database versions will result in errors that look like this in your logs:

up-satellite-api-1    | 2022-05-16T17:34:53.916Z        DEBUG   process/exec_conf.go:403        Unrecoverable error     {"error": "Error checking version for satellitedb: validate db version mismatch: expected 196 != 195\n\tstorj.io/storj/private/migrate.(*Migration).ValidateVersions:138\n\tstorj.io/storj/satellite/satellitedb.(*satelliteDB).CheckVersion:138

If you are okay with starting with a fresh satellite database, this can be accomplished by running

docker compose down -v

up's People

Contributors

azdagron avatar dlamarmorgan avatar egonelbre avatar elek avatar halkyon avatar ifraixedes avatar ihaid avatar jewharton avatar jtolio avatar kaloyan-raev avatar littleskunk avatar mobyvb avatar nadimhq avatar neo-cypher avatar profclems avatar rikysya avatar thepaul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

up's Issues

Feature request: dynamic default ENV variables

Extend the current feature that allows you to add services to the compose file, by also allowing that command to add ENV variables to other services within the compose file.

For example, if I use storj-up add billing to add storjscan and geth to the compose file, also add the required ENV variables for testing billing related functionality, like the ones needed for stripe testing.

Acceptance Criteria:

  • for our current recipes ensure they have the right ENV being set in the files
    • for example, the billing receipt should have storjscan, geth, etc..

Start using version tags

I started to use storj-up a week ago for uplink-rust CI; see storj-thirdparty/uplink-rust#28

It worked perfectly until I merged storj-thirdparty/uplink-rust#28 into the main branch and realized that those commits didn't pass the CI, but the CI passed finely with the PR.

I was digging into it and I realized that the CI of storj-up doesn't pass either with the same issue 429 too many requests. In the case of uplink-rust, the error is returned when running the storj-up credentials` command.

If we would like to use storj-up in CIs, we have to start to consider tagging the repository with version tags or keeping the main branch always green and backward compatible, although I believe that the second is harder.

For now, I solved the issue using a specific commit, however, it isn't ideal storj-thirdparty/uplink-rust#32

Create tickets for missing features that are used by storj-sim

Currently we are using storj-up and storj-sim side-by-side, however only one of them should be sufficient. Let's figure out the things we need to drop storj-sim as a tool.

First, we need to figure out which features are still missing in storj-up. Especially around scenarios involving the tests in scripts.

Acceptance Criteria:

  • Create tickets for each of the missing features in storj/up

Things to make work:

  • #61
  • #62
  • #63
    • (maybe a testplanet like thing instead?) -- or maybe it's not needed
  • #64

Things to replace storj-sim in github.com/storj/storj:

Things to replace storj-sim in github.com/storj/gateway-(st/mt):

Things to replace in uplink:

Go install failed with "cannot use "quic-go doesn't build on Go 1.19 yet""

On a fresh Mac I went to install storj-up after installing the latest version of Go (1.19). The install failed with:

➜  up git:(main) go install storj.io/storj-up@latest
# github.com/lucas-clemente/quic-go/internal/qtls
../../../go/pkg/mod/github.com/lucas-clemente/[email protected]/internal/qtls/go119.go:6:13: cannot use "quic-go doesn't build on Go 1.19 yet." (untyped string constant) as int value in variable declaration

Happy to test fixes if I can.

storj-up v2.0

This is a full refactor of storj up it can be used to generate multiple runtime descriptions.
This is a feature branch that is supposed to be merged. it has a lot of comments and 1 small feature is missing.
Does not support custom config file configuration.
The biggest challenge with this patch is to get reviewers since its such a huge change.

Acceptance Criteria:

  • fix any issues that arise from code reviews or testing
  • get this patch merged
  • test with storjscan
  • resolve merge/ build conflicts.

https://review.dev.storj.io/c/storj/up/+/8629

Testing and support of Storj-up V2

AC:

  • core and Admin were missing from Storj up
  • Add them to the docker-compose file

storj v2 lets you run as a script or as a nomad so we need to add them to that as well.

Add "start" command which does binary builds before starting docker, when necessary

Create a new command such as storj-up start which

  • checks for an environment variable such as STORJ_UP_LOCAL_STORJ or STORJ_UP_LOCAL_GATEWAY
  • for each image in docker-compose.yaml which has volumes mounted for using local binaries, if the respective environment variable is set, attempt to build binaries
  • this will be a normal go install on linux, or a cross compile for other operating systems. See README for specific commands
  • then, start docker with docker-compose up -d

From a user perspective, I would like to be able to run a single command on any operating system, and if my environment is configured correctly, the build and run steps will be done.

Add tracing to Storj-up

Add tracing to storj-up to allow for easily turning on distributed tracing and spinning up the required docker containers for the front end to view the data.

How to use the storj-up binary inside of a container to retrieve the credentials?

With the v1 release storj-up binary is present inside the containers, however, the storj-up credentials command doesn't seem to work.

That's the only command that the integration tests need.

The error is the following

docker compose exec satellite-api storj-up credentials -e
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused
#Server is not yet available. Retry in 1 sec... rpc: dial tcp 127.0.0.1:7777: connect: connection refused

If I'm not mistaken that's because inside a container the other containers run in the docker subnetwork and they are not mapped to the container localhost.

I'm looking for a workaround or to know if the implementation can be changed in a way that the command work when it runs inside of a container.

Add nomad support for locally mounting binaries and web static and dist directories

Currently docker compose with storj-up allows for local dev testing of mounted binaries and directories using the volume mounts. Nomad supports a similar capability using "host-volume" and volume_mount.
Acceptance Criteria:

  • Add support to storj-up to create these mounts in nomad tasks to allow for easy local development using nomad.

Update `local-ws` to support storagenode and multinode dashboards

Currently using storj-up local-ws command will add the required mounts for front end development of the satellite UI. This command should be expanded to allow for specifying which front end you would like to mount, so that it can also include the storagenode and multinode dashboards.

arm64 images

When running the Storj network on Mac M1s, storj-up attempts to run amd64 images which only works when you have the qemu emulation tools installed. It would be nice if we had arm64 images for storj-up to remove some layers of virtualization and simplify debugging.

Storj-up import usage history

Create a PR on top of https://review.dev.storj.io/c/storj/up/+/6843

To import usage data from https://storjlabs.atlassian.net/browse/SM-2743

For the beginning just import one test. We need to test out which tables are important. I assume we need bucket_bandwidth_rollups (important for invoices), bucket_storage_tallies (important for invoices), project_bandwidth_rollups (important for usage limits) storj/projectaccounting.go at main · storj/storj

For traffic the action mapping shoud be:
1 = customer uploads
2 = customer download
3 = audits
4 = repair upload
5 = repair download

Config change for local test.

# indicates if new project dashboard should be used
console.new-project-dashboard: true

Enable build storjscan from main branch

root@datengrab:~/github/up# storj-up build remote github -b main storjscan
Error: invalid service selector , please run `storj-up services` to find supported values
Usage:
  storj-up build remote github <selector> [flags]

Flags:
  -b, --branch string   The branch to checkout and build (default "main")
  -h, --help            help for github

Global Flags:
      --config string   config file (default is $HOME/.reminderctl.yaml)

Error: invalid service selector , please run `storj-up services` to find supported values

Add stripe-mock to storj up

Use Stripe-Mock for easy integration testing.
Stripe-Mock is stateless, if you want it to respond a certain way because of some state you would need to add that into the test.

Acceptance Criteria:

  • write an integration test with stripe mock basically as a POC with storj/up.
    • this would mean that stripe-mock is now integrated with Storj/up and we would be able to send requests to stripe-mock and get the correct responses.

Ensure we can stop redis while everything continues running (scripts/tests/redis).

Some tests in storj respository in scripts/tests/redis require stopping redis in the background to see how the system deals with redis going down.

An alternative would be to convert those tests to make it happen inside regular testsuite by implementing a custom listener and stopping that. This might be more beneficial, because it's easier to maintain.

storj-up generate invoice

Similar to #17

All we need is some fake usage for the previous month in order to be able to run the invoice command. The fake data doesn't need to be fancy. It can be a single tally result with 720 TBh of used space. -> 1 TB stored for a month.

storj-up create user with older creation date

For invoice generation we insert fake usage into the database. The problem we insert with an old timestampe in order to be able to create the invoice for the previous month like we would in production. This only works if we manipulate the creation date of the user. It would be great it storj-up could create the user with an timestamp 90 days back. That would give us enough room to insert fake data.

storj-up credentials --email [email protected]

func (ce *ConsoleEndpoint) tryCreateAndActivateUser(ctx context.Context, email string) error {

Doesn't generate right environment variables for uplinkng (which is now uplink)

~/tmp% docker compose up -d
(snip output)
~/tmp% eval $(storj-up credentials -e)
~/tmp% uplink mb sj://abc
No accesses configured. Use 'access save' or 'access create' to create one
        main.(*external).GetAccessInfo:92
        main.(*external).OpenAccess:67
        main.(*external).OpenProject:30
        main.(*cmdMb).Execute:40
        main.(*external).Wrap:123
        github.com/zeebo/clingy.(*Environment).dispatchDesc:126
        github.com/zeebo/clingy.(*Environment).dispatch:53
        github.com/zeebo/clingy.Environment.Run:34
        main.main:25
        runtime.main:255

This seemed to work fine before I updated my storj repo and got the uplinkng -> uplink rename.

go generate stringer error

running a go generate gives the error

stringer: internal error: package "fmt" without types was imported from "storj.io/storj-up/pkg/common"

and does not update the key_string.go file with any changes.

Wrong path for `storj-up localbin -s s:\xyz satellite-api`

Running locally:

storj-up local-bin -s "s:\core\storj\cmd\satellite" satellite-core satellite-admin satellite-api

Ended up creating a compose file:

    volumes:
    - type: bind
      source: "F:\\Go/bin/s:\\core\\storj\\cmd\\satellite/satellite"
      target: /var/lib/storj/go/bin/satellite
      bind:
        create_host_path: true

Similarly, if there already exists such a volume mount, it adds a new one rather than replacing the existing one.

Add commands to mount front end static and dist directories

When making front end dev changes, users are required to mount the static (storj/web/satellite/static) and dist (storj/web/satellite/dist) directories as volumes when testing locally. It would be better to add a storj-up command to mount these directories to the appropriate service (satellite-api).

Add multinode nomad support

Currently, the Nomad HCL file generated by Storj-up will only work if the Nomad cluster has a single node with enough resources to run everything on the same node. This is due to the structure of the HCL file (only a single task group), as well as assumptions made in the config (localhost for several ENV variables.).

This should be updated to be more flexible and separate out unique services to their own task group. This will allow nomad cluster with multiple nodes to spread out the load.

Acceptance Criteria:

  • if you have a nomad cluster with multiple machines then generating a nomad HCL file should allow you to run the system like normal.
  • BONUS: anytime nomad cluster gets spun up which machine gets to run each server can change. make it so that you can specify which machine runs each server.
    • make it so that we can have some level of consistency with the service web GUI ip/ ports.
    • some potential solutions could be using service mesh, or reverse proxy, or consul

Walkthrough for common things

Let's create a guide on how to use storj-up and how to do the most common tasks people need to do. Each of these can be converted into a separate issue for tracking purposes.

  • Walkthrough: Basic Docker setup
  • Walkthrough: Basic Nomad setup
  • Walkthrough: Basic Native setup
  • Walkthrough: Running the system and doing exploratory testing on frontend and with uplink.
  • Walkthrough: Running a system based on gerrit / github commit.
  • Walkthrough: Customizing the system for your needs
    • use different (older versions without build)
    • scale up to 50 storagenodes with different versions
    • find configuration parameters + change them
  • Walkthrough: Starting up system with simulated data
  • Walkthrough: Fixing an uplink issue and testing against the storj-up
  • Walkthrough: Fixing a satellite bug
  • Walkthrough: Fixing satellite frontend issue (with backend) #54
  • Walkthrough: Fixing a storagenode bug
  • Walkthrough: Fixing storagenode frontend (with backend)
  • Walkthrough: Fixing a gateway issue
  • Walkthrough: Fixing a multinode issue
  • Walkthrough: Saving the state of the system to reproduce an issue on another system.
  • Walkthrough: debug one of the components from local environment
  • Walkthrough: use admin API

Also, figure out whether there's something missing from this list.

This can be done as documentation or as a video per bullet-point. Also, avoid creating videos for things that are still not complete.

credentials command with -e flag should export all the data that the command does without it

The credentials command with -e flag should export all the data that the command does without it.

Why? because I'm using it for testing the Uplink-Rust and for testing and I use the command with -e flag, however, not all the data that the command outputs without the -e flag it's outputted with it.

My current case is that I need the API key to test some method of the acces grant struct.

Alternatively, the credentials command could have an option to print the output in a commonly used format, JSON, TOML, or YAML, so it can be written to a file and then easily read it programmatically. Despite this alternative, the one proposed above is handier when using a nix OS and it doesn't require to use of any external library to parse a file.

uplink from host to storagenode containers doesn't work on windows

Due to the docker desktop limitation on windows
Docker Desktop can’t route traffic to Linux containers.
uplink fails when it is used from a windows host to a linux container.

The object browser in the satellite GUI does seem to work ok, likely because it uses the gateway to send the data, which is exposed directly to the host via port mapping.

Acceptance Criteria

  • we have the ability to use uplink directly from the host to the storage nodes running in docker containers.

Add environment file with all possible configs, similar to storj-sim

storj-sim generates config.yaml files for satellites and storagenodes which contain every possible config that can be changed. They are all commented out by default, but you can simply uncomment a line, change the value, and save. Then, the change will go into affect as soon as you restart storj-sim.

With storj-up, you need to know the name of the flag in advance, then derive a storj-up-specific name. For example, reputation.flush-interval would become STORJ_REPUTATION_FLUSH_INTERVAL

AC:

  • Add a file (or files) alongside docker-compose.yaml which contains all possible configs, commented out by default. I should be able to uncomment a line, change the value, and it should take effect after restarting the relevant container(s)

Add a like thing for testing custom tools

storj-sim network test example.sh is a nice quick way to tests binaries with a configured environment. Implement something similar for storj-up, e.g. storj-up test example.sh. Note, the target might be a shell script or a binary on the local system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.