Skip to content

Commit decf611

Browse files
committed
Support application credential auth for Openstack swift
Signed-off-by: SungJin1212 <[email protected]>
1 parent d3778ce commit decf611

File tree

6 files changed

+119
-37
lines changed

6 files changed

+119
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [FEATURE] Ruler: Minimize chances of missed rule group evaluations that can occur due to OOM kills, bad underlying nodes, or due to an unhealthy ruler that appears in the ring as healthy. This feature is enabled via `-ruler.enable-ha-evaluation` flag. #6129
99
* [FEATURE] Store Gateway: Add an in-memory chunk cache. #6245
1010
* [FEATURE] Chunk Cache: Support multi level cache and add metrics. #6249
11+
* [ENHANCEMENT] OpenStack Swift: Add application credential configs for Openstack swift object storage backend. #6255
1112
* [ENHANCEMENT] Ingester: Add `blocks-storage.tsdb.wal-compression-type` to support zstd wal compression type. #6232
1213
* [ENHANCEMENT] Query Frontend: Add info field to query response. #6207
1314
* [ENHANCEMENT] Query Frontend: Add peakSample in query stats response. #6188

docs/blocks-storage/querier.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,18 @@ blocks_storage:
446446
# CLI flag: -blocks-storage.swift.auth-url
447447
[auth_url: <string> | default = ""]
448448

449+
# OpenStack Swift application credential ID.
450+
# CLI flag: -blocks-storage.swift.application-credential-id
451+
[application_credential_id: <string> | default = ""]
452+
453+
# OpenStack Swift application credential name.
454+
# CLI flag: -blocks-storage.swift.application-credential-name
455+
[application_credential_name: <string> | default = ""]
456+
457+
# OpenStack Swift application credential secret.
458+
# CLI flag: -blocks-storage.swift.application-credential-secret
459+
[application_credential_secret: <string> | default = ""]
460+
449461
# OpenStack Swift username.
450462
# CLI flag: -blocks-storage.swift.username
451463
[username: <string> | default = ""]

docs/blocks-storage/store-gateway.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,18 @@ blocks_storage:
543543
# CLI flag: -blocks-storage.swift.auth-url
544544
[auth_url: <string> | default = ""]
545545

546+
# OpenStack Swift application credential ID.
547+
# CLI flag: -blocks-storage.swift.application-credential-id
548+
[application_credential_id: <string> | default = ""]
549+
550+
# OpenStack Swift application credential name.
551+
# CLI flag: -blocks-storage.swift.application-credential-name
552+
[application_credential_name: <string> | default = ""]
553+
554+
# OpenStack Swift application credential secret.
555+
# CLI flag: -blocks-storage.swift.application-credential-secret
556+
[application_credential_secret: <string> | default = ""]
557+
546558
# OpenStack Swift username.
547559
# CLI flag: -blocks-storage.swift.username
548560
[username: <string> | default = ""]

docs/configuration/config-file-reference.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,18 @@ swift:
702702
# CLI flag: -alertmanager-storage.swift.auth-url
703703
[auth_url: <string> | default = ""]
704704

705+
# OpenStack Swift application credential ID.
706+
# CLI flag: -alertmanager-storage.swift.application-credential-id
707+
[application_credential_id: <string> | default = ""]
708+
709+
# OpenStack Swift application credential name.
710+
# CLI flag: -alertmanager-storage.swift.application-credential-name
711+
[application_credential_name: <string> | default = ""]
712+
713+
# OpenStack Swift application credential secret.
714+
# CLI flag: -alertmanager-storage.swift.application-credential-secret
715+
[application_credential_secret: <string> | default = ""]
716+
705717
# OpenStack Swift username.
706718
# CLI flag: -alertmanager-storage.swift.username
707719
[username: <string> | default = ""]
@@ -981,6 +993,18 @@ swift:
981993
# CLI flag: -blocks-storage.swift.auth-url
982994
[auth_url: <string> | default = ""]
983995

