Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception to start clustering K8s in v0.27.0 #1416

Closed
seungyongshim opened this issue Feb 3, 2022 · 6 comments
Closed

Exception to start clustering K8s in v0.27.0 #1416

seungyongshim opened this issue Feb 3, 2022 · 6 comments

Comments

@seungyongshim
Copy link

seungyongshim commented Feb 3, 2022

Expected Behavior

  • Deploy and Clustering on K8s
    • when to rolling update.
    • when to helm install.

Actual Behavior

  • OK : 0.26.0
  • Exception on starting : 0.27.0, 0.27.1-alpha.0.3

Steps to Reproduce the Problem

Specifications

  • Version: 0.27.0
  • Platform: AWS EKS v1.19.15-eks-9c63c4
  • Subsystem: dotnet6

StackTrace

Logs

{
	"@t": "2022-02-03T06:22:41.2010171Z",
	"@mt": "Starting Proto.Actor server on {Host}:{Port} ({Address})",
	"Host": "0.0.0.0",
	"Port": 0,
	"Address": "172.16.104.93:32815",
	"SourceContext": "Proto.Remote.GrpcNet.GrpcNetRemote"
}
{
	"@t": "2022-02-03T06:22:41.2145567Z",
	"@mt": "Starting",
	"SourceContext": "Proto.Cluster.Cluster"
}
{
	"@t": "2022-02-03T06:22:41.2479010Z",
	"@mt": "Started Cluster Gossip",
	"SourceContext": "Proto.Cluster.Gossip.Gossiper"
}
{
	"@t": "2022-02-03T06:22:41.2792984Z",
	"@mt": "[Cluster][KubernetesProvider] Registering service {PodName} on {PodIp}",
	"PodName": "aums-sendmail-6bc544c759-xj6ph",
	"PodIp": "172.16.104.93:32815",
	"SourceContext": "Proto.Cluster.Kubernetes.KubernetesProvider"
}
{
	"@t": "2022-02-03T06:22:41.8206948Z",
	"@mt": "Starting gossip loop",
	"SourceContext": "Proto.Cluster.Gossip.Gossiper"
}
{
	"@t": "2022-02-03T06:22:42.0595202Z",
	"@mt": "[Cluster][KubernetesProvider] Using Kubernetes namespace: aums",
	"SourceContext": "Proto.Cluster.Kubernetes.KubernetesProvider"
}
{
	"@t": "2022-02-03T06:22:42.0598211Z",
	"@mt": "[Cluster][KubernetesProvider] Using Kubernetes port: 32815",
	"SourceContext": "Proto.Cluster.Kubernetes.KubernetesProvider"
}
{
	"@t": "2022-02-03T06:22:42.2594518Z",
	"@mt": "[Cluster][KubernetesProvider] Unable to update pod labels, registration failed. Labels : {Labels}",
	"@l": "Error",
	"@x": "Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'BadRequest'\n   
	            at k8s.Kubernetes.SendRequestRaw(String requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken)\n   
	            at k8s.Kubernetes.PatchNamespacedPodWithHttpMessagesAsync(V1Patch body, String name, String namespaceParameter, String dryRun, String fieldManager, String fieldValidation, Nullable`1 force, Nullable`1 pretty, IDictionary`2 customHeaders, CancellationToken cancellationToken)\n   
	            at k8s.KubernetesExtensions.PatchNamespacedPodAsync(IKubernetes operations, V1Patch body, String name, String namespaceParameter, String dryRun, String fieldManager, String fieldValidation, Nullable`1 force, Nullable`1 pretty, CancellationToken cancellationToken)\n   
	            at Proto.Cluster.Kubernetes.KubernetesProvider.RegisterMemberInner()",
	"Labels": {
		"cluster.proto.actor/cluster": "Aums",
		"cluster.proto.actor/port": "32815",
		"cluster.proto.actor/member-id": "44b8842e175d4a4497e3d8762eb5d621",
		"app.kubernetes.io/instance": "aums",
		"app.kubernetes.io/name": "aums-sendmail",
		"pod-template-hash": "6bc544c759"
	},
	"SourceContext": "Proto.Cluster.Kubernetes.KubernetesProvider",
	"ExceptionDetail": {
		"HResult": -2146233088,
		"Message": "Operation returned an invalid status code 'BadRequest'",
		"Source": "KubernetesClient",
		"TargetSite": "Void MoveNext()",
		"Request": {
			"Method": {"Method": "PATCH"},
			"RequestUri": "https://172.20.0.1/api/v1/namespaces/aums/pods/aums-sendmail-6bc544c759-xj6ph",
			"Properties": {},
			"Content": {
				"operations": [
					{
						"value": {
							"cluster.proto.actor/cluster": "Aums",
							"cluster.proto.actor/port": "32815",
							"cluster.proto.actor/member-id": "44b8842e175d4a4497e3d8762eb5d621",
							"app.kubernetes.io/instance": "aums",
							"app.kubernetes.io/name": "aums-sendmail",
							"pod-template-hash": "6bc544c759"
						},
						"operationType": "Replace",
						"path": "/Metadata/Labels",
						"op": "replace"
					}
				],
				"contractResolver": {}
			},
			"Headers": {
				"Authorization" : [ "Bearer ***"                                 ],
				"Content-Type"  : [ "application/json-patch+json; charset=utf-8" ],
				"Content-Length": [ "366"                                        ]
			}
		},
		"Response": {
			"StatusCode": "BadRequest",
			"ReasonPhrase": "Bad Request",
			"Content": {
				"kind": "Status",
				"apiVersion": "v1",
				"metadata": {},
				"status": "Failure",
				"message": "json: cannot unmarshal object into Go value of type jsonpatch.Patch",
				"reason": "BadRequest",
				"code": 400
			},
			"Headers": {
				"audit-id"      : [ "f7cb6145-ed63-48cf-8b75-fbe12b43e9a2" ],
				"Cache-Control" : [ "no-cache, private"                    ],
				"Date"          : [ "Thu, 03 Feb 2022 06:22:42 GMT"        ],
				"Content-Type"  : [ "application/json"                     ],
				"Content-Length": [ "182"                                  ]
			}
		},
		"Body": null,
		"Type": "Microsoft.Rest.HttpOperationException"
	}
}
{
	"@t": "2022-02-03T06:22:42.5815750Z",
	"@mt": "Failed to register service",
	"@l": "Warning",
	"@x": "Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'BadRequest'\n   
	            at k8s.Kubernetes.SendRequestRaw(String requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken)\n   
	            at k8s.Kubernetes.PatchNamespacedPodWithHttpMessagesAsync(V1Patch body, String name, String namespaceParameter, String dryRun, String fieldManager, String fieldValidation, Nullable`1 force, Nullable`1 pretty, IDictionary`2 customHeaders, CancellationToken cancellationToken)\n   
	            at k8s.KubernetesExtensions.PatchNamespacedPodAsync(IKubernetes operations, V1Patch body, String name, String namespaceParameter, String dryRun, String fieldManager, String fieldValidation, Nullable`1 force, Nullable`1 pretty, CancellationToken cancellationToken)\n   
	            at Proto.Cluster.Kubernetes.KubernetesProvider.RegisterMemberInner()\n   
	            at Proto.Utils.Retry.Try(Func`1 body, Int32 retryCount, Int32 backoffMilliSeconds, Int32 maxBackoffMilliseconds, Action`2 onError, Action`1 onFailed, Boolean ignoreFailure)",
	"SourceContext": "Proto.Cluster.Kubernetes.KubernetesProvider",
	"ExceptionDetail": {
		"HResult": -2146233088,
		"Message": "Operation returned an invalid status code 'BadRequest'",
		"Source": "KubernetesClient",
		"TargetSite": "Void MoveNext()",
		"Request": {
			"Method": {"Method": "PATCH"},
			"RequestUri": "https://172.20.0.1/api/v1/namespaces/aums/pods/aums-sendmail-6bc544c759-xj6ph",
			"Properties": {},
			"Content": {
				"operations": [
					{
						"value": {
							"cluster.proto.actor/cluster": "Aums",
							"cluster.proto.actor/port": "32815",
							"cluster.proto.actor/member-id": "44b8842e175d4a4497e3d8762eb5d621",
							"app.kubernetes.io/instance": "aums",
							"app.kubernetes.io/name": "aums-sendmail",
							"pod-template-hash": "6bc544c759"
						},
						"operationType": "Replace",
						"path": "/Metadata/Labels",
						"op": "replace"
					}
				],
				"contractResolver": {}
			},
			"Headers": {
				"Authorization" : [ "Bearer ***"                                 ],
				"Content-Type"  : [ "application/json-patch+json; charset=utf-8" ],
				"Content-Length": [ "366"                                        ]
			}
		},
		"Response": {
			"StatusCode": "BadRequest",
			"ReasonPhrase": "Bad Request",
			"Content": {
				"kind": "Status",
				"apiVersion": "v1",
				"metadata": {},
				"status": "Failure",
				"message": "json: cannot unmarshal object into Go value of type jsonpatch.Patch",
				"reason": "BadRequest",
				"code": 400
			},
			"Headers": {
				"audit-id"      : [ "f7cb6145-ed63-48cf-8b75-fbe12b43e9a2" ],
				"Cache-Control" : [ "no-cache, private"                    ],
				"Date"          : [ "Thu, 03 Feb 2022 06:22:42 GMT"        ],
				"Content-Type"  : [ "application/json"                     ],
				"Content-Length": [ "182"                                  ]
			}
		},
		"Body": null,
		"Type": "Microsoft.Rest.HttpOperationException"
	}
}
{
	"@t": "2022-02-03T06:22:42.6090079Z",
	"@mt": "[Cluster][KubernetesProvider] Registering service {PodName} on {PodIp}",
	"PodName": "aums-sendmail-6bc544c759-xj6ph",
	"PodIp": "172.16.104.93:32815",
	"SourceContext": "Proto.Cluster.Kubernetes.KubernetesProvider"
}
.....(loop).....
@rogeralsing rogeralsing added the bug label Feb 3, 2022
@rogeralsing
Copy link
Contributor

I'm seeing the same issue in our cluster.
Looks like a change in the KubernetesClient nuget, sending bad json.

Will try to pinpoint this

@rogeralsing
Copy link
Contributor

The error returned from Kubernetes:

{
    "kind": "Status",
    "apiVersion": "v1",
    "metadata": {},
    "status": "Failure",
    "message": "json: cannot unmarshal object into Go value of type jsonpatch.Patch",
    "reason": "BadRequest",
    "code": 400
}

The payload sent.
I believe a new, invalid entry have been included in the KubernetesClient 7.x release

{
    "operations": [
        {
            "value": {
                "label xyz":"value xyz"
            },
            "operationType": "Replace", <---- This entry is not part of the Patch spec
            "path": "/Metadata/Labels",
            "op": "replace"
        }
    ],
    "contractResolver": {}
}

@rogeralsing
Copy link
Contributor

Verified now.
The KubernetesClient 6.x does not send the "operationType" entry

@rogeralsing
Copy link
Contributor

Pushed a new Proto.Actor release (preview) with the downgraded KubernetesClient

@rogeralsing
Copy link
Contributor

https://github.com/kubernetes-client/csharp/blob/8f4ee45cf38e572c56b76b684804381e13d4eac3/tests/E2E.Tests/MnikubeTests.cs#L121

Marking this up for grabs for anyone to replace the asp.net jsonpatch object we use today.

@rogeralsing
Copy link
Contributor

Done. will release a new proper release with the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants