Skip to content

Commit

Permalink
feat: set failover to default false. Update readme (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-projectn committed Aug 23, 2023
1 parent e2c26e0 commit c582e88
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ Traffic splitting provides a mechanism to precisely control how traffic is distr

Traffic splitting configuration is managed through the `client-behavior-params` ConfigMap in the Bolt (Crunch) Kubernetes cluster. This ConfigMap can be edited on your behalf by the Granica team or by you via `custom.vars` or directly editing the ConfigMap (the latter option is not recommended as it can cause state drift.) For further guidance on the traffic splitting configuration, reach out to the Granica team.

### Failover
### Fallback on 404
If sidekick can't find your object in Bolt, sidekick tries to find the object in S3. This happens transparently to the client, and it doesn't need any client retries.

Sidekick automatically failovers the request to s3 if the bolt request fails. For example This is useful when the object does not exist in bolt yet.
You can disable failover by passing a flag or setting a ENV variable:
### Failover
Sidekick has a failover mechanism that comes into play when there are network failures or when Bolt returns 500s
In these situations sidekick returns a 500 to the client, that may cause the client to retry. The retry request will make sidekick request Bolt again but a different endpoint. Eventually, either client will exhaust all retries to sidekick or sidekick will exhaust all replica endpoints. When one of these happens, the request has failed
The above failover mechanism is recommended, but can be changed. Sidekick can instead failover to S3 transparently to the Client immediately on noticing a network failure or 500 error. This can be set with either by a command line argument or environment variable

```bash
# Using flag
Expand All @@ -46,12 +49,10 @@ go run main serve --failover=false

```bash
# Using env variable
export SIDEKICK_BOLTROUTER_FAILOVER=true
export SIDEKICK_BOLTROUTER_FAILOVER=true # Not recommended
go run main serve
```

In the context of traffic splitting, if S3 is tried first due to the defined traffic distribution, Sidekick will automatically failover to Bolt if the initial request to S3 returns a `404 NoSuchKey`. This guarantees that the requested object can still be retrieved from Bolt, preserving the desired traffic splitting behavior and ensuring data availability and consistency.

### Local

You can run sidekick directly from the command line:
Expand Down
4 changes: 2 additions & 2 deletions boltrouter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Config struct {
// Enable pass through in Bolt.
Passthrough bool `yaml:"Passthrough"`

// Enable failover to a AWS request if the Bolt request fails or vice-versa.
// Enable failover to a AWS request if the Bolt request fails
Failover bool `yaml:"Failover"`

// Enable NoFallback404 to disable fallback on 404 response code from AWS request to Bolt or vice-versa.
Expand All @@ -35,7 +35,7 @@ type Config struct {
var DefaultConfig = Config{
Local: false,
Passthrough: false,
Failover: true,
Failover: false,
NoFallback404: false,
BoltEndpointOverride: "",
CrunchTrafficSplit: CrunchTrafficSplitByObjectKeyHash,
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func initServerFlags(cmd *cobra.Command) {
cmd.Flags().BoolP("local", "l", false, "Run sidekick in local (non cloud) mode. This is mostly use for testing locally.")
cmd.Flags().String("bolt-endpoint-override", "", "Specify the local bolt endpoint with port to override in local mode. e.g: <local-bolt-ip>:9000")
cmd.Flags().Bool("passthrough", false, "Set passthrough flag to bolt requests.")
cmd.Flags().BoolP("failover", "f", true, "Enables aws request failover if bolt request fails.")
cmd.Flags().BoolP("failover", "f", false, "Enables aws request failover if bolt request fails.")
cmd.Flags().String("crunch-traffic-split", "objectkeyhash", "Specify the crunch traffic split strategy: random or objectkeyhash")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestServeCmdConfig(t *testing.T) {
cfg := getBoltRouterConfig(testServeCmd)
assert.Equal(t, false, cfg.Local)
assert.Equal(t, false, cfg.Passthrough)
assert.Equal(t, true, cfg.Failover)
assert.Equal(t, false, cfg.Failover)
})

t.Run("EnvOnly", func(t *testing.T) {
Expand Down

0 comments on commit c582e88

Please sign in to comment.