Skip to content

Commit

Permalink
Noobaa/Operator: Display error message
Browse files Browse the repository at this point in the history
While deleting OBC or Bucketclass which does not exist,
we should display an error message and should not silently
give success.

Signed-off-by: Ashish Pandey <[email protected]>
(cherry picked from commit 553c496)
  • Loading branch information
aspandey authored and liranmauda committed Dec 4, 2024
1 parent 2bca4d8 commit ea0c59e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pkg/bucketclass/bucketclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ func RunDelete(cmd *cobra.Command, args []string) {
bucketClass.Name = args[0]
bucketClass.Namespace = options.Namespace

if !util.KubeCheck(bucketClass) {
log.Fatalf(`❌ Could not delete, BucketClass %q in namespace %q does not exist`,
bucketClass.Name, bucketClass.Namespace)
}

if !util.KubeDelete(bucketClass) {
log.Fatalf(`❌ Could not delete BucketClass %q in namespace %q`,
bucketClass.Name, bucketClass.Namespace)
Expand Down
6 changes: 5 additions & 1 deletion pkg/obc/obc.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func RunCreate(cmd *cobra.Command, args []string) {
log.Fatalf(`❌ NSFS account config must include both UID and GID as positive integers`)
}

if bucketClassName == "" && ( gid > -1 || uid > -1 || distinguishedName != "" ) {
if bucketClassName == "" && (gid > -1 || uid > -1 || distinguishedName != "") {
log.Fatalf(`❌ NSFS account config cannot be set without an NSFS bucketclass`)
}

Expand Down Expand Up @@ -331,6 +331,10 @@ func RunDelete(cmd *cobra.Command, args []string) {
obc.Name = args[0]
obc.Namespace = appNamespace

if !util.KubeCheck(obc) {
log.Fatalf(`❌ Could not delete. OBC %q in namespace %q does not exist`, obc.Name, obc.Namespace)
}

if !util.KubeDelete(obc) {
log.Fatalf(`❌ Could not delete OBC %q in namespace %q`,
obc.Name, obc.Namespace)
Expand Down
4 changes: 1 addition & 3 deletions test/cli/test_cli_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -965,13 +965,11 @@ function delete_backingstore_path {

function delete_namespacestore_path {
local object_bucket namespace_store
test_noobaa obc delete ${obc[2]}
test_noobaa bucketclass delete ${bucketclass[2]}
local namespacestore=($(test_noobaa silence namespacestore list | grep -v "NAME" | awk '{print $1}'))
local bucketclass=($(test_noobaa silence bucketclass list | grep -v "NAME" | awk '{print $1}'))
local obc=()
local all_obc=($(test_noobaa silence obc list | grep -v "BUCKET-NAME" | awk '{print $2":"$5}'))

# get obcs that their bucketclass is in bucketclass array
for object_bucket in ${all_obc[@]}
do
Expand Down

0 comments on commit ea0c59e

Please sign in to comment.