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

Bug: Found an issue with Azure SQL Server where it doesnt recognize existing SQL servers #782

Closed
wants to merge 15 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,21 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object,
instance.Status.SpecHash = hash
}

if instance.Status.Provisioning {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line was blocking the reconciler from "attaching" to existing SQL Servers - that was the desired functionality at one time, is it not anymore @jananivMS ?

Copy link
Contributor

@jananivMS jananivMS Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frodopwns fixed this as part of his PR here - #741 and I tested this. This scenario worked fine, so wondering what was the scenario that you saw the failure in, @WilliamMortlMicrosoft ? Status.Message would tell you if this reconcile doesnt happen. One of the cases where this happens is if the SQL server is present but the secret is not present in kube/keyvault. This is because we dont know the admin creds of an existing server and for it to work correctly we need to have the person externally creating the SQL server to also populate the secret.


serv, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name)
if err != nil {
azerr := errhelp.NewAzureErrorAzureError(err)
// @Todo: ResourceNotFound should be handled if the time since the last PUT is unreasonable
if azerr.Type != errhelp.ResourceNotFound {
return false, err
}

// the first minute or so after a PUT to create a server will result in failed GETs
instance.Status.State = "NotReady"
} else {
instance.Status.State = *serv.State
// check to see if server exists
serv, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name)
if err != nil {
azerr := errhelp.NewAzureErrorAzureError(err)
// @Todo: ResourceNotFound should be handled if the time since the last PUT is unreasonable
if azerr.Type != errhelp.ResourceNotFound {
return false, err
}

// the first minute or so after a PUT to create a server will result in failed GETs
instance.Status.State = "NotReady"
} else {
instance.Status.State = *serv.State

// if server is ready, we are done
if instance.Status.State == "Ready" {
instance.Status.Message = resourcemanager.SuccessMsg
instance.Status.Provisioned = true
Expand All @@ -130,11 +129,11 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object,
return true, nil
}

// server not done provisioning
// not ready yet, requeue
return false, nil
}

// create the sql server
// sql server doesn't exist yet, so create the sql server
instance.Status.Provisioning = true
if _, err := s.CreateOrUpdateSQLServer(ctx, instance.Spec.ResourceGroup, instance.Spec.Location, instance.Name, labels, azureSQLServerProperties, false); err != nil {
instance.Status.Message = err.Error()
Expand Down