From d621ae1ce7d1918502f71fbbd08f63ed70a59647 Mon Sep 17 00:00:00 2001 From: Atharva Mulmuley Date: Thu, 29 Apr 2021 13:44:22 +0530 Subject: [PATCH] trying a fix for self-hosted agent --- lib/arc-login.js | 4 +++- src/arc-login.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/arc-login.js b/lib/arc-login.js index 3dde00f4..294bdadc 100644 --- a/lib/arc-login.js +++ b/lib/arc-login.js @@ -15,6 +15,7 @@ const querystring = require("querystring"); const az_login = require("./main"); const path = require("path"); const child_process_1 = require("child_process"); +const fs = require("fs"); function getAzureAccessToken(servicePrincipalId, servicePrincipalKey, tenantId, authorityUrl, managementEndpointUrl) { return __awaiter(this, void 0, void 0, function* () { if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !authorityUrl) { @@ -71,6 +72,7 @@ function getArcKubeconfig() { yield az_login.executeAzCliCommand(`account show`, false); yield az_login.executeAzCliCommand(`extension add -n connectedk8s`, false); yield az_login.executeAzCliCommand(`extension list`, false); + yield az_login.executeAzCliCommand(`connectedk8s --help`, false); const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`); if (method == 'service-account') { @@ -93,7 +95,7 @@ function getArcKubeconfig() { } console.log('Waiting for 2 minutes for kubeconfig to be merged....'); yield sleep(120000); //sleeping for 2 minutes to allow kubeconfig to be merged - //fs.chmodSync(kubeconfigPath, '600'); + fs.chmodSync(kubeconfigPath, '600'); core.exportVariable('KUBECONFIG', kubeconfigPath); console.log('KUBECONFIG environment variable is set'); } diff --git a/src/arc-login.ts b/src/arc-login.ts index 95b937e9..29c40ce2 100644 --- a/src/arc-login.ts +++ b/src/arc-login.ts @@ -68,6 +68,7 @@ export async function getArcKubeconfig(): Promise { await az_login.executeAzCliCommand(`account show`, false); await az_login.executeAzCliCommand(`extension add -n connectedk8s`, false); await az_login.executeAzCliCommand(`extension list`, false); + await az_login.executeAzCliCommand(`connectedk8s --help`, false); const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`); if (method == 'service-account'){ @@ -89,7 +90,7 @@ export async function getArcKubeconfig(): Promise { } console.log('Waiting for 2 minutes for kubeconfig to be merged....') await sleep(120000) //sleeping for 2 minutes to allow kubeconfig to be merged - //fs.chmodSync(kubeconfigPath, '600'); + fs.chmodSync(kubeconfigPath, '600'); core.exportVariable('KUBECONFIG', kubeconfigPath); console.log('KUBECONFIG environment variable is set'); } catch (ex) {