go-ceph: rbd stat not returning the parent image name
Not able to get the parent image name from the image stat. executed below go program to get image stat
Tested with go-ceph 0.3
package main
import (
"fmt"
"github.com/ceph/go-ceph/rados"
"github.com/ceph/go-ceph/rbd"
)
const (
poolname = "replicapool"
)
func create_conn() (conn *rados.Conn, err error) {
conn, err = rados.NewConn()
if err != nil {
return nil, fmt.Errorf("Error creating NewConn (%v)\n", err)
}
baseArgs := []string{
"-m", "10.105.235.252:6789",
"--id", "admin",
"--key=" +"AQBAgOxexraiLxAAH3YLTTXjXLLaxLRGk6szMw==",
"-c", "/etc/ceph/ceph.conf",
}
err = conn.ParseCmdLineArgs(baseArgs)
if err != nil {
return nil, fmt.Errorf("Error updating connection with args (%v) (%v)", baseArgs, err)
}
err = conn.Connect()
if err != nil {
return nil, fmt.Errorf("Error connecting to Ceph cluster (%v). Connection args (%+v)", err, baseArgs)
}
return
}
func main(){
conn, err := create_conn()
if err != nil {
fmt.Printf("Error creating connection (%v)", err)
}
defer conn.Shutdown()
ioctx, err := conn.OpenIOContext(poolname)
if err != nil {
fmt.Printf("Error creating IO context (%v)", err)
}
defer ioctx.Destroy()
name:="csi-snap-0ac326e1-b212-11ea-b8ec-0242ac110010"
image := rbd.GetImage(ioctx, name)
if image == nil {
fmt.Printf("Error getting image handle (%v)", err)
}
err = image.Open()
if err != nil {
fmt.Printf("Error opening image (%v)", err)
}
s, err := image.Stat()
if err != nil {
image.Close()
fmt.Printf("Error fetching image info (%v)", err)
}
fmt.Printf("image stats for %s is %+v\n",name,s)
}
sh-4.4# ./main
image stats for csi-snap-0ac326e1-b212-11ea-b8ec-0242ac110010 is &{Size:1073741824 Obj_size:4194304 Num_objs:256 Order:22 Block_name_prefix:rbd_data.1342dd18e86f Parent_pool:-1 Parent_name:}
Image info for same image from ceph cluster
sh-4.2# rbd info csi-snap-0ac326e1-b212-11ea-b8ec-0242ac110010 --pool=replicapool --format=json |python -mjson.tool
{
"access_timestamp": "Fri Jun 19 09:48:35 2020",
"block_name_prefix": "rbd_data.1342dd18e86f",
"create_timestamp": "Fri Jun 19 09:48:35 2020",
"features": [
"layering",
"deep-flatten",
"operations"
],
"flags": [],
"format": 2,
"id": "1342dd18e86f",
"modify_timestamp": "Fri Jun 19 09:48:35 2020",
"name": "csi-snap-0ac326e1-b212-11ea-b8ec-0242ac110010",
"object_size": 4194304,
"objects": 256,
"op_features": [
"clone-child"
],
"order": 22,
"parent": {
"id": "1122bee6774f",
"image": "csi-vol-82f6ec77-b20d-11ea-8d70-0242ac110010",
"overlap": 1073741824,
"pool": "replicapool",
"pool_namespace": "",
"snapshot": "42f2a80e-2c63-4498-9776-c5e7204d31ec",
"trash": false
},
"size": 1073741824,
"snapshot_count": 1
}
Expected Result:
The image stat should return the parent image name
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (1 by maintainers)
we can use this issue to remove the deprecated fields from go-ceph, it doesnt make sense to have ParentName in stat output as it always returns empty