996+
# OpenStack Swift application credential ID.
997+
# CLI flag: -blocks-storage.swift.application-credential-id
998+
[application_credential_id: <string> | default = ""]
999+
1000+
# OpenStack Swift application credential name.
1001+
# CLI flag: -blocks-storage.swift.application-credential-name
1002+
[application_credential_name: <string> | default = ""]
1003+
1004+
# OpenStack Swift application credential secret.
1005+
# CLI flag: -blocks-storage.swift.application-credential-secret
1006+
[application_credential_secret: <string> | default = ""]
1007+
9841008
# OpenStack Swift username.
9851009
# CLI flag: -blocks-storage.swift.username
9861010
[username: <string> | default = ""]
@@ -4744,6 +4768,18 @@ swift:
47444768
# CLI flag: -ruler-storage.swift.auth-url
47454769
[auth_url: <string> | default = ""]
47464770

4771+
# OpenStack Swift application credential ID.
4772+
# CLI flag: -ruler-storage.swift.application-credential-id
4773+
[application_credential_id: <string> | default = ""]
4774+
4775+
# OpenStack Swift application credential name.
4776+
# CLI flag: -ruler-storage.swift.application-credential-name
4777+
[application_credential_name: <string> | default = ""]
4778+
4779+
# OpenStack Swift application credential secret.
4780+
# CLI flag: -ruler-storage.swift.application-credential-secret
4781+
[application_credential_secret: <string> | default = ""]
4782+
47474783
# OpenStack Swift username.
47484784
# CLI flag: -ruler-storage.swift.username
47494785
[username: <string> | default = ""]
@@ -5031,6 +5067,18 @@ swift:
50315067
# CLI flag: -runtime-config.swift.auth-url
50325068
[auth_url: <string> | default = ""]
50335069

5070+
# OpenStack Swift application credential ID.
5071+
# CLI flag: -runtime-config.swift.application-credential-id
5072+
[application_credential_id: <string> | default = ""]
5073+
5074+
# OpenStack Swift application credential name.
5075+
# CLI flag: -runtime-config.swift.application-credential-name
5076+
[application_credential_name: <string> | default = ""]
5077+
5078+
# OpenStack Swift application credential secret.
5079+
# CLI flag: -runtime-config.swift.application-credential-secret
5080+
[application_credential_secret: <string> | default = ""]
5081+
50345082
# OpenStack Swift username.
50355083
# CLI flag: -runtime-config.swift.username
50365084
[username: <string> | default = ""]

pkg/storage/bucket/swift/bucket_client.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,29 @@ import (
99
)
1010

