-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SharedIndexInformer with label filter only watching local Namespace #2801
Comments
Update: It works if I create the
|
…Selectors + Added test for SharedIndexInformer for a ServiceAccount type to monitor events filtered with labels across all namespaces and in a particular namespace to verify that the use case actually works on master. + Minor Cleanup in DefaultSharedIndexInfomerTest to avoid code duplication while setting MockServer expectations Related to fabric8io#2801
I wasn't able to reproduce this on master. I've added two tests for SharedIndexInformer for filter with labels in all namespace and in some specific namespace in #2895 |
…Selectors + Added test for SharedIndexInformer for a ServiceAccount type to monitor events filtered with labels across all namespaces and in a particular namespace to verify that the use case actually works on master. + Minor Cleanup in DefaultSharedIndexInfomerTest to avoid code duplication while setting MockServer expectations Related to #2801
This issue seems to be fixed via this PR : #2880 . Specifically this line: Line 465 in b3083a9
Here we while merging OperationContexts we pick Earlier we were just assigning argument value to current OperationContext's field, see v5.1.1 version I can confirm that my minikube's current context contained a namespace in it: - context:
cluster: minikube
extensions:
- extension:
last-update: Fri, 12 Mar 2021 15:45:33 IST
provider: minikube.sigs.k8s.io
version: v1.17.1
name: context_info
namespace: default
user: minikube
name: minikube I tested it with this code: try (KubernetesClient client = new DefaultKubernetesClient()) {
SharedInformerFactory factory = client.informers();
SharedIndexInformer<ServiceAccount> saInformer = factory.sharedIndexInformerFor(ServiceAccount.class,
new OperationContext().withLabels(Collections.singletonMap("foo", "bar")),
10 * 60 * 1000);
saInformer.addEventHandler(new ResourceEventHandler<ServiceAccount>() {
@Override
public void onAdd(ServiceAccount serviceAccount) {
System.out.printf("ADDED %s/%s\n", serviceAccount.getMetadata().getNamespace(), serviceAccount.getMetadata().getName());
}
@Override
public void onUpdate(ServiceAccount serviceAccount, ServiceAccount t1) {
System.out.printf("MODIFIED %s/%s\n", serviceAccount.getMetadata().getNamespace(), serviceAccount.getMetadata().getName());
}
@Override
public void onDelete(ServiceAccount serviceAccount, boolean b) {
System.out.printf("DELETED %s/%s\n", serviceAccount.getMetadata().getNamespace(), serviceAccount.getMetadata().getName());
}
});
factory.startAllRegisteredInformers();
Thread.sleep(30 * 160 * 1000L);
} catch (InterruptedException interruptedException) {
interruptedException.printStackTrace();
} It prints the following output:
|
I'm closing this issue since it seems to be fixed in our latest releases. Please, feel free to reopen in case the issue persists. |
I'm trying to watch all events of ServiceAccounts with a specific Label in all Namespaces of a cluster. I register a SharedIndexInformer the following way:
But i get only informed for the configured Namespace instead of all Namespaces of the cluster. I'm testing against a local CRC OCP 4.5, run the app with
mvn quarkus:dev
using Quarkus 1.11.1, K8s Client 5.0.0.The text was updated successfully, but these errors were encountered: