Skip to content

Commit

Permalink
Sensible default quota and storage systems when MySQL support unavail…
Browse files Browse the repository at this point in the history
…able (google#3679)

* Choose sensible default quota and storage systems when MySQL support unavailable

* Update CHANGELOG.md
  • Loading branch information
robstradling authored Nov 22, 2024
1 parent 92bc601 commit 5209ff1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Misc

* Control included quota and storage providers via build tags by @robstradling in https://github.com/google/trillian/pull/3664
* Sensible default quota and storage systems when MySQL support unavailable by @robstradling in https://github.com/google/trillian/pull/3679

## v1.6.1

Expand Down
30 changes: 30 additions & 0 deletions cmd/internal/provider/default_systems.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package provider

import (
"slices"

"github.com/google/trillian/quota"
"github.com/google/trillian/storage"
)

var (
DefaultQuotaSystem string
DefaultStorageSystem string
)

func init() {
defaultProvider := "mysql"
providers := storage.Providers()
if len(providers) > 0 && !slices.Contains(providers, defaultProvider) {
slices.Sort(providers)
defaultProvider = providers[0]
}
DefaultStorageSystem = defaultProvider

providers = quota.Providers()
if len(providers) > 0 && !slices.Contains(providers, defaultProvider) {
slices.Sort(providers)
defaultProvider = providers[0]
}
DefaultQuotaSystem = defaultProvider
}
6 changes: 3 additions & 3 deletions cmd/trillian_log_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"k8s.io/klog/v2"

// Register supported storage and quota providers.
_ "github.com/google/trillian/cmd/internal/provider"
"github.com/google/trillian/cmd/internal/provider"
)

var (
Expand All @@ -58,10 +58,10 @@ var (
etcdService = flag.String("etcd_service", "trillian-logserver", "Service name to announce ourselves under")
etcdHTTPService = flag.String("etcd_http_service", "trillian-logserver-http", "Service name to announce our HTTP endpoint under")

quotaSystem = flag.String("quota_system", "mysql", fmt.Sprintf("Quota system to use. One of: %v", quota.Providers()))
quotaSystem = flag.String("quota_system", provider.DefaultQuotaSystem, fmt.Sprintf("Quota system to use. One of: %v", quota.Providers()))
quotaDryRun = flag.Bool("quota_dry_run", false, "If true no requests are blocked due to lack of tokens")

storageSystem = flag.String("storage_system", "mysql", fmt.Sprintf("Storage system to use. One of: %v", storage.Providers()))
storageSystem = flag.String("storage_system", provider.DefaultStorageSystem, fmt.Sprintf("Storage system to use. One of: %v", storage.Providers()))

treeGCEnabled = flag.Bool("tree_gc", true, "If true, tree garbage collection (hard-deletion) is periodically performed")
treeDeleteThreshold = flag.Duration("tree_delete_threshold", serverutil.DefaultTreeDeleteThreshold, "Minimum period a tree has to remain deleted before being hard-deleted")
Expand Down
6 changes: 3 additions & 3 deletions cmd/trillian_log_signer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import (
"k8s.io/klog/v2"

// Register supported storage and quota providers.
_ "github.com/google/trillian/cmd/internal/provider"
"github.com/google/trillian/cmd/internal/provider"
)

var (
Expand All @@ -69,12 +69,12 @@ var (
lockDir = flag.String("lock_file_path", "/test/multimaster", "etcd lock file directory path")
healthzTimeout = flag.Duration("healthz_timeout", time.Second*5, "Timeout used during healthz checks")

quotaSystem = flag.String("quota_system", "mysql", fmt.Sprintf("Quota system to use. One of: %v", quota.Providers()))
quotaSystem = flag.String("quota_system", provider.DefaultQuotaSystem, fmt.Sprintf("Quota system to use. One of: %v", quota.Providers()))
quotaIncreaseFactor = flag.Float64("quota_increase_factor", log.QuotaIncreaseFactor,
"Increase factor for tokens replenished by sequencing-based quotas (1 means a 1:1 relationship between sequenced leaves and replenished tokens)."+
"Only effective for --quota_system=etcd.")

storageSystem = flag.String("storage_system", "mysql", fmt.Sprintf("Storage system to use. One of: %v", storage.Providers()))
storageSystem = flag.String("storage_system", provider.DefaultStorageSystem, fmt.Sprintf("Storage system to use. One of: %v", storage.Providers()))

preElectionPause = flag.Duration("pre_election_pause", 1*time.Second, "Maximum time to wait before starting elections")
masterHoldInterval = flag.Duration("master_hold_interval", 60*time.Second, "Minimum interval to hold mastership for")
Expand Down

0 comments on commit 5209ff1

Please sign in to comment.