Skip to content

Commit 60975f9

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

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
@@ -7,6 +7,7 @@
77
* [FEATURE] Ruler: Experimental: Add `ruler.frontend-address` to allow query to query frontends instead of ingesters. #6151
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
10+
* [ENHANCEMENT] OpenStack Swift: Add application credential configs for Openstack swift object storage backend. #6255
1011
* [ENHANCEMENT] Ingester: Add `blocks-storage.tsdb.wal-compression-type` to support zstd wal compression type. #6232
1112
* [ENHANCEMENT] Query Frontend: Add info field to query response. #6207
1213
* [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
@@ -428,6 +428,18 @@ blocks_storage:
428428
# CLI flag: -blocks-storage.swift.auth-url
429429
[auth_url: <string> | default = ""]
430430

431+
# OpenStack Swift application credential ID.
432+
# CLI flag: -blocks-storage.swift.application-credential-id
433+
[application_credential_id: <string> | default = ""]
434+
435+
# OpenStack Swift application credential name.
436+
# CLI flag: -blocks-storage.swift.application-credential-name
437+
[application_credential_name: <string> | default = ""]
438+
439+
# OpenStack Swift application credential secret.
440+
# CLI flag: -blocks-storage.swift.application-credential-secret
441+
[application_credential_secret: <string> | default = ""]
442+
431443
# OpenStack Swift username.
432444
# CLI flag: -blocks-storage.swift.username
433445
[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 = ""]
@@ -4690,6 +4714,18 @@ swift:
46904714
# CLI flag: -ruler-storage.swift.auth-url
46914715
[auth_url: <string> | default = ""]
46924716

4717+
# OpenStack Swift application credential ID.
4718+
# CLI flag: -ruler-storage.swift.application-credential-id
4719+
[application_credential_id: <string> | default = ""]
4720+
4721+
# OpenStack Swift application credential name.
4722+
# CLI flag: -ruler-storage.swift.application-credential-name
4723+
[application_credential_name: <string> | default = ""]
4724+
4725+
# OpenStack Swift application credential secret.
4726+
# CLI flag: -ruler-storage.swift.application-credential-secret
4727+
[application_credential_secret: <string> | default = ""]
4728+
46934729
# OpenStack Swift username.
46944730
# CLI flag: -ruler-storage.swift.username
46954731
[username: <string> | default = ""]
@@ -4977,6 +5013,18 @@ swift:
49775013
# CLI flag: -runtime-config.swift.auth-url
49785014
[auth_url: <string> | default = ""]
49795015

5016+
# OpenStack Swift application credential ID.
5017+
# CLI flag: -runtime-config.swift.application-credential-id
5018+
[application_credential_id: <string> | default = ""]
5019+
5020+
# OpenStack Swift application credential name.
5021+
# CLI flag: -runtime-config.swift.application-credential-name
5022+
[application_credential_name: <string> | default = ""]
5023+
5024+
# OpenStack Swift application credential secret.
5025+
# CLI flag: -runtime-config.swift.application-credential-secret
5026+
[application_credential_secret: <string> | default = ""]
5027+
49805028
# OpenStack Swift username.
49815029
# CLI flag: -runtime-config.swift.username
49825030
[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)