Skip to content

Commit

Permalink
fix: always ensure endpoint creation
Browse files Browse the repository at this point in the history
Longhorn 9919

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Dec 8, 2024
1 parent 2bb7ce3 commit d9c40b0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/nvme/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,9 @@ func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceA
return dmDeviceIsBusy, errors.Wrapf(err, "failed to load device info after connecting target for NVMe initiator %s", i.Name)

Check warning on line 302 in pkg/nvme/initiator.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/initiator.go#L302

Added line #L302 was not covered by tests
}

needMakeEndpoint := true
if dmDeviceAndEndpointCleanupRequired {
if dmDeviceIsBusy {
// Endpoint is already created, just replace the target device
needMakeEndpoint = false
i.logger.Info("Linear dm device is busy, trying the best to replace the target device for NVMe initiator")

Check warning on line 308 in pkg/nvme/initiator.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/initiator.go#L308

Added line #L308 was not covered by tests
if err := i.replaceDmDeviceTarget(); err != nil {
i.logger.WithError(err).Warnf("Failed to replace the target device for NVMe initiator")

Check warning on line 310 in pkg/nvme/initiator.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/initiator.go#L310

Added line #L310 was not covered by tests
Expand All @@ -325,8 +323,14 @@ func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceA
i.dev.Export = i.dev.Nvme
}

if needMakeEndpoint {
i.logger.Infof("Creating endpoint %v", i.Endpoint)
i.logger.Infof("Creating endpoint %v", i.Endpoint)
exist, err := i.isEndpointExist()
if err != nil {
return dmDeviceIsBusy, errors.Wrapf(err, "failed to check if endpoint %v exists for NVMe initiator %s", i.Endpoint, i.Name)
}

Check warning on line 330 in pkg/nvme/initiator.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/initiator.go#L329-L330

Added lines #L329 - L330 were not covered by tests
if exist {
i.logger.Infof("Skipping endpoint %v creation for NVMe initiator %s", i.Endpoint, i.Name)

Check warning on line 332 in pkg/nvme/initiator.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/initiator.go#L332

Added line #L332 was not covered by tests
} else {
if err := i.makeEndpoint(); err != nil {
return dmDeviceIsBusy, err

Check warning on line 335 in pkg/nvme/initiator.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/initiator.go#L335

Added line #L335 was not covered by tests
}
Expand Down

0 comments on commit d9c40b0

Please sign in to comment.