swift delete *

Bug #1231501 reported by Dafna Ron
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-swiftclient
Invalid
Undecided
Unassigned

Bug Description

when I run swift delete * we get a list of some object that supposedly do not exist that swift is trying to delete.
none of the containers or object under them are deleted:

[root@nott-vdsa tmp(keystone_admin)]# swift delete *
Object 'admin/keystone-signing-0Bdj_F' not found
Object 'admin/keystone-signing-2YKYcR' not found
Object 'admin/keystone-signing-59724W' not found
Object 'admin/create_horizon.txt' not found
Object 'admin/keystone-signing-62Gzvk' not found
Object 'admin/keystone-signing-6Wu8Z6' not found
Object 'admin/keystone-signing-BVrPwz' not found
Object 'admin/keystone-signing-CtP4UA' not found
Object 'admin/keystone-signing-E_hCiX' not found
Object 'admin/keystone-signing-CjKRGD' not found
Object 'admin/keystone-signing-emzPOA' not found
Object 'admin/file.tar.gz' not found
Object 'admin/keystone-signing-hf66GT' not found
Object 'admin/keystone-signing-junmx6' not found
Object 'admin/keystone-signing-lx4Ig6' not found
Object 'admin/keystone-signing-KBYxY2' not found
Object 'admin/keystone-signing-mBgRBf' not found
Object 'admin/keystone-signing-kKTroh' not found
Object 'admin/keystone-signing-nova' not found
Object 'admin/initrd.img' not found
Object 'admin/keystone-signing-pd82DZ' not found
Object 'admin/keystone-signing-SqdO2x' not found
Object 'admin/keystone-signing-njDZF2' not found
Object 'admin/keystone-signing-olPTxr' not found
Object 'admin/keystone-signing-tmBNUN' not found
Object 'admin/glance' not found
Object 'admin/keystone-signing-uJ8zIo' not found
Object 'admin/keystone-signing-v9POs9' not found
Object 'admin/keystone-signing-qZYe4J' not found
Object 'admin/keystone-signing-vAifQZ' not found
Object 'admin/keystone-signing-uhVbvH' not found
Object 'admin/keystone-signing-Z0uGYQ' not found
Object 'admin/keystone-signing-u9JMlw' not found
Object 'admin/keystone-signing-Uu4vww' not found
Object 'admin/keystone-signing-2effZE' not found
Object 'admin/ks-script-uLSgyo.log' not found
Object 'admin/keystone-signing-yOe71a' not found
Object 'admin/glance-api.conf' not found
Object 'admin/test2' not found
Object 'admin/packstack-answers-20130924-140637.txt' not found
Object 'admin/yum.log' not found
Object 'admin/test1' not found
Object 'admin/rhel-server-x86_64-kvm-6.4_20130130.0-2-sda.qcow2' not found
Object 'admin/ks-script-uLSgyo' not found
Object 'admin/test3' not found
Object 'admin/file' not found
Object 'admin/glance1' not found
Object 'admin/image' not found
[root@nott-vdsa tmp(keystone_admin)]# swift list
dafna
haha
lala
lala1
test
test1
[root@nott-vdsa tmp(keystone_admin)]# swift list dafna
file.tar.gz
test1
test2
test3
tmp/glance-api.conf
tmp/ks-script-uLSgyo.log
[root@nott-vdsa tmp(keystone_admin)]#

Revision history for this message
gholt (gholt) wrote :

Have you heard of file name globbing?

https://en.wikipedia.org/wiki/Glob_(programming)

Revision history for this message
Samuel Merritt (torgomatic) wrote :

As gholt said, that's your shell expanding "*", and has nothing to do with Swift or swiftclient.

Changed in swift:
status: New → Invalid
Revision history for this message
Dave Neary (dneary) wrote :

Hi,

Filesystem globbing doesn't traverse the subdirectories - why doesn't it just show an error for trying to delete the objkect "admin"? Obviously Swift is expanding the directory entries there. What's the appropriate way to pass a * into Swift without globbing?

Dave.

Revision history for this message
Dafna Ron (dron-3) wrote :

gholt, yes I have heard of globbing :) luckily I don't take things to heart but someone with thinner skin may have take this question badly ;)

Revision history for this message
Chmouel Boudjnah (chmouel) wrote :

What happen here is that you are doing a :

swift delete *

when you look at the swift help for delete :

