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

The Pods status in ReplicaSet is not correct #4696

Closed
zehuaiWANG opened this issue Dec 21, 2019 · 2 comments
Closed

The Pods status in ReplicaSet is not correct #4696

zehuaiWANG opened this issue Dec 21, 2019 · 2 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@zehuaiWANG
Copy link
Contributor

zehuaiWANG commented Dec 21, 2019

hi~ everyone, I found that when replicaset gets its podInfo by following code, it only uses the label selector. I think we should add the owner reference judgment to ensure that the pod belongs to replicaset.

func getReplicaSetPodInfo(client k8sClient.Interface, replicaSet *apps.ReplicaSet) (*common.PodInfo, error) {
	labelSelector := labels.SelectorFromSet(replicaSet.Spec.Selector.MatchLabels)
	channels := &common.ResourceChannels{
		PodList: common.GetPodListChannelWithOptions(client, common.NewSameNamespaceQuery(replicaSet.Namespace),
			metaV1.ListOptions{
				LabelSelector: labelSelector.String(),
				FieldSelector: fields.Everything().String(),
			}, 1),
	}

	pods := <-channels.PodList.List
	if err := <-channels.PodList.Error; err != nil {
		return nil, err
	}

	podInfo := common.GetPodInfo(replicaSet.Status.Replicas, replicaSet.Spec.Replicas, pods.Items)
	return &podInfo, nil
}

What more, I test it by create two replcicaSet with same label selectors:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: test0
  labels:
    app: guestbook
    tier: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      labels:
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google_samples/gb-frontend:v3
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: test1
  labels:
    app: guestbook
    tier: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      labels:
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google_samples/gb-frontend:v3

and the view will be:
image

I wonder if it is a bug, if so, I am willing to submit a PR to modify it.
/assign @maciaszczykm @floreks thanks

Additional, I wonder if the front-end this part have something wrong either in the Resource Infomation:
2

@zehuaiWANG zehuaiWANG added the kind/bug Categorizes issue or PR as related to a bug. label Dec 21, 2019
@floreks
Copy link
Member

floreks commented Dec 21, 2019

First see how kubectl handles that. We want to show the same output.

@zehuaiWANG
Copy link
Contributor Author

@floreks It's not the same as the kubectl output.
5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants