ci: extra commit will be dropped

This is extra commit will be dropped

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2024-11-21 13:38:49 +01:00
parent e4d6e19554
commit 2ac83b6e73

View File

@ -279,54 +279,88 @@ func GetGlobalMirrorGroupStatus(ioctx *rados.IOContext, groupName string) (Globa
s := C.rbd_mirror_group_global_status_t{} s := C.rbd_mirror_group_global_status_t{}
cGroupName := C.CString(groupName) cGroupName := C.CString(groupName)
defer C.free(unsafe.Pointer(cGroupName)) defer C.free(unsafe.Pointer(cGroupName))
// ret := C.rbd_mirror_group_get_global_status( ret := C.rbd_mirror_group_get_global_status(
// cephIoctx(ioctx), cephIoctx(ioctx),
// (*C.char)(cGroupName), (*C.char)(cGroupName),
// &s, &s,
// C.sizeof_rbd_mirror_group_global_status_t) C.sizeof_rbd_mirror_group_global_status_t)
// if err := getError(ret); err != nil { if err := getError(ret); err != nil {
// return GlobalMirrorGroupStatus{}, err return GlobalMirrorGroupStatus{}, err
// } }
status := newGlobalMirrorGroupStatus(&s) status := newGlobalMirrorGroupStatus(&s)
return status, nil return status, nil
} }
func newGlobalMirrorGroupStatus( func newGlobalMirrorGroupStatus(s *C.rbd_mirror_group_global_status_t) GlobalMirrorGroupStatus {
s *C.rbd_mirror_group_global_status_t) GlobalMirrorGroupStatus { // Initializing the status object
status := GlobalMirrorGroupStatus{ status := GlobalMirrorGroupStatus{
Name: C.GoString(s.name), Name: C.GoString(s.name),
Info: convertMirrorGroupInfo(&s.info), Info: convertMirrorGroupInfo(&s.info),
SiteStatusesCount: int(s.site_statuses_count), SiteStatusesCount: int(s.site_statuses_count),
SiteStatuses: make([]SiteMirrorGroupStatus, s.site_statuses_count), SiteStatuses: make([]SiteMirrorGroupStatus, s.site_statuses_count),
} }
gsscs := (*groupSiteArray)(unsafe.Pointer(s.site_statuses))[:s.site_statuses_count:s.site_statuses_count]
for i := C.uint32_t(0); i < s.site_statuses_count; i++ {
gss := gsscs[i]
status.SiteStatuses[i] = SiteMirrorGroupStatus{
MirrorUUID: C.GoString(gss.mirror_uuid),
MirrorImageGlobalIDs: C.GoString(*gss.mirror_image_global_ids),
MirrorImagePoolIDs: int64(*gss.mirror_image_pool_ids),
State: MirrorGroupStatusState(gss.state),
Description: C.GoString(gss.description),
MirrorImageCount: int(gss.mirror_image_count),
LastUpdate: int64(gss.last_update),
MirrorImages: make([]SiteMirrorImageStatus, gss.mirror_image_count),
Up: bool(gss.up),
}
sscs := (*siteArray)(unsafe.Pointer(gss.mirror_images))[:gss.mirror_image_count:gss.mirror_image_count] // Print the count of site statuses for debugging
for i := C.uint32_t(0); i < gss.mirror_image_count; i++ { fmt.Println("status.SiteStatusesCount: ", s.site_statuses_count)
ss := sscs[i]
status.SiteStatuses[i].MirrorImages[i] = SiteMirrorImageStatus{ fmt.Printf("s.site_statuses: %+v\n", s.site_statuses)
MirrorUUID: C.GoString(ss.mirror_uuid), // Check if site statuses are not null before using them
State: MirrorImageStatusState(ss.state), if s.site_statuses != nil && s.site_statuses_count > 0 {
Description: C.GoString(ss.description), gsscs := (*groupSiteArray)(unsafe.Pointer(s.site_statuses))[:s.site_statuses_count:s.site_statuses_count]
LastUpdate: int64(ss.last_update), for i := C.uint32_t(0); i < s.site_statuses_count; i++ {
Up: bool(ss.up), gss := gsscs[i]
fmt.Printf("gss.groupSiteArray: %+v\n", gss)
// Ensure that fields are valid before using them
if gss.mirror_uuid != nil && gss.mirror_image_global_ids != nil {
status.SiteStatuses[i] = SiteMirrorGroupStatus{
MirrorUUID: C.GoString(gss.mirror_uuid),
MirrorImageGlobalIDs: C.GoString(*gss.mirror_image_global_ids),
MirrorImagePoolIDs: int64(*gss.mirror_image_pool_ids),
State: MirrorGroupStatusState(gss.state),
Description: C.GoString(gss.description),
MirrorImageCount: int(gss.mirror_image_count),
LastUpdate: int64(gss.last_update),
MirrorImages: make([]SiteMirrorImageStatus, gss.mirror_image_count),
Up: bool(gss.up),
}
// Check if the mirror_images pointer is valid
if gss.mirror_images != nil && gss.mirror_image_count > 0 {
sscs := (*siteArray)(unsafe.Pointer(gss.mirror_images))[:gss.mirror_image_count:gss.mirror_image_count]
fmt.Printf("sscs: siteArray %+v\n", sscs)
for j := C.uint32_t(0); j < gss.mirror_image_count; j++ {
ss := sscs[j]
// Ensure that fields are valid before using them
if ss.mirror_uuid != nil {
status.SiteStatuses[i].MirrorImages[j] = SiteMirrorImageStatus{
MirrorUUID: C.GoString(ss.mirror_uuid),
State: MirrorImageStatusState(ss.state),
Description: C.GoString(ss.description),
LastUpdate: int64(ss.last_update),
Up: bool(ss.up),
}
} else {
// Log if a field is invalid
fmt.Println("Warning: mirror_uuid is nil at index", i, j)
}
}
} else {
// Handle case where mirror_images is nil or mirror_image_count is 0
fmt.Println("Warning: mirror_images is nil or mirror_image_count is 0 at index", i)
}
} else {
// Handle case where mirror_uuid or mirror_image_global_ids is nil
fmt.Println("Warning: mirror_uuid or mirror_image_global_ids is nil at index", i)
} }
} }
} else {
// Handle case where site statuses are nil or count is 0
fmt.Println("Warning: site_statuses is nil or site_statuses_count is 0")
} }
// Return the populated status
return status return status
} }