Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2279805

Summary: runtime error: index out of range [1] with length 1
Product: Red Hat OpenStack Reporter: Robin Cernin <rcernin>
Component: collectd-libpod-statsAssignee: Yadnesh Kulkarni <ykulkarn>
Status: CLOSED MIGRATED QA Contact: Leonid Natapov <lnatapov>
Severity: high Docs Contact:
Priority: high    
Version: 17.1 (Wallaby)CC: enothen, mrunge, parthee, ykulkarn
Target Milestone: ---Keywords: Triaged, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-12-04 06:53:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Robin Cernin 2024-05-08 23:38:58 UTC
With deployed with 17.1, we hit collectd issue starting up due to the `collectd-libpod-stats/pkg/virt/virt.go:178` unable to properly split the container as it doesnt follow the naming convention with fsid for other ceph containers.
```
[root@ctrl02 ~]# cat /var/lib/containers/storage/overlay-containers/volatile-containers.json | jq .[].names | grep "ceph"
  "ceph-nfs-pacemaker"
  "ceph-<CEPH_FSID_STRING>-prometheus-ctrl02"
  "ceph-<CEPH_FSID_STRING>-grafana-ctrl02"
  "ceph-<CEPH_FSID_STRING>-alertmanager-ctrl02"
  "ceph-<CEPH_FSID_STRING>-rgw-ctrl02-utfxjj"
  "ceph-<CEPH_FSID_STRING>-mds-cephfs-ctrl02-obizhg"
  "ceph-<CEPH_FSID_STRING>-mon-ctrl02"
  "ceph-<CEPH_FSID_STRING>-node-exporter-ctrl02"
  "ceph-<CEPH_FSID_STRING>-crash-ctrl02"
  "ceph-<CEPH_FSID_STRING>-mgr-ctrl02"
```
The split fails for the ceph_service_name as it is not able to split the container name properly.

From: https://github.com/infrawatch/collectd-libpod-stats/blob/master/pkg/virt/virt.go#L178
```
					// get hostname without the domain name
					node_hostname, _ := os.Hostname()
					node_hostname = strings.Split(node_hostname, ".")[0]

					// from `container_name` get the name of the ceph service for which cgroup path is to be found
					ceph_service_name := strings.Split(container_name, node_hostname)[0]
					ceph_service_name = strings.Trim(ceph_service_name, "-")
					ceph_service_name = strings.SplitAfter(ceph_service_name, fmt.Sprintf("ceph-%s-", ceph_fsid))[1]  <= This is where the split fails
```
Traceback when starting collectd
```
    ++ cat /run_command
    + CMD='/usr/sbin/collectd -f'
    + ARGS=
    + [[ ! -n '' ]]
    + . kolla_extend_start
    + echo 'Running command: '\''/usr/sbin/collectd -f'\'''
    Running command: '/usr/sbin/collectd -f'
    + umask 0022
    + exec /usr/sbin/collectd -f
    [2024-05-09 02:18:33] plugin_load: plugin "logfile" successfully loaded.
    panic: runtime error: index out of range [1] with length 1

    goroutine 17 [running, locked to thread]:
    panic({0x7f427ee69260, 0xc00037ce40})
            /usr/lib/golang/src/runtime/panic.go:987 +0x3ba fp=0xc00015f8c0 sp=0xc00015f800 pc=0x7f427ecf643a
    runtime.goPanicIndex(0x1, 0x1)
            /usr/lib/golang/src/runtime/panic.go:113 +0x7f fp=0xc00015f900 sp=0xc00015f8c0 pc=0x7f427ecf453f
    github.com/infrawatch/collectd-libpod-stats/pkg/virt.genContainerCgroupPath(0x0, {0xc0002fdd00, 0x40}, 0x1, 0x0, {0xc0002f4468, 0x12})
            /builddir/build/BUILD/collectd-libpod-stats-1.0.5/src/github.com/infrawatch/collectd-libpod-stats/pkg/virt/virt.go:178 +0x91e fp=0xc00015fad8 sp=0xc00015f900 pc=0x7f427edf9abe
    github.com/infrawatch/collectd-libpod-stats/pkg/virt.ContainersStats({0xc00015fc30, 0x2, 0x2?})
            /builddir/build/BUILD/collectd-libpod-stats-1.0.5/src/github.com/infrawatch/collectd-libpod-stats/pkg/virt/virt.go:51 +0x285 fp=0xc00015fbe0 sp=0xc00015fad8 pc=0x7f427edf8a65
    main.(*LibpodStats).Read(0xc000014040, {0x7f427ee75ee8, 0xc00014c840})
            /builddir/build/BUILD/collectd-libpod-stats-1.0.5/src/github.com/infrawatch/collectd-libpod-stats/plugin/libpodstats.go:32 +0x65 fp=0xc00015fd58 sp=0xc00015fbe0 pc=0x7f427edfa185
    collectd.org/plugin.wrap_read_callback(0xc000006601?)
            /builddir/build/BUILD/collectd-libpod-stats-1.0.5/src/collectd.org/plugin/plugin.go:497 +0x1d1 fp=0xc00015fe18 sp=0xc00015fd58 pc=0x7f427edf22b1
    _cgoexp_cbd283888191_wrap_read_callback(0x7f422dffad7c)
            _cgo_gotypes.go:1205 +0x25 fp=0xc00015fe30 sp=0xc00015fe18 pc=0x7f427edf3f25
    runtime.cgocallbackg1(0x7f427edf3f00, 0xc00011cfe0?, 0x0)
            /usr/lib/golang/src/runtime/cgocall.go:316 +0x2c2 fp=0xc00015ff00 sp=0xc00015fe30 pc=0x7f427ecc5602
    runtime.cgocallbackg(0x0?, 0x0?, 0x0?)
            /usr/lib/golang/src/runtime/cgocall.go:235 +0x109 fp=0xc00015ff90 sp=0xc00015ff00 pc=0x7f427ecc5289
    runtime.cgocallbackg(0x7f427edf3f00, 0x7f422dffad7c, 0x0)
            <autogenerated>:1 +0x31 fp=0xc00015ffb8 sp=0xc00015ff90 pc=0x7f427ed288f1
    runtime.cgocallback(0x0, 0x0, 0x0)
            /usr/lib/golang/src/runtime/asm_amd64.s:994 +0xb3 fp=0xc00015ffe0 sp=0xc00015ffb8 pc=0x7f427ed26353
    runtime.goexit()
            /usr/lib/golang/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00015ffe8 sp=0xc00015ffe0 pc=0x7f427ed265a1
```

The problem is with the following line:
```
strings.SplitAfter(ceph_service_name, fmt.Sprintf("ceph-%s-", ceph_fsid))[1]
```

We are splitting on `fsid` but `ceph-nfs-pacemaker` doesn't have fsid. So, the split fails and we get panic.


The problem is with the following line:
```
strings.SplitAfter(ceph_service_name, fmt.Sprintf("ceph-%s-", ceph_fsid))[1]
```

We are splitting on `fsid` but `ceph-nfs-pacemaker` doesn't have fsid. So, the split fails and we get panic.