Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensible default quota and storage systems when MySQL support unavailable #3679

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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
Loading