-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Disk Manager] retry with new checkpoint id when create snapshot if shadow disk failed during filling #2691
Open
gy2411
wants to merge
9
commits into
main
Choose a base branch
from
users/gayurgin/retry_with_new_checkpoint_id_when_create_snapshot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+839
−35
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7e5ef27
[Disk Manager] add methods for disk registry to nbs client
gy2411 1b5ba68
[Disk Manager] retry with new checkpoint id in create snapshot task i…
gy2411 76099cb
[Disk Manager] add test on snapshot creation with shadow disk failure
gy2411 7d546cb
[Disk Manager] enable shadow disks in disk manager large tests
gy2411 77e5bf0
minor improvements
gy2411 40b43db
[Disk Manager] add tests on disk registry methods of nbs client
gy2411 0e0840e
[Disk Manager] create snapshot from disk: add unit test on checkpoint…
gy2411 3a572dd
fix tests names
gy2411 560c54f
minor fixes
gy2411 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
cloud/disk_manager/internal/pkg/clients/nbs/disk_registry_state.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package nbs | ||
|
||
type diskRegistryCheckpointReplica struct { | ||
CheckpointID string `json:"CheckpointId"` | ||
SourceDiskID string `json:"SourceDiskId"` | ||
} | ||
|
||
type diskRegistryDisk struct { | ||
DiskID string `json:"DiskId"` | ||
DeviceUUIDs []string `json:"DeviceUUIDs"` | ||
CheckpointReplica diskRegistryCheckpointReplica `json:"CheckpointReplica"` | ||
} | ||
|
||
type diskRegistryDevice struct { | ||
DeviceUUID string `json:"DeviceUUID"` | ||
} | ||
|
||
type diskRegistryAgent struct { | ||
Devices []diskRegistryDevice `json:"Devices"` | ||
AgentID string `json:"AgentId"` | ||
} | ||
|
||
type DiskRegistryBackup struct { | ||
Disks []diskRegistryDisk `json:"Disks"` | ||
Agents []diskRegistryAgent `json:"Agents"` | ||
} | ||
|
||
type diskRegistryState struct { | ||
Backup DiskRegistryBackup `json:"Backup"` | ||
} | ||
|
||
func (b *DiskRegistryBackup) GetDevicesOfDisk(diskID string) []string { | ||
for _, disk := range b.Disks { | ||
if disk.DiskID == diskID { | ||
return disk.DeviceUUIDs | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (b *DiskRegistryBackup) GetDevicesOfShadowDisk( | ||
originalDiskID string, | ||
) []string { | ||
|
||
for _, disk := range b.Disks { | ||
if disk.CheckpointReplica.SourceDiskID == originalDiskID { | ||
return disk.DeviceUUIDs | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (b *DiskRegistryBackup) GetAgentIDByDeviceUUId(deviceUUID string) string { | ||
for _, agent := range b.Agents { | ||
for _, device := range agent.Devices { | ||
if device.DeviceUUID == deviceUUID { | ||
return agent.AgentID | ||
} | ||
} | ||
} | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package nbs | |
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"hash/crc32" | ||
"math/rand" | ||
|
@@ -513,6 +514,56 @@ func (c *client) Write( | |
return nil | ||
} | ||
|
||
func (c *client) BackupDiskRegistryState( | ||
ctx context.Context, | ||
) (*DiskRegistryBackup, error) { | ||
|
||
output, err := c.nbs.ExecuteAction(ctx, "backupdiskregistrystate", []byte("{}")) | ||
if err != nil { | ||
return nil, wrapError(err) | ||
} | ||
|
||
var state diskRegistryState | ||
err = json.Unmarshal(output, &state) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &state.Backup, nil | ||
} | ||
|
||
func (c *client) DisableDevices( | ||
ctx context.Context, | ||
agentID string, | ||
deviceUUIDs []string, | ||
message string, | ||
) error { | ||
|
||
if len(deviceUUIDs) == 0 { | ||
return fmt.Errorf("list of devices to disable should contain at least one device") | ||
} | ||
|
||
deviceUUIDsField, err := json.Marshal(deviceUUIDs) | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
input := fmt.Sprintf( | ||
"{\"DisableAgent\":{\"AgentId\":\"%v\",\"DeviceUUIDs\":%v},\"Message\":\"%v\"}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Хотя ручка и называется "DisableAgent", она не будет ломать весь агент, если ей передать непустой спасок девайсов. Она сломает только девайсы из этого списка. Сломает -- значит, девайсы начнут отдавать ошибку в ответ на все запросы чтения и записи. |
||
agentID, | ||
string(deviceUUIDsField), | ||
message, | ||
) | ||
|
||
_, err = c.nbs.ExecuteAction( | ||
ctx, | ||
"diskregistrychangestate", | ||
[]byte(input), | ||
) | ||
|
||
return wrapError(err) | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
type checkpoint struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ GO_LIBRARY() | |
|
||
SRCS( | ||
client.go | ||
disk_registry_state.go | ||
factory.go | ||
interface.go | ||
metrics.go | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предлагаю упростить и если уж тащить внутренности dr в дм, то только в тестового клиента (и я бы даже делал это без тестов)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А что ты понимаешь под "упростить"?
Хм, а в чём принципиальная разница между тестовым клиентом и отдельным файликом disk_registry_state.go? Они ведь всё равно в одном модуле находятся.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если не писать тесты на методы работы с disk registry, то появляется опасение, что выключение девайса не сработает. И тогда интеграционный тест будет работать вхолостую -- он будет завершаться успехом, но при этом по факту никогда не будет выключать девайс. Хочется обезопаситься от этого.
Было бы здорово в самом интеграционном тесте как-то проверить, что девайс действительно был выключен и что действительно был налит новый чекпоинт. Но ведь так происходит не всегда -- из-за рандома с таймингами могут быть сценарии, когда девайс не ломался.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
то, что написаны тесты - никогда не плохо
но такой большой кусок кода, особенно не используемый ДМом в проде тащить в nbs клиента неправильно - мы вообще в DA не ходим
в клиенте иметь этот код также будет причиной вопросов что это, зачем это, давайте сделаем по аналогии и тп
мы в целом уже давно хотели это исправить и мне кажется этот момент настал, тк этот код нетривиальный (тк это внутренности DA) #892