diff --git a/api/telemetry/v1alpha1/collector_types.go b/api/telemetry/v1alpha1/collector_types.go index eba1908..8a8d4ad 100644 --- a/api/telemetry/v1alpha1/collector_types.go +++ b/api/telemetry/v1alpha1/collector_types.go @@ -80,15 +80,15 @@ func (c CollectorSpec) GetMemoryLimit() *resource.Quantity { // CollectorStatus defines the observed state of Collector type CollectorStatus struct { - State State `json:"state,omitempty"` Tenants []string `json:"tenants,omitempty"` + State State `json:"state,omitempty"` } //+kubebuilder:object:root=true //+kubebuilder:resource:scope=Cluster,categories=telemetry-all //+kubebuilder:subresource:status -//+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state` //+kubebuilder:printcolumn:name="Tenants",type=string,JSONPath=`.status.tenants` +//+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state` // Collector is the Schema for the collectors API type Collector struct { diff --git a/internal/controller/telemetry/route_controller.go b/internal/controller/telemetry/route_controller.go index a3f2af6..b783f8e 100644 --- a/internal/controller/telemetry/route_controller.go +++ b/internal/controller/telemetry/route_controller.go @@ -475,26 +475,20 @@ func (r *RouteReconciler) getTenants(ctx context.Context, listOpts *client.ListO } func (r *RouteReconciler) checkBridgeConnections(ctx context.Context, bridge *v1alpha1.Bridge) error { - listOpts := &client.ListOptions{ - FieldSelector: fields.OneTermEqualSelector(tenantNameField, bridge.Spec.SourceTenant), - } - sourceTenant, err := r.getTenants(ctx, listOpts) - if err != nil { - return err - } - if len(sourceTenant) != 1 && sourceTenant[0].Name != bridge.Spec.SourceTenant { - return errors.Errorf("bridge (%s) has invalid source tenant", bridge.Name) - } - - listOpts = &client.ListOptions{ - FieldSelector: fields.OneTermEqualSelector(tenantNameField, bridge.Spec.TargetTenant), - } - targetTenant, err := r.getTenants(ctx, listOpts) - if err != nil { - return err - } - if len(targetTenant) != 1 && targetTenant[0].Name != bridge.Spec.TargetTenant { - return errors.Errorf("bridge (%s) has invalid target tenant", bridge.Name) + for _, tenant := range []string{bridge.Spec.SourceTenant, bridge.Spec.TargetTenant} { + listOpts := &client.ListOptions{ + FieldSelector: fields.OneTermEqualSelector(tenantNameField, tenant), + } + tenants, err := r.getTenants(ctx, listOpts) + if err != nil { + return err + } + if len(tenants) == 0 { + return errors.Errorf("tenant: %s not found for bridge: %s", tenant, bridge.Name) + } + if len(tenants) != 1 || tenants[0].Name != tenant { + return errors.Errorf("bridge: %s has invalid tenant reference: %s", bridge.Name, tenant) + } } return nil