Skip to content

Commit

Permalink
fix: revert "skip collection of deployments with 0 replicas" (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenorgate authored Jul 11, 2024
1 parent 4c6fd6c commit 3d6f471
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
17 changes: 1 addition & 16 deletions internal/services/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,22 +741,7 @@ func getDefaultInformers(f informers.SharedInformerFactory, castwareNamespace st
reflect.TypeOf(&corev1.PersistentVolumeClaim{}): {informer: f.Core().V1().PersistentVolumeClaims().Informer()},
reflect.TypeOf(&corev1.ReplicationController{}): {informer: f.Core().V1().ReplicationControllers().Informer()},
reflect.TypeOf(&corev1.Namespace{}): {informer: f.Core().V1().Namespaces().Informer()},
reflect.TypeOf(&appsv1.Deployment{}): {
informer: f.Apps().V1().Deployments().Informer(),
filters: filters.Filters{
{
func(e castai.EventType, obj interface{}) bool {
deployment, ok := obj.(*appsv1.Deployment)
if !ok {
return false
}

return deployment.Namespace == castwareNamespace ||
(deployment.Spec.Replicas != nil && *deployment.Spec.Replicas > 0 && deployment.Status.Replicas > 0)
},
},
},
},
reflect.TypeOf(&appsv1.Deployment{}): {informer: f.Apps().V1().Deployments().Informer()},
reflect.TypeOf(&appsv1.ReplicaSet{}): {
informer: f.Apps().V1().ReplicaSets().Informer(),
filters: filters.Filters{
Expand Down
36 changes: 0 additions & 36 deletions internal/services/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,14 +887,6 @@ func TestDefaultInformers_MatchFilters(t *testing.T) {
},
expectedMatch: true,
},
"keep if deployment in castware namespace": {
obj: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "castware",
},
},
expectedMatch: true,
},
"discard if replicaset has zero replicas": {
obj: &appsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -909,20 +901,6 @@ func TestDefaultInformers_MatchFilters(t *testing.T) {
},
expectedMatch: false,
},
"discard if deployment has zero replicas": {
obj: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
},
Spec: appsv1.DeploymentSpec{
Replicas: lo.ToPtr(int32(0)),
},
Status: appsv1.DeploymentStatus{
Replicas: 0,
},
},
expectedMatch: false,
},
"keep if replicaset has more than zero replicas": {
obj: &appsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -937,20 +915,6 @@ func TestDefaultInformers_MatchFilters(t *testing.T) {
},
expectedMatch: true,
},
"keep if deployment has more than zero replicas": {
obj: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
},
Spec: appsv1.DeploymentSpec{
Replicas: lo.ToPtr(int32(1)),
},
Status: appsv1.DeploymentStatus{
Replicas: 1,
},
},
expectedMatch: true,
},
}

for name, data := range tests {
Expand Down

0 comments on commit 3d6f471

Please sign in to comment.