Skip to content

Commit

Permalink
feat: add a new setting to enable v2 data engine fast rebuilding
Browse files Browse the repository at this point in the history
Longhorn 9488

Signed-off-by: Shuo Wu <[email protected]>
  • Loading branch information
shuo-wu committed Dec 3, 2024
1 parent 2d5d202 commit bf5ec5c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
7 changes: 6 additions & 1 deletion controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4892,7 +4892,12 @@ func (c *VolumeController) shouldCleanUpFailedReplica(v *longhorn.Volume, r *lon
}
// TODO: Remove it once we can reuse failed replicas during v2 rebuilding
if types.IsDataEngineV2(v.Spec.DataEngine) {
return true
v2DataEngineFastRebuilding, err := c.ds.GetSettingAsBool(types.SettingNameV2DataEngineFastRebuilding)
if err != nil {
log.WithError(err).Warn("Failed to get the setting for v2 data engine fast rebuilding, will consider it as false")
v2DataEngineFastRebuilding = false
}
return !v2DataEngineFastRebuilding
}
// Failed too long ago to be useful during a rebuild.
if v.Spec.StaleReplicaTimeout > 0 &&
Expand Down
9 changes: 8 additions & 1 deletion scheduler/replica_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,14 @@ func filterActiveReplicas(replicas map[string]*longhorn.Replica) map[string]*lon
func (rcs *ReplicaScheduler) CheckAndReuseFailedReplica(replicas map[string]*longhorn.Replica, volume *longhorn.Volume, hardNodeAffinity string) (*longhorn.Replica, error) {
// TODO: Remove it once we can reuse failed replicas during v2 rebuilding
if types.IsDataEngineV2(volume.Spec.DataEngine) {
return nil, nil
v2DataEngineFastRebuilding, err := rcs.ds.GetSettingAsBool(types.SettingNameV2DataEngineFastRebuilding)
if err != nil {
logrus.WithError(err).Warn("Failed to get the setting for v2 data engine fast rebuilding, will consider it as false")
v2DataEngineFastRebuilding = false
}
if !v2DataEngineFastRebuilding {
return nil, nil
}
}

replicas = filterActiveReplicas(replicas)
Expand Down
17 changes: 15 additions & 2 deletions types/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const (
SettingNameV2DataEngineCPUMask = SettingName("v2-data-engine-cpu-mask")
SettingNameV2DataEngineLogLevel = SettingName("v2-data-engine-log-level")
SettingNameV2DataEngineLogFlags = SettingName("v2-data-engine-log-flags")
SettingNameV2DataEngineFastRebuilding = SettingName("v2-data-engine-fast-rebuilding")
SettingNameFreezeFilesystemForSnapshot = SettingName("freeze-filesystem-for-snapshot")
SettingNameAutoCleanupSnapshotWhenDeleteBackup = SettingName("auto-cleanup-when-delete-backup")
SettingNameDefaultMinNumberOfBackingImageCopies = SettingName("default-min-number-of-backing-image-copies")
Expand Down Expand Up @@ -225,6 +226,7 @@ var (
SettingNameV2DataEngineCPUMask,
SettingNameV2DataEngineLogLevel,
SettingNameV2DataEngineLogFlags,
SettingNameV2DataEngineFastRebuilding,
SettingNameReplicaDiskSoftAntiAffinity,
SettingNameAllowEmptyNodeSelectorVolume,
SettingNameAllowEmptyDiskSelectorVolume,
Expand Down Expand Up @@ -347,6 +349,7 @@ var (
SettingNameV2DataEngineCPUMask: SettingDefinitionV2DataEngineCPUMask,
SettingNameV2DataEngineLogLevel: SettingDefinitionV2DataEngineLogLevel,
SettingNameV2DataEngineLogFlags: SettingDefinitionV2DataEngineLogFlags,
SettingNameV2DataEngineFastRebuilding: SettingDefinitionV2DataEngineFastRebuilding,
SettingNameReplicaDiskSoftAntiAffinity: SettingDefinitionReplicaDiskSoftAntiAffinity,
SettingNameAllowEmptyNodeSelectorVolume: SettingDefinitionAllowEmptyNodeSelectorVolume,
SettingNameAllowEmptyDiskSelectorVolume: SettingDefinitionAllowEmptyDiskSelectorVolume,
Expand Down Expand Up @@ -1260,12 +1263,12 @@ var (

SettingDefinitionFastReplicaRebuildEnabled = SettingDefinition{
DisplayName: "Fast Replica Rebuild Enabled",
Description: "This setting enables the fast replica rebuilding feature. It relies on the checksums of snapshot disk files, so setting the snapshot-data-integrity to **enable** or **fast-check** is a prerequisite.",
Description: "This setting enables the fast replica rebuilding feature, which will try to reuse the existing data on a failed replica rather than directly creating a new replica for a degraded volume.",
Category: SettingCategoryGeneral,
Type: SettingTypeBool,
Required: true,
ReadOnly: false,
Default: "true",
Default: "false",
}

SettingDefinitionReplicaFileSyncHTTPClientTimeout = SettingDefinition{
Expand Down Expand Up @@ -1477,6 +1480,16 @@ var (
Default: "",
}

SettingDefinitionV2DataEngineFastRebuilding = SettingDefinition{
DisplayName: "V2 Data Engine Fast Rebuilding",
Description: "Enable the fast rebuilding feature for V2 Data Engine.",
Category: SettingCategoryV2DataEngine,
Type: SettingTypeBool,
Required: true,
ReadOnly: false,
Default: "false",
}

SettingDefinitionAutoCleanupSnapshotWhenDeleteBackup = SettingDefinition{
DisplayName: "Automatically Cleanup Snapshot When Deleting Backup",
Description: "This setting enables Longhorn to automatically cleanup snapshots when removing backup.",
Expand Down

0 comments on commit bf5ec5c

Please sign in to comment.