api icon indicating copy to clipboard operation
api copied to clipboard

the namespace in pod is empty

Open paipaoso opened this issue 3 years ago • 6 comments

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 avatar Jan 19 '22 07:01 paipaoso

@paipaoso can share detail operations that you have performed?

kundan2707 avatar Jan 20 '22 11:01 kundan2707

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 avatar Jan 24 '22 02:01 paipaoso

@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.

kundan2707 avatar Jan 27 '22 12:01 kundan2707

/assign

kundan2707 avatar Mar 23 '22 11:03 kundan2707

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Jun 21 '22 11:06 k8s-triage-robot

/remove-lifecycle stale

kundan2707 avatar Jul 18 '22 07:07 kundan2707

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Oct 16 '22 08:10 k8s-triage-robot