Skip to content

Commit

Permalink
Change azure storage account secret name (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinBisson authored Jun 18, 2024
1 parent f94322a commit 345d8ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Change azure storage account secret name by using the bucket name instead of the storage account name to not be bothered by azure storage account name limitations (up to 24 characters) which truncates secret name for long bucket names like `giantswarm-glippy-mimir-ruler` which becomes `giantswarmglippymimirrul`. As this rule is unpredictable (depends on the installation name), it is better to fix the name of the secret.

## [0.6.1] - 2024-06-17

### Fixed

- Fix object-storage-operator templating.
- Fix object-storage-operator aws templating by using the root scope when possible.

## [0.6.0] - 2024-06-17

Expand Down
16 changes: 8 additions & 8 deletions internal/pkg/service/objectstorage/cloud/azure/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (s AzureObjectStorageAdapter) CreateBucket(ctx context.Context, bucket *v1a
nil,
)
if err != nil {
return fmt.Errorf("Impossible to retrieve Access Keys from Storage Account %s", storageAccountName)
return fmt.Errorf("unable to retrieve access keys from storage account %s", storageAccountName)
}
// Then, we retrieve the Access Key for 'key1'
foundKey1 := false
Expand All @@ -178,7 +178,7 @@ func (s AzureObjectStorageAdapter) CreateBucket(ctx context.Context, bucket *v1a
// Finally, we create the Secret into the bucket namespace
secret := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: storageAccountName,
Name: bucket.Spec.Name,
Namespace: bucket.Namespace,
Labels: map[string]string{
"giantswarm.io/managed-by": "object-storage-operator",
Expand All @@ -193,12 +193,12 @@ func (s AzureObjectStorageAdapter) CreateBucket(ctx context.Context, bucket *v1a
if err != nil {
return err
}
s.logger.Info(fmt.Sprintf("Secret %s created", storageAccountName))
s.logger.Info(fmt.Sprintf("created secret %s", bucket.Spec.Name))
break
}
}
if !foundKey1 {
return fmt.Errorf("Impossible to retrieve Access Keys 'key1' from Storage Account %s", storageAccountName)
return fmt.Errorf("unable to retrieve access keys 'key1' from storage account %s", storageAccountName)
}

return nil
Expand Down Expand Up @@ -227,20 +227,20 @@ func (s AzureObjectStorageAdapter) DeleteBucket(ctx context.Context, bucket *v1a
err = s.client.Get(
ctx,
types.NamespacedName{
Name: bucket.Spec.Name,
Namespace: bucket.Namespace,
Name: storageAccountName,
},
&secret)
if err != nil {
s.logger.Error(err, fmt.Sprintf("Impossible to retrieve Secret %s", storageAccountName))
s.logger.Error(err, fmt.Sprintf("unable to retrieve secret %s", bucket.Spec.Name))
return err
}
err = s.client.Delete(ctx, &secret)
if err != nil {
s.logger.Error(err, fmt.Sprintf("Impossible to delete Secret %s", storageAccountName))
s.logger.Error(err, fmt.Sprintf("unable to delete secret %s", bucket.Spec.Name))
return err
}
s.logger.Info(fmt.Sprintf("Secret %s deleted", storageAccountName))
s.logger.Info(fmt.Sprintf("deleted secret %s", bucket.Spec.Name))

return nil
}
Expand Down

0 comments on commit 345d8ca

Please sign in to comment.