Closed TsuyoshiUshio closed 7 years ago
Hi @rakelkar,
https://github.com/TsuyoshiUshio/KubernetesTask/issues/8
I noticed that the problem only happens when I use kubectl apply task without downloading kubectl binary. I guess the problem is asyncronous related problem between write .kubeconfig file and tl.checkPath validation. That is why, I move the sesion of the writing .kubeconfig file and make it Sync method. Now it works.
Since it might not be a cool solution. I quite new to node. If you have any cool refactoring idea, please let me know.
Ahh. I understand. we can't use await fs.writeFile(this.configfile, this.kubeconfig);
. it is converted into,,,
return __awaiter(this, void 0, void 0, function* () {
try {
tl.debug("cwd(): " + tl.cwd());
tl.debug("configfile: " + this.configfile);
yield fs.writeFile(this.configfile, this.kubeconfig);
this.kubectl.arg('--kubeconfig').arg(this.configfile);
tl.debug("settings kubectl exec perms");
tl.checkPath(this.kubectlbinary, 'kubectlBinary');
tl.checkPath(this.configfile, 'configFile');
yield this.kubectl.exec();
tl.setResult(tl.TaskResult.Succeeded, "kubectl works.");
return;
}
catch (err) {
tl.setResult(tl.TaskResult.Failed, err);
}
});
It is just added yield. yield fs.writeFile but it won't wait it. We need wrap the write file.
For this reason, writeSync might be a right solution. Since is not a big wait time.
Nice catch!
Ok! I will marge this. :)
The error only happens when I use kube apply task without downloading kubectl. The error happnens at varidation of tl.checkPath(this.configfile, 'configfile'); after the kubectl apply task, I check if these is .kubeconfig or not. It exists.
I guess the problem is asyncronous related problem. That is why, I move the sesion of the writing .kubeconfig file and make it Sync method. Now it works.