使用fabric8 Watch API监听所有Service上的删除操作没有监听到,为什么?(可付费解决问题)
我用fabric8来监听所有Service上的删除动作,代码如下。 从代码中,我先给所有Service创建了一个Watch,然后删除service1,但是输出信息里没有打印删除信息,到是有一些ADDED信息。
我可以付钱解决这个问题。
@Test
public void testWatchServices() {
final CountDownLatch deleteLatch = new CountDownLatch(1);
final CountDownLatch closeLatch = new CountDownLatch(1);
Watch watch = client.services().inNamespace("auth").watch(new Watcher<Service>() {
@Override
public void eventReceived(Action action, Service resource) {
switch (action) {
default:
System.out.println(action+" "+resource.getMetadata().getName()+" is doing!");
// throw new AssertionFailedError(action.toString().concat(" isn't recognised."));
}
}
@Override
public void onClose(KubernetesClientException cause) {
}
});
//CREATE
if (client.pods().inNamespace("auth").withName("service1") != null) {
client.pods().inNamespace("auth").create(new PodBuilder().withNewMetadata().withName("service1").endMetadata().build());
}
// //READ
// ServiceList serviceList = client.services().inNamespace("auth").list();
// System.out.println(JSON.toJSONString(serviceList,true));
// assertNotNull(serviceList);
//DELETE
client.pods().inNamespace("auth").withName("service1").delete();
// //READ AGAIN
// serviceList = client.services().inNamespace("auth").list();
// assertNotNull(serviceList);
try {
assertTrue(deleteLatch.await(1, TimeUnit.MINUTES));
} catch (InterruptedException e) {
e.printStackTrace();
}
watch.close();
try {
assertTrue(closeLatch.await(1, TimeUnit.MINUTES));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
控制台打印信息:
ADDED auth-redis-ddb is doing!
ADDED authentication-service is doing!
ADDED auth-api is doing!
ADDED auth-jsclient is doing!
ADDED auth-api-central is doing!
ADDED authentication-facade is doing!
ADDED auth-authentication-server is doing!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为你删除pods的时候. 是不会把
service
删除的.