@@ -127,33 +127,32 @@ func UpdateNodeDisruptionMetrics(nd *nodedisruptionv1alpha1.NodeDisruption) {
127
127
nd_state := 0
128
128
if nd .Status .State == nodedisruptionv1alpha1 .Pending {
129
129
nd_state = 0
130
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Pending )).Set (1 )
131
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Granted )).Set (0 )
132
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Rejected )).Set (0 )
130
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Pending ), nd . Spec . Type ).Set (1 )
131
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Granted ), nd . Spec . Type ).Set (0 )
132
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Rejected ), nd . Spec . Type ).Set (0 )
133
133
} else if nd .Status .State == nodedisruptionv1alpha1 .Rejected {
134
134
nd_state = - 1
135
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Pending )).Set (0 )
136
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Rejected )).Set (1 )
137
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Granted )).Set (0 )
135
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Pending ), nd . Spec . Type ).Set (0 )
136
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Rejected ), nd . Spec . Type ).Set (1 )
137
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Granted ), nd . Spec . Type ).Set (0 )
138
138
} else if nd .Status .State == nodedisruptionv1alpha1 .Granted {
139
139
nd_state = 1
140
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Pending )).Set (0 )
141
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Rejected )).Set (0 )
142
- NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Granted )).Set (1 )
140
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Pending ), nd . Spec . Type ).Set (0 )
141
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Rejected ), nd . Spec . Type ).Set (0 )
142
+ NodeDisruptionStateAsLabel .WithLabelValues (nd .Name , string (nodedisruptionv1alpha1 .Granted ), nd . Spec . Type ).Set (1 )
143
143
}
144
- NodeDisruptionStateAsValue .WithLabelValues (nd .Name ).Set (float64 (nd_state ))
145
- NodeDisruptionCreated .WithLabelValues (nd .Name ).Set (float64 (nd .CreationTimestamp .Unix ()))
144
+ NodeDisruptionStateAsValue .WithLabelValues (nd .Name , nd . Spec . Type ).Set (float64 (nd_state ))
145
+ NodeDisruptionCreated .WithLabelValues (nd .Name , nd . Spec . Type ).Set (float64 (nd .CreationTimestamp .Unix ()))
146
146
// Deadline might not be set so it will be 0 but timestamp in Go are not Unix epoch
147
147
// so converting a 0 timestamp will not result in epoch 0. We override this to have nice values
148
148
deadline := nd .Spec .Retry .Deadline .Unix ()
149
149
if nd .Spec .Retry .Deadline .IsZero () {
150
150
deadline = 0
151
151
}
152
- NodeDisruptionDeadline .WithLabelValues (nd .Name ).Set (float64 (deadline ))
153
- NodeDisruptionType .WithLabelValues (nd .Name , nd .Spec .Type ).Set (1 )
152
+ NodeDisruptionDeadline .WithLabelValues (nd .Name , nd .Spec .Type ).Set (float64 (deadline ))
154
153
155
154
for _ , node_name := range nd .Status .DisruptedNodes {
156
- NodeDisruptionImpactedNodes .WithLabelValues (nd .Name , node_name ).Set (1 )
155
+ NodeDisruptionImpactedNodes .WithLabelValues (nd .Name , node_name , nd . Spec . Type ).Set (1 )
157
156
}
158
157
}
159
158
@@ -200,9 +199,9 @@ func (ndr *SingleNodeDisruptionReconciler) TryTransitionState(ctx context.Contex
200
199
return err
201
200
}
202
201
if ndr .NodeDisruption .Status .State == nodedisruptionv1alpha1 .Granted {
203
- NodeDisruptionGrantedTotal .WithLabelValues ().Inc ()
202
+ NodeDisruptionGrantedTotal .WithLabelValues (ndr . NodeDisruption . Spec . Type ).Inc ()
204
203
} else if ndr .NodeDisruption .Status .State == nodedisruptionv1alpha1 .Rejected {
205
- NodeDisruptionRejectedTotal .WithLabelValues ().Inc ()
204
+ NodeDisruptionRejectedTotal .WithLabelValues (ndr . NodeDisruption . Spec . Type ).Inc ()
206
205
}
207
206
}
208
207
// If the disruption is not Pending nor unknown, the state is final
0 commit comments