Lirt / velero-plugin-for-openstack

Openstack Cinder, Manila and Swift plugin for Velero backups
MIT License
27 stars 16 forks source link

[BUG] Random suffix for snapshot/backup names is not random #82

Closed kayrus closed 1 year ago

kayrus commented 1 year ago

Describe the bug

Golang prior to 1.20 has a fixed seed for math/rand.globalRand and backup/snapshots have the same suffix in a name.

Try to run https://go.dev/play/p/qKmDuwawK4H?v=goprev (go 1.19) several times and every time it will:

5577006791947779410
8674665223082153551
15352856648520921629
13260572831089785859
3916589616287113937

Comparing to https://go.dev/play/p/qKmDuwawK4H (go 1.20)

Steps to reproduce the behavior

Restore a snapshot and restart the velero. Then restore a new snapshot, the resulting snapshot names will have the same suffix:

2d9835a7-65e1-4728-97a0-9010a0e2a418.backup.5577006791947779410 2d9835a7-65e1-4728-97a0-9010a0e2a418.backup.5577006791947779410

Expected behavior

Velero plugin must generate unpredictable suffixes for volume/snapshot names.

This can be done by upgrading the go version to 1.20, or using the private rand object with its own seed based on timestamp.

See also https://github.com/golang/go/issues/54880