Skip to content

Commit

Permalink
Add more retries and cooldown to SKR kubeconfig initd (#924)
Browse files Browse the repository at this point in the history
Add more retries and cooldown to SKR kubeconfig init
  • Loading branch information
MarekMichali authored Jul 11, 2024
1 parent a71867d commit 68b07de
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions testing/e2e/skr/skr-test/provision/provision-skr.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ async function provisionSKRAndInitK8sConfig(options, provisioningTimeout) {
console.log('Initiating K8s client...');
await initializeK8sClient({kubeconfigPath: shoot.kubeconfig});

try {
await getSecret('sap-btp-manager', 'kyma-system');
} catch (error) {
console.log('An error occurred while testing the K8s client');
console.log('Downloading the kubeconfig once again. Trying to initialize the client one last time');
const kubeconfigPath = kcp.getKubeconfig(shoot.name);
await initializeK8sClient({kubeconfigPath: kubeconfigPath});
let retryCount = 0;
const maxRetries = 10;
const cooldown = 1000 * 60 * 1; // 1m

while (retryCount < maxRetries) {
try {
await getSecret('sap-btp-manager', 'kyma-system');
break;
} catch (error) {
console.log('An error occurred while testing the K8s client');
console.log(`Downloading the kubeconfig again. Trying to initialize the client. Retry count: ${retryCount}`);
const kubeconfigPath = kcp.getKubeconfig(shoot.name);
await initializeK8sClient({kubeconfigPath: kubeconfigPath});
retryCount++;
await new Promise((resolve) => setTimeout(resolve, cooldown));
}
}
}
console.log('Initialization of K8s finished...');
Expand Down

0 comments on commit 68b07de

Please sign in to comment.