Skip to content

Commit

Permalink
Merge pull request noobaa#1271 from dannyzaken/danny-5.12
Browse files Browse the repository at this point in the history
[Backport to 5.12] Bug Fix BZ 2242414
  • Loading branch information
dannyzaken authored Dec 26, 2023
2 parents 662f2a1 + a442279 commit 4d7a27d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.52.2
version: v1.55.2

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.17"
go-version: "1.18"

- name: Deploy Dependencies
id: deploy
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.17"
go-version: "1.18"

- name: Deploy Dependencies
id: deploy
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.17"
go-version: "1.18"

- name: Deploy Dependencies
id: deploy
Expand Down
4 changes: 2 additions & 2 deletions pkg/noobaaaccount/noobaaaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,15 @@ func GenerateAccountKeys(name string) error {
secret.StringData["AWS_ACCESS_KEY_ID"] = accessKeys.AccessKey
secret.StringData["AWS_SECRET_ACCESS_KEY"] = accessKeys.SecretKey

//If we will not be able to update the secret we will print the credentials as they allready been changed by the RPC
// If we will not be able to update the secret we will print the credentials as they already been changed by the RPC
if !util.KubeUpdate(secret) {
log.Printf(`❌ Please write the new credentials for account %s:`, name)
fmt.Printf("\nAWS_ACCESS_KEY_ID : %s\n", accessKeys.AccessKey)
fmt.Printf("AWS_SECRET_ACCESS_KEY : %s\n\n", accessKeys.SecretKey)
log.Fatalf(`❌ Failed to update the secret %s with the new accessKeys`, secret.Name)
}

log.Printf("✅ Successfully reganerate s3 credentials for the account %q", name)
log.Printf("✅ Successfully regenerate s3 credentials for the account %q", name)
return nil
}

Expand Down
14 changes: 8 additions & 6 deletions pkg/obc/obc.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func CmdRegenerate() *cobra.Command {
Short: "Regenerate OBC S3 Credentials",
Run: RunRegenerate,
}
cmd.Flags().String("app-namespace", "",
"Set the namespace of the application where the OBC should be regenerated")
return cmd
}

Expand All @@ -77,7 +79,7 @@ func CmdDelete() *cobra.Command {
Run: RunDelete,
}
cmd.Flags().String("app-namespace", "",
"Set the namespace of the application where the OBC should be created")
"Set the namespace of the application where the OBC should be deleted")
return cmd
}

Expand Down Expand Up @@ -247,7 +249,7 @@ func RunRegenerate(cmd *cobra.Command, args []string) {
if obc.Spec.ObjectBucketName != "" {
ob.Name = obc.Spec.ObjectBucketName
} else {
ob.Name = fmt.Sprintf("obc-%s-%s", appNamespace, name)
ob.Name = fmt.Sprintf("ob-%s-%s", appNamespace, name)
}

if !util.KubeCheck(ob) {
Expand All @@ -256,7 +258,7 @@ func RunRegenerate(cmd *cobra.Command, args []string) {

accountName := ob.Spec.AdditionalState["account"]

err := GenerateAccountKeys(name, accountName)
err := GenerateAccountKeys(name, accountName, appNamespace)
if err != nil {
log.Fatalf(`❌ Could not regenerate credentials for %q: %v`, name, err)
}
Expand Down Expand Up @@ -513,7 +515,7 @@ func CheckPhase(obc *nbv1.ObjectBucketClaim) {
}

// GenerateAccountKeys regenerate noobaa OBC account S3 keys
func GenerateAccountKeys(name string, accountName string) error {
func GenerateAccountKeys(name, accountName, appNamespace string) error {
log := util.Logger()

if accountName == "" {
Expand All @@ -529,7 +531,7 @@ func GenerateAccountKeys(name string, accountName string) error {

// Checking that we can find the secret before we are calling the RPC to change the credentials.
secret := util.KubeObject(bundle.File_deploy_internal_secret_empty_yaml).(*corev1.Secret)
secret.Namespace = options.Namespace
secret.Namespace = appNamespace
secret.Name = name
if !util.KubeCheckQuiet(secret) {
log.Fatalf(`❌ Could not find secret: %s, will not regenerate keys.`, secret.Name)
Expand Down Expand Up @@ -564,6 +566,6 @@ func GenerateAccountKeys(name string, accountName string) error {
log.Fatalf(`❌ Failed to update the secret %s with the new accessKeys`, secret.Name)
}

log.Printf("✅ Successfully reganerate s3 credentials for the OBC %q", name)
log.Printf("✅ Successfully regenerate s3 credentials for the OBC %q", name)
return nil
}

0 comments on commit 4d7a27d

Please sign in to comment.