-
Notifications
You must be signed in to change notification settings - Fork 136
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
feat(backingimage): backingimage ha eviction enhancement #2742
base: master
Are you sure you want to change the base?
Conversation
This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏 |
f6f2738
to
cb486bd
Compare
fixed. |
93b1320
to
d1e592d
Compare
Hi @shuo-wu So I changed the logic to
WDYT? |
a598b5f
to
260a658
Compare
This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏 |
d17ffbf
to
b10b965
Compare
b10b965
to
bd8a313
Compare
fixed. |
5bcae3b
to
72fc205
Compare
This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏 |
2226465
to
5d5160f
Compare
fixed. |
5d5160f
to
f019cea
Compare
ref: longhorn/longhorn 2856 Signed-off-by: Jack Lin <jack.lin@suse.com>
3b208ac
to
0799c06
Compare
ref: longhorn/longhorn 2856 Signed-off-by: Jack Lin <jack.lin@suse.com>
0799c06
to
6566ee6
Compare
@@ -11,12 +11,18 @@ type BackingImage struct { | |||
|
|||
DeletionTimestamp string `json:"deletionTimestamp,omitempty" yaml:"deletion_timestamp,omitempty"` | |||
|
|||
DiskFileStatusMap map[string]BackingImageDiskFileStatus `json:"diskFileStatusMap,omitempty" yaml:"disk_file_status_map,omitempty"` | |||
DiskFileStatusMap map[string]interface{} `json:"diskFileStatusMap,omitempty" yaml:"disk_file_status_map,omitempty"` |
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.
You need to revert this automatically generated code
existingBI := bi.DeepCopy() | ||
defer func() { | ||
if err == nil { | ||
if !reflect.DeepEqual(bi.Spec, existingBI.Spec) { | ||
bi, err = m.ds.UpdateBackingImage(bi) | ||
return | ||
} | ||
} | ||
}() | ||
|
||
bi.Spec.MinNumberOfCopies = minNumberOfCopies |
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.
NIT: There is no need to do deep copy for this field check & update
Type: SettingTypeInt, | ||
Required: true, | ||
ReadOnly: false, | ||
Default: "1", |
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.
is it better to use a larger value here? For example, 3
res, err := rc.ds.CanPutBackingImageOnDisk(bi, r.Spec.DiskID) | ||
if err != nil { | ||
log.Warnf("Failed to check if backing image %v can be put on disk %v", bi.Name, r.Spec.DiskID) | ||
} | ||
if !res { | ||
log.Warnf("The backing image %v can not be put on the disk %v", bi.Name, r.Spec.DiskID) | ||
return "", nil | ||
} |
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.
Probably it's better to return an error when there is no result. Then the call can set the replica condition to false rather than keeping waiting there
@@ -4975,6 +5003,22 @@ func (s *DataStore) IsV2DataEngineDisabledForNode(nodeName string) (bool, error) | |||
return false, nil | |||
} | |||
|
|||
func (s *DataStore) GetDiskBackingImageMap(node *longhorn.Node) (map[string][]*longhorn.BackingImage, error) { |
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.
The input is not used.
// returns the first Node && the first Disk of the Node marked with condition ready and allow scheduling | ||
func (s *DataStore) GetRandomReadyNodeDisk() (*longhorn.Node, string, error) { | ||
func (s *DataStore) GetReadyNodeDiskForBackingImage(backingImage *longhorn.BackingImage, usedDisks map[string]bool) (*longhorn.Node, string, error) { |
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.
NIT: No need to input usedDisks
. The info is already in backingImage
controller/node_controller.go
Outdated
if diskSpec.EvictionRequested || node.Spec.EvictionRequested { | ||
for _, backingImage := range diskBackingImageMap[diskUUID] { | ||
// trigger eviction request | ||
backingImage.Status.DiskFileStatusMap[diskUUID].EvictionRequested = true |
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.
Wait... Should we add field EvictionRequested
in backingImage.Status.DiskFileStatusMap
?
I prefer to:
1. Not update Backing Image Status in a controller other than BackingImageController
2. If possible, evict a backing image disk file by adding this field to backingImage.Spec.Disks
. Can the implementation be similar to that of replicas?
You already add backingImage.Spec.DiskFileSpecMap[diskUUID].EvictionRequested
in the 2nd commit. Then you should call API UpdateBackingImage
instead.
ref: longhorn/longhorn#2856
minNumberOfCopies
nodeSelector
,diskSelector
Spec.Disks
toSpec.DiskFileSpecMap
and AddevictionRequested
minNumberOfCopies
or eviction situationreplenishBackingImageCopies()
nonFailedCopies >= MinNumberOfCopies
, we check if we need to replenish one copy for evictionNonEvictingCount < MinNumberOfCopies
nonFailedCopies < MinNumberOfCopies
cleanupEvictionRequestedBackingImageCopies()
concurrent-backing-image-replenish-per-node-limit
to limit the number of BackingImage being synced on the same node at the same time