diff --git a/lib/arc-login.js b/lib/arc-login.js index 26ba61c6..6482efb6 100644 --- a/lib/arc-login.js +++ b/lib/arc-login.js @@ -82,25 +82,27 @@ function getArcKubeconfig() { const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`); let azPath = yield io.which("az", true); - let out = fs.openSync('./out.log', 'a'); - let err = fs.openSync('./err.log', 'a'); + const out = fs.openSync('./out.log', 'a'); + const err = fs.openSync('./out.log', 'a'); if (method == 'service-account') { let saToken = core.getInput('token'); if (!saToken) { throw Error("'saToken' is not passed for 'service-account' method."); } console.log('using service account method for authenticating to arc cluster.'); - child_process_1.spawn(azPath, ['connectedk8s', 'proxy', '-n', clusterName, '-g', resourceGroupName, '-f', kubeconfigPath, '--token', saToken], { + const proc = child_process_1.spawn(azPath, ['connectedk8s', 'proxy', '-n', clusterName, '-g', resourceGroupName, '-f', kubeconfigPath, '--token', saToken], { detached: true, stdio: ['ignore', out, err] - }).unref(); + }); + proc.unref(); } else { console.log('using spn method for authenticating to arc cluster.'); - child_process_1.spawn(azPath, ['connectedk8s', 'proxy', '-n', clusterName, '-g', resourceGroupName, '-f', kubeconfigPath], { + const proc = child_process_1.spawn(azPath, ['connectedk8s', 'proxy', '-n', clusterName, '-g', resourceGroupName, '-f', kubeconfigPath], { detached: true, stdio: ['ignore', out, err] - }).unref(); + }); + proc.unref(); } console.log('Waiting for 2 minutes for kubeconfig to be merged....'); yield sleep(120000); //sleeping for 2 minutes to allow kubeconfig to be merged diff --git a/src/arc-login.ts b/src/arc-login.ts index 0613ad0c..23cf9f65 100644 --- a/src/arc-login.ts +++ b/src/arc-login.ts @@ -78,24 +78,26 @@ export async function getArcKubeconfig(): Promise { const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`); let azPath = await io.which("az", true); - let out = fs.openSync('./out.log', 'a'); - let err = fs.openSync('./err.log', 'a'); + const out = fs.openSync('./out.log', 'a'); + const err = fs.openSync('./out.log', 'a'); if (method == 'service-account'){ let saToken = core.getInput('token'); if(!saToken){ throw Error("'saToken' is not passed for 'service-account' method.") } console.log('using service account method for authenticating to arc cluster.') - spawn(azPath,['connectedk8s','proxy','-n',clusterName,'-g',resourceGroupName,'-f',kubeconfigPath,'--token',saToken], { + const proc=spawn(azPath,['connectedk8s','proxy','-n',clusterName,'-g',resourceGroupName,'-f',kubeconfigPath,'--token',saToken], { detached: true, stdio: [ 'ignore', out, err ] - }).unref(); + }); + proc.unref(); } else{ console.log('using spn method for authenticating to arc cluster.') - spawn(azPath,['connectedk8s','proxy','-n',clusterName,'-g',resourceGroupName,'-f',kubeconfigPath], { + const proc=spawn(azPath,['connectedk8s','proxy','-n',clusterName,'-g',resourceGroupName,'-f',kubeconfigPath], { detached: true, stdio: [ 'ignore', out, err ] - }).unref(); + }); + proc.unref(); } console.log('Waiting for 2 minutes for kubeconfig to be merged....') await sleep(120000) //sleeping for 2 minutes to allow kubeconfig to be merged