Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Namespace not populated in the FederateResources response #1181

Closed
binkkatal opened this issue Jan 27, 2020 · 4 comments
Closed

Namespace not populated in the FederateResources response #1181

binkkatal opened this issue Jan 27, 2020 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@binkkatal
Copy link
Contributor

Input

federate.FederateResources(resources)

where resources contain the input kubernetes object.

{
	"apiVersion": "apps/v1",
	"kind": "Deployment",
	"metadata": {
		"creationTimestamp": null,
		"labels": {
			"run": "apiserver"
		},
		"name": "apiserver",
		"namespace": "demons"
	},
	"spec": {
		"replicas": 1,
		"selector": {
			"matchLabels": {
				"run": "apiserver"
			}
		},
		"strategy": {},
		"template": {
			"metadata": {
				"creationTimestamp": null,
				"labels": {
					"run": "apiserver"
				}
			},
			"spec": {
				"containers": [{
					"image": "biqmind/todo-api",
					"name": "apiserver",
					"ports": [{
						"containerPort": 8080
					}],
					"resources": {}
				}]
			}
		}
	},
	"status": {}
}

What happened:
The namespace was not copied in the response of federate.FederateResources(resources)

{
	"apiVersion": "types.kubefed.io/v1beta1",
	"kind": "FederatedDeployment",
	"metadata": {
		"name": "apiserver"
	},
	"spec": {
		"placement": {
			"clusterSelector": {
				"matchLabels": {}
			}
		},
		"template": {
			"metadata": {
				"labels": {
					"run": "apiserver"
				}
			},
			"spec": {
				"replicas": 1,
				"selector": {
					"matchLabels": {
						"run": "apiserver"
					}
				},
				"strategy": {},
				"template": {
					"metadata": {
						"creationTimestamp": null,
						"labels": {
							"run": "apiserver"
						}
					},
					"spec": {
						"containers": [{
							"image": "biqmind/todo-api",
							"name": "apiserver",
							"ports": [{
								"containerPort": 8080
							}],
							"resources": {}
						}]
					}
				}
			}
		}
	}
}

What you expected to happen:

{
	"apiVersion": "types.kubefed.io/v1beta1",
	"kind": "FederatedDeployment",
	"metadata": {
		"name": "apiserver",
		"namespace": "demons"
	},
	"spec": {
		"placement": {
			"clusterSelector": {
				"matchLabels": {}
			}
		},
		"template": {
			"metadata": {
				"labels": {
					"run": "apiserver"
				}
			},
			"spec": {
				"replicas": 1,
				"selector": {
					"matchLabels": {
						"run": "apiserver"
					}
				},
				"strategy": {},
				"template": {
					"metadata": {
						"creationTimestamp": null,
						"labels": {
							"run": "apiserver"
						}
					},
					"spec": {
						"containers": [{
							"image": "biqmind/todo-api",
							"name": "apiserver",
							"ports": [{
								"containerPort": 8080
							}],
							"resources": {}
						}]
					}
				}
			}
		}
	}
}

How to reproduce it (as minimally and precisely as possible):
use federate.FederateResources(resources) from the federate package

Anything else we need to know?:
would it be right to check if the object is namespaced using this code ?

if i revert this condition , i get the right response and namespaces as in the expected response.

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 27, 2020
@binkkatal binkkatal changed the title Namespace not pupulated in the FederateResources response Namespace not populated in the FederateResources response Jan 27, 2020
@xunpan
Copy link
Contributor

xunpan commented Feb 25, 2020

good catch. this is a bug.
Would you like to contribute code to fix it?

@binkkatal
Copy link
Contributor Author

@xunpan ,

Will raise a PR this weekend

binkkatal added a commit to binkkatal/kubefed that referenced this issue Mar 7, 2020
The current code checks if the api resource is namespaced or not by a faulty condition,

	`apiResource.Namespaced = targetResource.GetNamespace() == ""`

If the input kubernetes api-resource has a namespace, the above condition makes the federatedapi-resource not namespaced, due to which the namespaces are not populated in the federatedapi-resource.

Changing the above condition to

	`apiResource.Namespaced = targetResource.GetNamespace() != ""`

makes the federated-api-resource as namespaced and sets the namespace as well.

Read more on [issue#1181](kubernetes-retired#1181)
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 26, 2020
@binkkatal
Copy link
Contributor Author

Closing this under #1199

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

4 participants