api
api copied to clipboard
the namespace in pod is empty
the code is as follows:
obj := &corev1.Pod{}
pod := h.Decoder.Decode(req, obj)
and output is:
&Pod{ObjectMeta:{ test-2021-10-26-06-00-1026060225-573e31ecd3e668d7c1cb- 0 0001-01-01 00:00:00 +0000 UTC <nil> <nil>
Can anyone tell me why this happened and how to fix it? thx!
@paipaoso can share detail operations that you have performed?
Thank you for your reply!
This is in a webhook func:
func (h *PodCreateHandler) Handle(ctx context.Context, req admission.Request) admission.Response {
obj := &corev1.Pod{}
err := h.Decoder.Decode(req, obj)
if err != nil {
return admission.Errored(http.StatusBadRequest, err)
}
copy := obj.DeepCopy()
when get the contex of copy, the namepsace is just nil. And I found the same issue in https://github.com/kubeflow/katib/blob/c22afe9fb550f149c225a999209b4417f14f07c4/pkg/webhook/v1beta1/pod/inject_webhook.go#L75, which seems a identified problem. But I didn't get the reason, can you pls disabuse? thx!
@paipaoso thanks for pointing out this scenario and i am also not aware of reason behind this. I will discuss on slack channel and will update here if i recieve any answer.
/assign
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale