mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
rbd: rbd-nbd logging the ceph-CSI way
- One logfile per device/volume - Add ability to customize the logdir, default: /var/log/ceph Note: if user customizes the hostpath to something else other than default /var/log/ceph, then it is his responsibility to update the `cephLogDir` in storageclass to reflect the same with daemon: ``` cephLogDir: "/var/log/mynewpath" ``` Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
0be7024726
commit
682b3a980b
@ -69,6 +69,12 @@ parameters:
|
|||||||
# on supported nodes
|
# on supported nodes
|
||||||
# mounter: rbd-nbd
|
# mounter: rbd-nbd
|
||||||
|
|
||||||
|
# (optional) ceph client log location, eg: rbd-nbd
|
||||||
|
# By default host-path /var/log/ceph of node is bind-mounted into
|
||||||
|
# csi-rbdplugin pod at /var/log/ceph mount path. See docs/rbd-nbd.md
|
||||||
|
# for available configuration options.
|
||||||
|
# cephLogDir: /var/log/ceph
|
||||||
|
|
||||||
# (optional) Prefix to use for naming RBD images.
|
# (optional) Prefix to use for naming RBD images.
|
||||||
# If omitted, defaults to "csi-vol-".
|
# If omitted, defaults to "csi-vol-".
|
||||||
# volumeNamePrefix: "foo-bar-"
|
# volumeNamePrefix: "foo-bar-"
|
||||||
|
@ -274,6 +274,7 @@ func (ns *NodeServer) NodeStageVolume(
|
|||||||
volOptions.MapOptions = req.GetVolumeContext()["mapOptions"]
|
volOptions.MapOptions = req.GetVolumeContext()["mapOptions"]
|
||||||
volOptions.UnmapOptions = req.GetVolumeContext()["unmapOptions"]
|
volOptions.UnmapOptions = req.GetVolumeContext()["unmapOptions"]
|
||||||
volOptions.Mounter = req.GetVolumeContext()["mounter"]
|
volOptions.Mounter = req.GetVolumeContext()["mounter"]
|
||||||
|
volOptions.LogDir = req.GetVolumeContext()["cephLogDir"]
|
||||||
|
|
||||||
err = volOptions.Connect(cr)
|
err = volOptions.Connect(cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -296,6 +296,14 @@ func createPath(ctx context.Context, volOpt *rbdVolume, device string, cr *util.
|
|||||||
util.WarningLog(ctx, "failed to detect if image %q is thick-provisioned: %v", volOpt, err)
|
util.WarningLog(ctx, "failed to detect if image %q is thick-provisioned: %v", volOpt, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isNbd {
|
||||||
|
if volOpt.LogDir == "" {
|
||||||
|
volOpt.LogDir = defaultLogDir
|
||||||
|
}
|
||||||
|
mapArgs = append(mapArgs, "--log-file",
|
||||||
|
getCephClientLogFileName(volOpt.VolID, volOpt.LogDir, "rbd-nbd"))
|
||||||
|
}
|
||||||
|
|
||||||
cli := rbd
|
cli := rbd
|
||||||
if device != "" {
|
if device != "" {
|
||||||
// TODO: use rbd cli for attach/detach in the future
|
// TODO: use rbd cli for attach/detach in the future
|
||||||
|
@ -50,6 +50,7 @@ const (
|
|||||||
rbdImageWatcherSteps = 10
|
rbdImageWatcherSteps = 10
|
||||||
rbdDefaultMounter = "rbd"
|
rbdDefaultMounter = "rbd"
|
||||||
rbdNbdMounter = "rbd-nbd"
|
rbdNbdMounter = "rbd-nbd"
|
||||||
|
defaultLogDir = "/var/log/ceph"
|
||||||
|
|
||||||
// Output strings returned during invocation of "ceph rbd task add remove <imagespec>" when
|
// Output strings returned during invocation of "ceph rbd task add remove <imagespec>" when
|
||||||
// command is not supported by ceph manager. Used to check errors and recover when the command
|
// command is not supported by ceph manager. Used to check errors and recover when the command
|
||||||
@ -136,6 +137,7 @@ type rbdVolume struct {
|
|||||||
ReservedID string
|
ReservedID string
|
||||||
MapOptions string
|
MapOptions string
|
||||||
UnmapOptions string
|
UnmapOptions string
|
||||||
|
LogDir string
|
||||||
VolName string `json:"volName"`
|
VolName string `json:"volName"`
|
||||||
MonValueFromSecret string `json:"monValueFromSecret"`
|
MonValueFromSecret string `json:"monValueFromSecret"`
|
||||||
VolSize int64 `json:"volSize"`
|
VolSize int64 `json:"volSize"`
|
||||||
@ -2002,3 +2004,16 @@ func (ri *rbdImage) addSnapshotScheduling(
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getCephClientLogFileName compiles the complete log file path based on inputs.
|
||||||
|
func getCephClientLogFileName(id, logDir, prefix string) string {
|
||||||
|
if prefix == "" {
|
||||||
|
prefix = "ceph"
|
||||||
|
}
|
||||||
|
|
||||||
|
if logDir == "" {
|
||||||
|
logDir = defaultLogDir
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s/%s-%s.log", logDir, prefix, id)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user