mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
rbd: remove per volume rbd-nbd logfiles on detach
- Update the meta stash with logDir details - Use the same to remove logfile on unstage/unmap to be space efficient Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
d67e88ccd0
commit
ea3def0db2
@ -275,6 +275,9 @@ func (ns *NodeServer) NodeStageVolume(
|
||||
volOptions.UnmapOptions = req.GetVolumeContext()["unmapOptions"]
|
||||
volOptions.Mounter = req.GetVolumeContext()["mounter"]
|
||||
volOptions.LogDir = req.GetVolumeContext()["cephLogDir"]
|
||||
if volOptions.LogDir == "" {
|
||||
volOptions.LogDir = defaultLogDir
|
||||
}
|
||||
|
||||
err = volOptions.Connect(cr)
|
||||
if err != nil {
|
||||
@ -827,6 +830,7 @@ func (ns *NodeServer) NodeUnstageVolume(
|
||||
encrypted: imgInfo.Encrypted,
|
||||
volumeID: req.GetVolumeId(),
|
||||
unmapOptions: imgInfo.UnmapOptions,
|
||||
logDir: imgInfo.LogDir,
|
||||
}
|
||||
if err = detachRBDImageOrDeviceSpec(ctx, dArgs); err != nil {
|
||||
util.ErrorLog(
|
||||
|
@ -88,6 +88,7 @@ type detachRBDImageArgs struct {
|
||||
encrypted bool
|
||||
volumeID string
|
||||
unmapOptions string
|
||||
logDir string
|
||||
}
|
||||
|
||||
// rbdGetDeviceList queries rbd about mapped devices and returns a list of rbdDeviceInfo
|
||||
@ -306,9 +307,6 @@ func createPath(ctx context.Context, volOpt *rbdVolume, device string, cr *util.
|
||||
}
|
||||
|
||||
if isNbd {
|
||||
if volOpt.LogDir == "" {
|
||||
volOpt.LogDir = defaultLogDir
|
||||
}
|
||||
mapArgs = append(mapArgs, "--log-file",
|
||||
getCephClientLogFileName(volOpt.VolID, volOpt.LogDir, "rbd-nbd"))
|
||||
}
|
||||
@ -341,6 +339,7 @@ func createPath(ctx context.Context, volOpt *rbdVolume, device string, cr *util.
|
||||
encrypted: volOpt.isEncrypted(),
|
||||
volumeID: volOpt.VolID,
|
||||
unmapOptions: volOpt.UnmapOptions,
|
||||
logDir: volOpt.LogDir,
|
||||
}
|
||||
detErr := detachRBDImageOrDeviceSpec(ctx, dArgs)
|
||||
if detErr != nil {
|
||||
@ -442,6 +441,13 @@ func detachRBDImageOrDeviceSpec(
|
||||
|
||||
return fmt.Errorf("rbd: unmap for spec (%s) failed (%w): (%s)", dArgs.imageOrDeviceSpec, err, stderr)
|
||||
}
|
||||
if dArgs.isNbd && dArgs.logDir != "" {
|
||||
logFile := getCephClientLogFileName(dArgs.volumeID, dArgs.logDir, "rbd-nbd")
|
||||
if err = os.Remove(logFile); err != nil {
|
||||
util.WarningLog(ctx, "failed to remove logfile: %s, error: %v",
|
||||
logFile, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -1525,6 +1525,7 @@ type rbdImageMetadataStash struct {
|
||||
NbdAccess bool `json:"accessType"`
|
||||
Encrypted bool `json:"encrypted"`
|
||||
DevicePath string `json:"device"` // holds NBD device path for now
|
||||
LogDir string `json:"logDir"` // holds the client log path
|
||||
}
|
||||
|
||||
// file name in which image metadata is stashed.
|
||||
@ -1555,6 +1556,7 @@ func stashRBDImageMetadata(volOptions *rbdVolume, metaDataPath string) error {
|
||||
imgMeta.NbdAccess = false
|
||||
if volOptions.Mounter == rbdTonbd && hasNBD {
|
||||
imgMeta.NbdAccess = true
|
||||
imgMeta.LogDir = volOptions.LogDir
|
||||
}
|
||||
|
||||
encodedBytes, err := json.Marshal(imgMeta)
|
||||
|
Loading…
Reference in New Issue
Block a user