Skip to content

Commit

Permalink
Add logs for volume attachment and detachment
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Oct 13, 2023
1 parent 6dcbb2a commit 286e6e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controller/share_manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (c *ShareManagerController) createShareManagerAttachmentTicket(sm *longhorn
}
}
if shareManagerAttachmentTicket.NodeID != sm.Status.OwnerID {
log.Infof("Attachment ticket %v request a new node %v from old node %v", shareManagerAttachmentTicket.ID, shareManagerAttachmentTicket.NodeID, sm.Status.OwnerID)
log.Infof("Attachment ticket %v request a new node %v from old node %v", shareManagerAttachmentTicket.ID, sm.Status.OwnerID, shareManagerAttachmentTicket.NodeID)
shareManagerAttachmentTicket.NodeID = sm.Status.OwnerID
}

Expand Down
9 changes: 9 additions & 0 deletions controller/volume_attachment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ func (vac *VolumeAttachmentController) handleVolumeMigrationRollback(va *longhor
}

func (vac *VolumeAttachmentController) handleVolumeDetachment(va *longhorn.VolumeAttachment, vol *longhorn.Volume) {
log := getLoggerForLHVolumeAttachment(vac.logger, va)

// Volume is already trying to detach
if vol.Spec.NodeID == "" {
return
Expand All @@ -449,6 +451,8 @@ func (vac *VolumeAttachmentController) handleVolumeDetachment(va *longhorn.Volum
return
}

log.Infof("Volume %v is selected to detach from node %v", vol.Name, vol.Spec.NodeID)

// There is no attachment ticket that request the current vol.Spec.NodeID.
// Therefore, set desire state of volume to empty
vol.Spec.NodeID = ""
Expand Down Expand Up @@ -488,6 +492,7 @@ func (vac *VolumeAttachmentController) shouldDoDetach(va *longhorn.VolumeAttachm
}

if len(currentAttachmentTickets) == 0 {
log.Infof("Should detach volume %v because there is no matching attachment ticket", vol.Spec.NodeID)
return true
}

Expand Down Expand Up @@ -549,6 +554,8 @@ func hasWorkloadTicket(attachmentTickets map[string]*longhorn.AttachmentTicket,
}

func (vac *VolumeAttachmentController) handleVolumeAttachment(va *longhorn.VolumeAttachment, vol *longhorn.Volume) {
log := getLoggerForLHVolumeAttachment(vac.logger, va)

// Wait for volume to be fully detached
if !isVolumeFullyDetached(vol) {
return
Expand All @@ -565,6 +572,8 @@ func (vac *VolumeAttachmentController) handleVolumeAttachment(va *longhorn.Volum
return
}

log.Infof("Volume %v is selected to attach to node %v, ticket +%v", vol.Name, attachmentTicket.NodeID, attachmentTicket)

vol.Spec.NodeID = attachmentTicket.NodeID
setAttachmentParameter(attachmentTicket.Parameters, vol)
}
Expand Down

0 comments on commit 286e6e6

Please sign in to comment.