Bug 49543

Summary: Ошибка при выполнении swift-ring-builder rebalance
Product: Branch p10 Reporter: Nikolai Zurabishvili <zurabishvilinn>
Component: openstack-swiftAssignee: Grigory Ustinov <grenka>
Status: NEW --- QA Contact: qa-p10 <qa-p10>
Severity: normal    
Priority: P5 CC: aminov
Version: не указана   
Hardware: x86_64   
OS: Linux   
Attachments:
Description Flags
openstack-keystone-deploy.sh none

Description Nikolai Zurabishvili 2024-02-28 11:45:39 MSK
Created attachment 15616 [details]
openstack-keystone-deploy.sh

openstack-swift-2.25.0-alt1

Стенды (обновлен до p10):

Server 10.1 x86-64

Предусловия:

Добавить дополнительно 3 диска к виртуалке размером например 5 GB 

Установлены пакеты: # apt-get install openstack-swift-* rsync-server

Настроить openstack-keystone используя скрипт (см openstack-keystone-deploy.sh)

Шаги:

1. Настроить swift-proxy:

# openstack user create --domain default --password-prompt swift
# openstack service create --name swift   --description "OpenStack Object Storage" object-store

# openstack endpoint create --region RegionOne object-store public http://$(hostname -i):8080/v1/AUTH_%\(project_id\)s
# openstack endpoint create --region RegionOne object-store internal http://$(hostname -i):8080/v1/AUTH_%\(project_id\)s
# openstack endpoint create --region RegionOne object-store admin http://$(hostname -i):8080/v1/AUTH_%\(project_id\)s
 
1.1 Отредактировать файл /etc/swift/proxy-server.conf 

[DEFAULT]
...
bind_port = 8080
user = swift
swift_dir = /etc/swift
...

[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
...
www_authenticate_uri = http://127.0.0.1:5000
auth_url = http://127.0.0.1:5000
memcached_servers = 127.0.0.1:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = swift
password = 1
delay_auth_decision = True

2. Настроить Object Storage service

# mkfs.xfs /dev/sdb
# mkfs.xfs /dev/sdc
# mkfs.xfs /dev/sdd

# mkdir -p /srv/node/sdb
# mkdir -p /srv/node/sdc
# mkdir -p /srv/node/sdd

# blkid

2.1 Добавить в /etc/fstab строки используя UUID из предыдущей команды:
UUID="<UUID-from-output-above>" /srv/node/sdb xfs noatime 0 2
UUID="<UUID-from-output-above>" /srv/node/sdc xfs noatime 0 2
UUID="<UUID-from-output-above>" /srv/node/sdd xfs noatime 0 2

# mount /srv/node/sdb
# mount /srv/node/sdc
# mount /srv/node/sdd

3. Настроить rsync

Добавить в /etc/rsyncd.conf строки:
 
uid = swift
gid = swift
log file = /var/log/rsyncd/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1

[account]
max connections = 2
path = /srv/node/
read only = False
lock file = /var/lock/account.lock

[container]
max connections = 2
path = /srv/node/
read only = False
lock file = /var/lock/container.lock

[object]
max connections = 2
path = /srv/node/
read only = False
lock file = /var/lock/object.lock

# echo >> /etc/sysconfig/rsyncd
# systemctl enable --now rsyncd.socket

4. Настроить остальные компоненты swift

/etc/swift/account-server.conf

[DEFAULT]
...
user = swift
swift_dir = /etc/swift
devices = /srv/node
...

/etc/swift/container-server.conf

[DEFAULT]
...
user = swift
swift_dir = /etc/swift
devices = /srv/node
...

/etc/swift/object-server.conf

[DEFAULT]
...
user = swift
swift_dir = /etc/swift
devices = /srv/node
...

5. Назначить права 

# chown -R swift:swift /srv/node

6. В /etc/swift/swift.conf добавить строки:

[swift-hash]
...
swift_hash_path_suffix = HASH_PATH_SUFFIX
swift_hash_path_prefix = HASH_PATH_PREFIX

7. Настроить initial rings:

# swift-ring-builder account.builder create 10 3 1
# swift-ring-builder container.builder create 10 3 1
# swift-ring-builder object.builder create 10 3 1

# swift-ring-builder account.builder add --region 1 --zone 1 --ip <VM-IP> --port 6202 --device sdb --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip <VM-IP> --port 6202 --device sdc --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip <VM-IP> --port 6202 --device sdd --weight 100

где <VM-IP> - ip тестируемой машины

# swift-ring-builder account.builder

# swift-ring-builder account.builder rebalance


Ожидаемый результат: Успешное выполнение команды
 
Фактический результат: Reassigned 3072 (300.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00
Traceback (most recent call last):
  File "/usr/bin/swift-ring-builder", line 24, in <module>
    sys.exit(main())
  File "/usr/lib/python3/site-packages/swift/cli/ringbuilder.py", line 1688, in main
    getattr(Commands, command, Commands.unknown)()
  File "/usr/lib/python3/site-packages/swift/cli/ringbuilder.py", line 1158, in rebalance
    builder.get_ring().save(
  File "/usr/lib/python3/site-packages/swift/common/ring/ring.py", line 239, in save
    self.serialize_v1(gz_file)
  File "/usr/lib/python3/site-packages/swift/common/ring/ring.py", line 224, in serialize_v1
    file_obj.write(part2dev_id.tostring())
AttributeError: 'array.array' object has no attribute 'tostring'