Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ChanYiLin
Copy link
Contributor

@ChanYiLin ChanYiLin commented Apr 25, 2024

ref: longhorn/longhorn#2856

  1. Add minNumberOfCopies
  2. Add nodeSelector, diskSelector
  3. Change the Spec.Disks to Spec.DiskFileSpecMap and Add evictionRequested
  4. Periodically replenish the copies if the number of healthy copies less than the minNumberOfCopies or eviction situation
    • replenishBackingImageCopies()
      • if nonFailedCopies >= MinNumberOfCopies, we check if we need to replenish one copy for eviction
        • replenish one if NonEvictingCount < MinNumberOfCopies
      • if nonFailedCopies < MinNumberOfCopies
        • replenish one copy to meet the MinNumberOfCopies requirement.
  5. Periodically delete evicted copies
    • cleanupEvictionRequestedBackingImageCopies()
      • If there is no non evicted healthy copy, don't delete the copy.
      • Otherwise, delete the evicted copy.
  6. Add concurrent-backing-image-replenish-per-node-limit to limit the number of BackingImage being synced on the same node at the same time
    • if the number = 0, longhorn won't replenish the BackingImage to new node/disk
  7. Adjust replica scheduler, replica won't be scheduled to the node where BackingImage can not be stored.

@ChanYiLin ChanYiLin self-assigned this Apr 25, 2024
Copy link

mergify bot commented Apr 25, 2024

This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏

@ChanYiLin ChanYiLin force-pushed the LH2856_BackingImage_HA branch 3 times, most recently from f6f2738 to cb486bd Compare April 26, 2024 07:21
@ChanYiLin
Copy link
Contributor Author

This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏

fixed.

@ChanYiLin ChanYiLin force-pushed the LH2856_BackingImage_HA branch 2 times, most recently from 93b1320 to d1e592d Compare April 26, 2024 09:27
@ChanYiLin
Copy link
Contributor Author

ChanYiLin commented Apr 26, 2024

Hi @shuo-wu
I don't know the context why we always keep the first prepared file when cleanup backing image file on the disk in node controller here
I think maybe there is a case when a user tries to evict the file on that node.
Besides, the first prepared file has nothing special
If all the files are failed, we still cleanup the bids.Spec.NodeID and bids.Spec.DiskUUID to restart the prepare process.

So I changed the logic to

  • only starts to cleanup backing image file on the disk when the file is transferred
  • it is okay to clean up the file on the first prepared file

WDYT?
Thansk

@ChanYiLin ChanYiLin marked this pull request as ready for review April 26, 2024 09:33
@ChanYiLin ChanYiLin force-pushed the LH2856_BackingImage_HA branch 2 times, most recently from a598b5f to 260a658 Compare April 26, 2024 15:46
Copy link

mergify bot commented Apr 27, 2024

This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏

@ChanYiLin
Copy link
Contributor Author

This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏

fixed.

@ChanYiLin ChanYiLin force-pushed the LH2856_BackingImage_HA branch 3 times, most recently from 5bcae3b to 72fc205 Compare May 2, 2024 07:52
Copy link

mergify bot commented May 2, 2024

This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏

@ChanYiLin ChanYiLin force-pushed the LH2856_BackingImage_HA branch 2 times, most recently from 2226465 to 5d5160f Compare May 23, 2024 07:06
@ChanYiLin
Copy link
Contributor Author

This pull request is now in conflict. Could you fix it @ChanYiLin? 🙏

fixed.

@innobead innobead self-requested a review May 23, 2024 07:11
@ChanYiLin ChanYiLin marked this pull request as draft May 28, 2024 13:13
ref: longhorn/longhorn 2856

Signed-off-by: Jack Lin <jack.lin@suse.com>
@ChanYiLin ChanYiLin force-pushed the LH2856_BackingImage_HA branch 2 times, most recently from 3b208ac to 0799c06 Compare May 30, 2024 04:26
@ChanYiLin ChanYiLin marked this pull request as ready for review May 30, 2024 06:49
ref: longhorn/longhorn 2856

Signed-off-by: Jack Lin <jack.lin@suse.com>
@@ -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"`
Copy link
Contributor

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

Comment on lines +238 to +248
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
Copy link
Contributor

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",
Copy link
Contributor

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

Comment on lines +420 to +427
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
}
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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

if diskSpec.EvictionRequested || node.Spec.EvictionRequested {
for _, backingImage := range diskBackingImageMap[diskUUID] {
// trigger eviction request
backingImage.Status.DiskFileStatusMap[diskUUID].EvictionRequested = true
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants