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

Fixes edge case issue of a false positive AKS deployment failure #3492

Merged
merged 1 commit into from
Mar 7, 2024
Merged
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
16 changes: 9 additions & 7 deletions cli/azd/pkg/project/service_target_aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ func (t *aksTarget) Deploy(
deployed = deployed || kustomizeDeployed

// Vanilla k8s manifests with minimal templating support
deployment, err := t.deployManifests(ctx, serviceConfig, task)
manifestsDeployed, deployment, err := t.deployManifests(ctx, serviceConfig, task)
if err != nil && !os.IsNotExist(err) {
task.SetError(err)
return
}

deployed = deployed || deployment != nil
deployed = deployed || manifestsDeployed

if !deployed {
task.SetError(errors.New("no deployment manifests found"))
Expand Down Expand Up @@ -297,7 +297,7 @@ func (t *aksTarget) deployManifests(
ctx context.Context,
serviceConfig *ServiceConfig,
task *async.TaskContextWithProgress[*ServiceDeployResult, ServiceProgress],
) (*kubectl.Deployment, error) {
) (bool, *kubectl.Deployment, error) {
wbreza marked this conversation as resolved.
Show resolved Hide resolved
deploymentPath := serviceConfig.K8s.DeploymentPath
if deploymentPath == "" {
deploymentPath = defaultDeploymentPath
Expand All @@ -307,7 +307,7 @@ func (t *aksTarget) deployManifests(

// Manifests are optional so we will continue if the directory does not exist
if _, err := os.Stat(deploymentPath); os.IsNotExist(err) {
return nil, err
return false, nil, err
}

task.SetProgress(NewServiceProgress("Applying k8s manifests"))
Expand All @@ -317,7 +317,7 @@ func (t *aksTarget) deployManifests(
nil,
)
if err != nil {
return nil, fmt.Errorf("failed applying kube manifests: %w", err)
return false, nil, fmt.Errorf("failed applying kube manifests: %w", err)
}

deploymentName := serviceConfig.K8s.Deployment.Name
Expand All @@ -330,10 +330,12 @@ func (t *aksTarget) deployManifests(
task.SetProgress(NewServiceProgress("Verifying deployment"))
deployment, err := t.waitForDeployment(ctx, deploymentName)
if err != nil && !errors.Is(err, kubectl.ErrResourceNotFound) {
return nil, err
// We continue to return a true value here since at this point we have successfully applied the manifests
// even through the deployment may not have been found
return true, nil, err
}

return deployment, nil
return true, deployment, nil
}

// deployKustomize deploys kustomize manifests to the k8s cluster
Expand Down
Loading