Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to reduce deployment failures due to ingress configuration delays #739

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/deploy-tes-on-azure/Deployer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,13 @@ await PerformHelmDeploymentAsync(resourceGroup,
await ExecuteQueriesOnAzurePostgreSQLDbFromK8(kubernetesClient, deploymentName, deploymentNamespace);
await kubernetesClient.AppsV1.DeleteNamespacedDeploymentAsync(deploymentName, deploymentNamespace, cancellationToken: cts.Token);


if (configuration.EnableIngress.GetValueOrDefault())
{
var tmpValues = await kubernetesManager.ConfigureAltLocalValuesYamlAsync("no-ingress.yml", values => values.Service["enableIngress"] = $"{false}");
var backupValues = kubernetesManager.SwapLocalValuesYaml(tmpValues);
await kubernetesManager.DeployHelmChartToClusterAsync(kubernetesClient);
kubernetesManager.RestoreLocalValuesYaml(backupValues);

await Execute(
$"Enabling Ingress {kubernetesManager.TesHostname}",
async () =>
Expand Down
22 changes: 22 additions & 0 deletions src/deploy-tes-on-azure/KubernetesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ await ExecHelmProcessAsync($"upgrade --install tesonazure ./helm --kubeconfig \"
workingDirectory: workingDirectoryTemp);
await WaitForWorkloadAsync(kubernetesClient, "tes", configuration.AksCoANamespace, cancellationToken);
}

public async Task RemovePodAadChart()
{
await ExecHelmProcessAsync($"uninstall aad-pod-identity", throwOnNonZeroExitCode: false);
Expand Down Expand Up @@ -300,6 +301,27 @@ public async Task UpgradeValuesYamlAsync(IStorageAccount storageAccount, Diction
await Deployer.UploadTextToStorageAccountAsync(storageAccount, Deployer.ConfigurationContainerName, "aksValues.yaml", valuesString, cancellationToken);
}

public async Task<FileInfo> ConfigureAltLocalValuesYamlAsync(string altName, Action<HelmValues> configure)
{
FileInfo altValues = new(Path.Combine(Path.GetDirectoryName(TempHelmValuesYamlPath), altName));
var values = KubernetesYaml.Deserialize<HelmValues>(await File.ReadAllTextAsync(TempHelmValuesYamlPath, cancellationToken));
configure(values);
await File.WriteAllTextAsync(altValues.FullName, KubernetesYaml.Serialize(values), cancellationToken);
return altValues;
}

public FileInfo SwapLocalValuesYaml(FileInfo file)
{
FileInfo backup = new(Path.Combine(file.DirectoryName, "backup.bak"));
File.Replace(file.FullName, TempHelmValuesYamlPath, backup.FullName);
return backup;
}

public void RestoreLocalValuesYaml(FileInfo backup)
{
File.Replace(backup.FullName, TempHelmValuesYamlPath, default);
}

public async Task<Dictionary<string, string>> GetAKSSettingsAsync(IStorageAccount storageAccount)
{
var values = KubernetesYaml.Deserialize<HelmValues>(await Deployer.DownloadTextFromStorageAccountAsync(storageAccount, Deployer.ConfigurationContainerName, "aksValues.yaml", cancellationToken));
Expand Down
Loading