@@ -54,8 +54,9 @@ type Data struct {
5454 ClusterID string
5555 ImageSource string
5656 Arch string
57- NGFResourceCounts NGFResourceCounts
57+ DeploymentID string
5858 NodeCount int
59+ NGFResourceCounts NGFResourceCounts
5960 NGFReplicaCount int
6061}
6162
@@ -101,7 +102,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
101102 return Data {}, fmt .Errorf ("failed to collect NGF resource counts: %w" , err )
102103 }
103104
104- ngfReplicaCount , err := collectNGFReplicaCount (ctx , c .cfg .K8sClientReader , c .cfg .PodNSName )
105+ ngfReplicaCount , deploymentID , err := collectNGFReplicaData (ctx , c .cfg .K8sClientReader , c .cfg .PodNSName )
105106 if err != nil {
106107 return Data {}, fmt .Errorf ("failed to collect NGF replica count: %w" , err )
107108 }
@@ -122,6 +123,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
122123 ClusterID : clusterID ,
123124 ImageSource : c .cfg .ImageSource ,
124125 Arch : runtime .GOARCH ,
126+ DeploymentID : deploymentID ,
125127 }
126128
127129 return data , nil
@@ -175,23 +177,31 @@ func collectGraphResourceCount(
175177 return ngfResourceCounts , nil
176178}
177179
178- func collectNGFReplicaCount (ctx context.Context , k8sClient client.Reader , podNSName types.NamespacedName ) (int , error ) {
180+ func collectNGFReplicaData (
181+ ctx context.Context ,
182+ k8sClient client.Reader ,
183+ podNSName types.NamespacedName ,
184+ ) (int , string , error ) {
179185 var pod v1.Pod
180186 if err := k8sClient .Get (
181187 ctx ,
182188 types.NamespacedName {Namespace : podNSName .Namespace , Name : podNSName .Name },
183189 & pod ,
184190 ); err != nil {
185- return 0 , fmt .Errorf ("failed to get NGF Pod: %w" , err )
191+ return 0 , "" , fmt .Errorf ("failed to get NGF Pod: %w" , err )
186192 }
187193
188194 podOwnerRefs := pod .GetOwnerReferences ()
189195 if len (podOwnerRefs ) != 1 {
190- return 0 , fmt .Errorf ("expected one owner reference of the NGF Pod, got %d" , len (podOwnerRefs ))
196+ return 0 , "" , fmt .Errorf ("expected one owner reference of the NGF Pod, got %d" , len (podOwnerRefs ))
191197 }
192198
193199 if podOwnerRefs [0 ].Kind != "ReplicaSet" {
194- return 0 , fmt .Errorf ("expected pod owner reference to be ReplicaSet, got %s" , podOwnerRefs [0 ].Kind )
200+ return 0 , "" , fmt .Errorf ("expected pod owner reference to be ReplicaSet, got %s" , podOwnerRefs [0 ].Kind )
201+ }
202+
203+ if podOwnerRefs [0 ].UID == "" {
204+ return 0 , "" , fmt .Errorf ("expected pod owner reference to have a UID: %v" , podOwnerRefs [0 ])
195205 }
196206
197207 var replicaSet appsv1.ReplicaSet
@@ -200,14 +210,14 @@ func collectNGFReplicaCount(ctx context.Context, k8sClient client.Reader, podNSN
200210 types.NamespacedName {Namespace : podNSName .Namespace , Name : podOwnerRefs [0 ].Name },
201211 & replicaSet ,
202212 ); err != nil {
203- return 0 , fmt .Errorf ("failed to get NGF Pod's ReplicaSet: %w" , err )
213+ return 0 , "" , fmt .Errorf ("failed to get NGF Pod's ReplicaSet: %w" , err )
204214 }
205215
206216 if replicaSet .Spec .Replicas == nil {
207- return 0 , errors .New ("replica set replicas was nil" )
217+ return 0 , "" , errors .New ("replica set replicas was nil" )
208218 }
209219
210- return int (* replicaSet .Spec .Replicas ), nil
220+ return int (* replicaSet .Spec .Replicas ), string ( podOwnerRefs [ 0 ]. UID ), nil
211221}
212222
213223// CollectClusterID gets the UID of the kube-system namespace.
0 commit comments