You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using the asynchronous run method, the test found that the actual task was less than the original task. #272
By using the following asynchronous run method, saltstack has fewer actual tasks than it does in concurrent situations, What should I do? Are there any configurations that are not configured correctly?
changed the title [-]Using the asynchronous run method, the test found that there were fewer actual tasks than real tasks.[/-][+]Using the asynchronous running method, the test found that the actual task was less than the original task.[/+]on Apr 17, 2019
changed the title [-]Using the asynchronous running method, the test found that the actual task was less than the original task.[/-][+]Using the asynchronous run method, the test found that the actual task was less than the original task.[/+]on Apr 17, 2019
Hey @zhuhaolin162, what exactly do you mean when you say "saltstack has fewer actual tasks than it does in concurrent situations"? How exactly do you use this method and what is the unexpected outcome vs. the expected?
Activity
[-]Using the asynchronous run method, the test found that there were fewer actual tasks than real tasks.[/-][+]Using the asynchronous running method, the test found that the actual task was less than the original task.[/+][-]Using the asynchronous running method, the test found that the actual task was less than the original task.[/-][+]Using the asynchronous run method, the test found that the actual task was less than the original task.[/+]renner commentedon Apr 17, 2019
Hey @zhuhaolin162, what exactly do you mean when you say "saltstack has fewer actual tasks than it does in concurrent situations"? How exactly do you use this method and what is the unexpected outcome vs. the expected?
zhuhaolin162 commentedon Apr 18, 2019
Test purpose :
I want to generate 100 files in /tmp/test , but in fact it just generate 75 files(the nums is not exactly every times)
Test result:
[root@rhel72 test]# pwd
/tmp/test
[root@rhel72 test]# ls -l |grep '^-'|wc -l
75
Test code:
public static String ayscExecute(String ip, final String command) {
try {
CloseableHttpAsyncClient httpClient = HttpClientUtils.defaultClient();
SaltClient client = new SaltClient(URI.create(ConstUtils.SALT_API_URL), new HttpAsyncClientImpl(httpClient));
IPCidr target = new IPCidr(ip);
List list = new ArrayList();
list.add(command);
Runnable cleanup = () -> {
try {
httpClient.close();
} catch (Exception e) {
logger.error("close error",e);
}
};
CompletionStage<Map<String, Object>> result = client.run(ConstUtils.SALT_API_USER,
ConstUtils.SALT_API_PASSWORD, AuthModule.PAM,"local",
target,"cmd.run",list,new LinkedHashMap<>());
result
.thenAccept(t-> System.out.println(t))
.thenRun(cleanup);
}catch (Exception e){
logger.error("aysc exec failed",e);
return "fail";
}
return "ok";
}
public static void main(String[] args) {
ConstUtils.SALT_API_USER = "user";
ConstUtils.SALT_API_PASSWORD = "password";
ConstUtils.SALT_API_URL = "http://192.168.6.138:8000";
String ip = "192.168.6.138";
ExecutorService executorService = Executors.newFixedThreadPool(1);
AtomicInteger count = new AtomicInteger();
executorService.submit(()->{
for(int i=0;i<100;i++) {
int num = count.getAndIncrement();
String command = String.format("touch /tmp/test/%s;echo %s",num,num);
System.out.println(command);
String result = SaltUtil.ayscExecute(ip,command);
System.out.println(result);
}
});
}
Thank you for you help! @renner