Skip to content

Commit

Permalink
fix incorrect reporting of replicaset DesiredReplicas
Browse files Browse the repository at this point in the history
ReplicaSetSpec.Replicas is an *int32. Just like in DeploymentSpec,
where we deal with that in the same way.
  • Loading branch information
rade committed Nov 30, 2017
1 parent d6e47c0 commit 914acf6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion probe/kubernetes/replica_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ func (r *replicaSet) AddParent(topology, id string) {
}

func (r *replicaSet) GetNode(probeID string) report.Node {
// Spec.Replicas can be omitted, and the pointer will be nil. It defaults to 1.
desiredReplicas := 1
if r.Spec.Replicas != nil {
desiredReplicas = int(*r.Spec.Replicas)
}
return r.MetaNode(report.MakeReplicaSetNodeID(r.UID())).WithLatests(map[string]string{
ObservedGeneration: fmt.Sprint(r.Status.ObservedGeneration),
Replicas: fmt.Sprint(r.Status.Replicas),
DesiredReplicas: fmt.Sprint(r.Spec.Replicas),
DesiredReplicas: fmt.Sprint(desiredReplicas),
FullyLabeledReplicas: fmt.Sprint(r.Status.FullyLabeledReplicas),
report.ControlProbeID: probeID,
}).WithParents(r.parents).WithLatestActiveControls(ScaleUp, ScaleDown)
Expand Down

0 comments on commit 914acf6

Please sign in to comment.