,----
| $ swift delete --help
| Usage: Delete a container or objects within a container
|
| Positional arguments:
| <container> Name of container to delete from
| <object> Name of object to delete. Specify multiple times
| for multiple objects
`----

so the first arg is a container and the object is the list of objects.

I would guess that you have a directory admin keystone-signing-* and other files, so basically when you do the star which would do the ordering alphabetically and pick up admin as first (letter a) you say:

delete all those other objects in the admin directory

and swiftclient just try it and tells you that it fails.

@Dave if you want to delete with globbing like you says you can just delete the container directly and it would delete everything underdeath.

Revision history for this message
Dafna Ron (dron-3) wrote :

Actually.... the files that are output by swift are from my local /tmp directory (which I was under when running the swift delete * command)
so swift is looking for the local files from the location you are on when running the command.

look at this:

I have one container with 3 files:

[root@nott-vdsa /(keystone_admin)]# swift list
files
[root@nott-vdsa /(keystone_admin)]# swift list files
file1
file2
file3

I am under this location on my compute:

[root@nott-vdsa dafna_test(keystone_admin)]# pwd
/tmp/dafna_test

where I created these 3 files:

[root@nott-vdsa dafna_test(keystone_admin)]# ls -l
total 0
-rw-r--r--. 1 root root 0 Sep 27 16:23 local_file
-rw-r--r--. 1 root root 0 Sep 27 16:23 local_file1
-rw-r--r--. 1 root root 0 Sep 27 16:23 local_file2

I run swift delete *

[root@nott-vdsa dafna_test(keystone_admin)]# swift delete *
Object 'local_file/local_file2' not found
Object 'local_file/local_file1' not found
[root@nott-vdsa dafna_test(keystone_admin)]# ls -l
total 0
-rw-r--r--. 1 root root 0 Sep 27 16:23 local_file
-rw-r--r--. 1 root root 0 Sep 27 16:23 local_file1
-rw-r--r--. 1 root root 0 Sep 27 16:23 local_file2

now I'll do the same from a different location:

[root@nott-vdsa logs(keystone_admin)]# pwd
/tmp/logs

I copies some logs there so ls output is:

[root@nott-vdsa logs(keystone_admin)]# ls -l
total 140
-rw-r--r--. 1 root root 138625 Sep 27 16:26 access_log
-rw-r--r--. 1 root root 3797 Sep 27 16:26 error_log
-rw-r--r--. 1 root root 0 Sep 27 16:26 swift-startup.log

[root@nott-vdsa logs(keystone_admin)]# swift delete *
Object 'access_log/error_log' not found
Object 'access_log/swift-startup.log' not found
[root@nott-vdsa logs(keystone_admin)]#

as you can see, what swift is looking for are actually the files from the local dir in which I am located on while running the command.

and the container is not deleted at all:

[root@nott-vdsa logs(keystone_admin)]# swift list files
file1
file2
file3

Revision history for this message
Chmouel Boudjnah (chmouel) wrote :

I am not sure I understand, what do you expect when doing swift delete * ?
Are you expecting that swift will delete every containers in your account?
It will not because when you do that from a shell the shell would do an expansion and there is no way to avoid that except if you add a backslash or quote it which then get * properly passed into the argv of the swiftclient.

Swift does not know anything about */star (you may even as well have a object called * if you wanted), if you really want to delete everything on your swift you just can do swift delete --all

affects: swift → python-swiftclient
Revision history for this message
Dafna Ron (dron-3) wrote :

I'll explain what my expectations are then :)

I expect that swift will either delete all containers when using a wild card or exit like it would if I run
swift upload *
what I don't expect is swift to list the files from my local dir and try to delete them from swift servers and than give errors that they do not exist.

I also do not expect inconsistency in the way that swift handles the */star.
for example, swift knows to upload all the files from a directory and create a container when I used 'swift upload * local_file'
[root@nott-vdsa tmp(keystone_admin)]# swift list local_file
local_file
local_file1
local_file2

swift will try to upload and create containers for all files/directories under my location if I use * with upload as well.
but it will not know how to delete all the files from the container or delete all containers if I use *

btw, you can create a container called * but you do have to use '*' as we have to do for all special characters and you need to use the same syntax when deleting it.

as you can see, I created one using swift post '*'

[root@nott-vdsa tmp(keystone_admin)]# swift list
*

swift delete * will not delete anything because it will try to find all the files from my local /tmp dir:

[root@nott-vdsa tmp(keystone_admin)]# swift delete *
Object 'create_horizon.txt/keystone-signing-hf66GT' not found
Object 'create_horizon.txt/file1' not found
Object 'create_horizon.txt/keystone-signing-lx4Ig6' not found
Object 'create_horizon.txt/keystone-signing-mBgRBf' not found
Object 'create_horizon.

swift delete '*' will delete it though...

[root@nott-vdsa tmp(keystone_admin)]# swift delete '*'
[root@nott-vdsa tmp(keystone_admin)]# swift list
local_file
test
test1

for conclusion, I think that you can decide on any design that you like, but I think that currently there is inconsistency in the way that we use * in swift.

and I have to add one last thing... I do the testing from a user/admin prospective (which is our end user right?) and yes, I have read the help file and noticed the --all, but using a * in linux is a standard, so when I run swift delete * I do expect all containers to be deleted or for a graceful exit to happen :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.