-
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
base: main
Are you sure you want to change the base?
Changes from all commits
6d80281
d7cd897
54278fb
35da72c
3b88f28
2fff43a
7cf5113
e5ab782
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 "" | ||
} |
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 { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ GO_TEST_FOR(cloud/disk_manager/internal/pkg/clients/nbs) | |
|
||
SET_APPEND(RECIPE_ARGS --nbs-only) | ||
SET_APPEND(RECIPE_ARGS --multiple-nbs) | ||
SET_APPEND(RECIPE_ARGS --disk-agent-count 3) | ||
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. нигде не нашел использования этого флага в этом ПРе - он уже был раньше? |
||
INCLUDE(${ARCADIA_ROOT}/cloud/disk_manager/test/recipe/recipe.inc) | ||
|
||
GO_XTEST_SRCS( | ||
|
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 | ||
|
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 в дм, то только в тестового клиента (и я бы даже делал это без тестов)