Skip to content

Commit

Permalink
fix(backingimage): set default min number of copies when upgrading
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 9352

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin authored and c3y1huang committed Aug 30, 2024
1 parent c7c0d2f commit 68a4591
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion types/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (

// From `maximumChainLength` in longhorn-engine/pkg/replica/replica.go
MaxSnapshotNum = 250

DefaultMinNumberOfCopies = 3
)

type SettingType string
Expand Down Expand Up @@ -1463,7 +1465,7 @@ var (
Type: SettingTypeInt,
Required: true,
ReadOnly: false,
Default: "3",
Default: strconv.Itoa(DefaultMinNumberOfCopies),
ValueIntRange: map[string]int{
ValueIntRangeMinimum: 1,
},
Expand Down
3 changes: 3 additions & 0 deletions upgrade/v16xto170/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"

"github.com/longhorn/longhorn-manager/types"
"github.com/longhorn/longhorn-manager/util"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
Expand Down Expand Up @@ -131,6 +132,8 @@ func upgradeBackingImages(namespace string, lhClient *lhclientset.Clientset, res
delete(bi.Spec.Disks, diskUUID)
}
}
// set the default value for bi.Spec.MinNumberOfCopies
bi.Spec.MinNumberOfCopies = types.DefaultMinNumberOfCopies
}

return nil
Expand Down

0 comments on commit 68a4591

Please sign in to comment.