You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2019/10/02 07:55:19 UTC
[camel-k] 04/05: fix(scale): Make sure the replicas status is taken
from the latest replica set
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 361b57331ca260e0381cf81d4801ef12bdb690f9
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Thu Sep 26 15:57:27 2019 +0200
fix(scale): Make sure the replicas status is taken from the latest replica set
---
pkg/controller/integration/monitor.go | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index 9dbb169..cbc3af5 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -79,7 +79,8 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1alpha1.I
}
// And update the scale status accordingly
if len(replicaSets.Items) > 0 {
- replicas := replicaSets.Items[0].Status.Replicas
+ replicaSet := findLatestReplicaSet(replicaSets)
+ replicas := replicaSet.Status.Replicas
if integration.Status.Replicas == nil || replicas != *integration.Status.Replicas {
integration.Status.Replicas = &replicas
}
@@ -105,3 +106,13 @@ func (action *monitorAction) getReplicaSetsForIntegration(ctx context.Context, i
}
return list, nil
}
+
+func findLatestReplicaSet(list *appsv1.ReplicaSetList) *appsv1.ReplicaSet {
+ latest := list.Items[0]
+ for i, rs := range list.Items[1:] {
+ if latest.CreationTimestamp.Before(&rs.CreationTimestamp) {
+ latest = list.Items[i+1]
+ }
+ }
+ return &latest
+}