protoactor-go icon indicating copy to clipboard operation
protoactor-go copied to clipboard

K8S Provider is trying to do an invalid patch operation

Open orktes opened this issue 3 years ago • 1 comments

Describe the bug After working around https://github.com/asynkron/protoactor-go/issues/652 by injecting larger timeouts into the code when receive timeout is set to 0 I ran into another issue where the provider is trying to do a patch call into the pod labels but failing with json: cannot unmarshal object into Go value of type jsonpatch.Patch.

This is caused by the k8s expecting a JSON array with patch ops rather than a single op.

https://github.com/asynkron/protoactor-go/blob/dev/cluster/clusterproviders/k8s/k8s_provider.go#L337-L345

A simple fix for the issue is to change the patch into a slice.

payload := []struct {
		Op    string `json:"op"`
		Path  string `json:"path"`
		Value Labels `json:"value"`
	}{
		{
			Op:    "replace",
			Path:  "/metadata/labels",
			Value: pod.GetLabels(),
		},
	}

I can contribute a fix once it clear what the fix for https://github.com/asynkron/protoactor-go/issues/652 is as currently my change set is just full of hacks ;)

orktes avatar Apr 21 '22 13:04 orktes

I am currently out and incapable of taking care of this but I will be back soon, I can take care of it if you are busy by then

DamnWidget avatar Apr 28 '22 08:04 DamnWidget