Skip to content

Commit

Permalink
fix: set LHv2 DiskDriver to "auto" if unset
Browse files Browse the repository at this point in the history
We need to force DiskDriver to "auto" if it's not explicitly set,
because Longhorn also does that internally.  If we don't do this,
the subsequent reflect.DeepEqual() in LonghornV2Provisioner.Update()
will always fail because we have an empty string, but the LHN CR
will have it set to "auto" which results in a weird resync loop.

Related issue: harvester/harvester#6709

Signed-off-by: Tim Serong <[email protected]>
  • Loading branch information
tserong committed Oct 10, 2024
1 parent d5b7347 commit d08029a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/provisioner/longhornv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ func NewLHV2Provisioner(
if !cacheDiskTags.Initialized() {
return nil, errors.New(ErrorCacheDiskTagsNotInitialized)
}
if device.Spec.Provisioner.Longhorn.DiskDriver == longhornv1.DiskDriverNone {
// We need to force DiskDriver to "auto" if it's not explicitly set,
// because Longhorn also does that internally. If we don't do it
// here, the subsequent reflect.DeepEqual() in our Update() function
// will always fail because we have an empty string, but the LHN CR
// has it set to "auto" which results in a weird resync loop.
device.Spec.Provisioner.Longhorn.DiskDriver = longhornv1.DiskDriverAuto
}
baseProvisioner := &provisioner{
name: TypeLonghornV2,
blockInfo: block,
Expand Down Expand Up @@ -85,17 +93,14 @@ func (p *LonghornV2Provisioner) Provision() (isRequeueNeeded bool, err error) {
return false, err
}

// If diskDriver is an empty string, longhorn will map that to "auto" internally
diskDriver := p.device.Spec.Provisioner.Longhorn.DiskDriver

diskSpec := longhornv1.DiskSpec{
Type: longhornv1.DiskTypeBlock,
Path: devPath,
AllowScheduling: true,
EvictionRequested: false,
StorageReserved: 0,
Tags: tags,
DiskDriver: diskDriver,
DiskDriver: p.device.Spec.Provisioner.Longhorn.DiskDriver,
}

// We're intentionally not trying to sync disk tags from longhorn if the
Expand Down

0 comments on commit d08029a

Please sign in to comment.