From 4f2a1a2c8756a0259b55f1317e5d1ad2d400d7f4 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Fri, 30 Nov 2018 20:38:50 +0100 Subject: [PATCH] check slice size --- pkg/processor/processor.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/processor/processor.go b/pkg/processor/processor.go index e8ff0cdf5..60694ca52 100644 --- a/pkg/processor/processor.go +++ b/pkg/processor/processor.go @@ -250,10 +250,12 @@ func (p *Processor) processPodEvent(c *v1.Pod) error { // Set the policy to retain name := c.Labels["component"] - name = name[14:len(name)] - p.k8sclient.UpdateVolumeReclaimPolicy(p.clusters[fmt.Sprintf("%s-%s", name, c.ObjectMeta.Namespace)].ESCluster.Spec.Storage.VolumeReclaimPolicy, c.ObjectMeta.Namespace, name) + if len(name) > 14 { + name = name[14:len(name)] + p.k8sclient.UpdateVolumeReclaimPolicy(p.clusters[fmt.Sprintf("%s-%s", name, c.ObjectMeta.Namespace)].ESCluster.Spec.Storage.VolumeReclaimPolicy, c.ObjectMeta.Namespace, name) + } return nil }