1111
// NewBucketClient creates a new Swift bucket client
12-
func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) {
12+
func NewBucketClient(cfg Config, _ string, logger log.Logger) (objstore.Bucket, error) {
1313
bucketConfig := swift.Config{
14-
AuthVersion: cfg.AuthVersion,
15-
AuthUrl: cfg.AuthURL,
16-
Username: cfg.Username,
17-
UserDomainName: cfg.UserDomainName,
18-
UserDomainID: cfg.UserDomainID,
19-
UserId: cfg.UserID,
20-
Password: cfg.Password,
21-
DomainId: cfg.DomainID,
22-
DomainName: cfg.DomainName,
23-
ProjectID: cfg.ProjectID,
24-
ProjectName: cfg.ProjectName,
25-
ProjectDomainID: cfg.ProjectDomainID,
26-
ProjectDomainName: cfg.ProjectDomainName,
27-
RegionName: cfg.RegionName,
28-
ContainerName: cfg.ContainerName,
29-
Retries: cfg.MaxRetries,
30-
ConnectTimeout: model.Duration(cfg.ConnectTimeout),
31-
Timeout: model.Duration(cfg.RequestTimeout),
14+
AuthVersion: cfg.AuthVersion,
15+
AuthUrl: cfg.AuthURL,
16+
ApplicationCredentialID: cfg.ApplicationCredentialID,
17+
ApplicationCredentialName: cfg.ApplicationCredentialName,
18+
ApplicationCredentialSecret: cfg.ApplicationCredentialSecret,
19+
Username: cfg.Username,
20+
UserDomainName: cfg.UserDomainName,
21+
UserDomainID: cfg.UserDomainID,
22+
UserId: cfg.UserID,
23+
Password: cfg.Password,
24+
DomainId: cfg.DomainID,
25+
DomainName: cfg.DomainName,
26+
ProjectID: cfg.ProjectID,
27+
ProjectName: cfg.ProjectName,
28+
ProjectDomainID: cfg.ProjectDomainID,
29+
ProjectDomainName: cfg.ProjectDomainName,
30+
RegionName: cfg.RegionName,
31+
ContainerName: cfg.ContainerName,
32+
Retries: cfg.MaxRetries,
33+
ConnectTimeout: model.Duration(cfg.ConnectTimeout),
34+
Timeout: model.Duration(cfg.RequestTimeout),
3235

3336
// Hard-coded defaults.
3437
ChunkSize: swift.DefaultConfig.ChunkSize,

pkg/storage/bucket/swift/config.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,27 @@ import (
77

88
// Config holds the config options for Swift backend
99
type Config struct {
10-
AuthVersion int `yaml:"auth_version"`
11-
AuthURL string `yaml:"auth_url"`
12-
Username string `yaml:"username"`
13-
UserDomainName string `yaml:"user_domain_name"`
14-
UserDomainID string `yaml:"user_domain_id"`
15-
UserID string `yaml:"user_id"`
16-
Password string `yaml:"password"`
17-
DomainID string `yaml:"domain_id"`
18-
DomainName string `yaml:"domain_name"`
19-
ProjectID string `yaml:"project_id"`
20-
ProjectName string `yaml:"project_name"`
21-
ProjectDomainID string `yaml:"project_domain_id"`
22-
ProjectDomainName string `yaml:"project_domain_name"`
23-
RegionName string `yaml:"region_name"`
24-
ContainerName string `yaml:"container_name"`
25-
MaxRetries int `yaml:"max_retries"`
26-
ConnectTimeout time.Duration `yaml:"connect_timeout"`
27-
RequestTimeout time.Duration `yaml:"request_timeout"`
10+
AuthVersion int `yaml:"auth_version"`
11+
AuthURL string `yaml:"auth_url"`
12+
ApplicationCredentialID string `yaml:"application_credential_id"`
13+
ApplicationCredentialName string `yaml:"application_credential_name"`
14+
ApplicationCredentialSecret string `yaml:"application_credential_secret"`
15+
Username string `yaml:"username"`
16+
UserDomainName string `yaml:"user_domain_name"`
17+
UserDomainID string `yaml:"user_domain_id"`
18+
UserID string `yaml:"user_id"`
19+
Password string `yaml:"password"`
20+
DomainID string `yaml:"domain_id"`
21+
DomainName string `yaml:"domain_name"`
22+
ProjectID string `yaml:"project_id"`
23+
ProjectName string `yaml:"project_name"`
24+
ProjectDomainID string `yaml:"project_domain_id"`
25+
ProjectDomainName string `yaml:"project_domain_name"`
26+
RegionName string `yaml:"region_name"`
27+
ContainerName string `yaml:"container_name"`
28+
MaxRetries int `yaml:"max_retries"`
29+
ConnectTimeout time.Duration `yaml:"connect_timeout"`
30+
RequestTimeout time.Duration `yaml:"request_timeout"`
2831
}
2932

3033
// RegisterFlags registers the flags for Swift storage
@@ -47,6 +50,9 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
4750
f.StringVar(&cfg.ProjectName, prefix+"swift.project-name", "", "OpenStack Swift project name (v2,v3 auth only).")
4851
f.StringVar(&cfg.ProjectDomainID, prefix+"swift.project-domain-id", "", "ID of the OpenStack Swift project's domain (v3 auth only), only needed if it differs the from user domain.")
4952
f.StringVar(&cfg.ProjectDomainName, prefix+"swift.project-domain-name", "", "Name of the OpenStack Swift project's domain (v3 auth only), only needed if it differs from the user domain.")
53+
f.StringVar(&cfg.ApplicationCredentialID, prefix+"swift.application-credential-id", "", "OpenStack Swift application credential ID.")
54+
f.StringVar(&cfg.ApplicationCredentialName, prefix+"swift.application-credential-name", "", "OpenStack Swift application credential name.")
55+
f.StringVar(&cfg.ApplicationCredentialSecret, prefix+"swift.application-credential-secret", "", "OpenStack Swift application credential secret.")
5056
f.StringVar(&cfg.RegionName, prefix+"swift.region-name", "", "OpenStack Swift Region to use (v2,v3 auth only).")
5157
f.StringVar(&cfg.ContainerName, prefix+"swift.container-name", "", "Name of the OpenStack Swift container to put chunks in.")
5258
f.IntVar(&cfg.MaxRetries, prefix+"swift.max-retries", 3, "Max retries on requests error.")

0 commit comments

Comments
 (0)