Replicatedctl throws "Array Index Out of Bounds Error"


#1

While trying to update to new release via dashboard Even though the previous version was updated successfully Dashboard shows error and stalls subsequent update. When tried to stop and start app replicatedctl throws array index out of bounds error.

Error Trace:

error: error executing jsonpath "{.items[0].metadata.name}": Error executing template: array index out of bounds: index 0, length 0. Printing more information for debugging the template:
template was:
	{.items[0].metadata.name}
object given to jsonpath engine was:
	map[string]interface {}{"apiVersion":"v1", "items":[]interface {}{}, "kind":"List", "metadata":map[string]interface {}{"resourceVersion":"", "selfLink":""}}

error: expected 'exec (POD | TYPE/NAME) COMMAND [ARG1] [ARG2] ... [ARGN]'.
POD or TYPE/NAME and COMMAND are required arguments for the exec command
See 'kubectl exec -h' for help and examples


#2

Can you try running kubectl get pods


#3

Yeah everything seems to be working fine.


#4

Mani, there should a a label on the replicated pod tier: master. You can see the failing command that looks for it in the /usr/local/bin/replicatedctl scrip. Can you check what labels the pod has:

kubectl get pod replicated-<generated stuff> -o yaml | grep -w -5 labels

Can you also run the following command?

kubectl get pods -l tier=master

#5

I think I found the reason for this issue.
This arises when I change my default namespace in context. This eventually means /usr/local/bin/replicatedctl should use -n default in the kubectl commands. Screenshot attached.
Should I raise an issue in any GitHub repo?


#6

Works fine after updating namespace in /usr/local/bin/replicatedctl as follows

 sh -c "kubectl -n default exec -c replicated $flags \
          $(kubectl get pods -n default -o=jsonpath="{.items[0].metadata.name}" -l tier=master) -- \
          replicatedctl$push $(printf "%s" "$opts")"


#8

we will create an internal issue to track this


#9

That would be great. Thanks.