Skip to content

Commit

Permalink
Merge pull request #1025 from jananivMS/sqlservercrash
Browse files Browse the repository at this point in the history
Fix nil pointer dereference in Sql Server operator
  • Loading branch information
jananivMS authored May 5, 2020
2 parents 0cf906b + c4262db commit 346cfaf
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,24 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object,
}

// Assure that the requested name is available and assume the secret exists
checkNameResult, _ := CheckNameAvailability(ctx, instance.Name)
if *checkNameResult.Available != true {
instance.Status.Provisioning = false
if _, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name); err != nil {
instance.Status.Message = "SQL server already exists somewhere else"
return true, nil
}
checkNameResult, err := CheckNameAvailability(ctx, instance.Name)
if err == nil {
if *checkNameResult.Available != true {
instance.Status.Provisioning = false
if _, err := s.GetServer(ctx, instance.Spec.ResourceGroup, instance.Name); err != nil {
instance.Status.Message = "SQL server already exists somewhere else"
return true, nil
}

instance.Status.Message = fmt.Sprintf(
`SQL server already exists and the credentials could not be found.
instance.Status.Message = fmt.Sprintf(
`SQL server already exists and the credentials could not be found.
If using kube secrets a secret should exist at '%s' for keyvault it should be '%s'`,
key.String(),
fmt.Sprintf("%s-%s", key.Namespace, key.Name),
)
key.String(),
fmt.Sprintf("%s-%s", key.Namespace, key.Name),
)

return false, nil
return false, nil
}
}

secret, err = NewSecret(instance.Name)
Expand Down

0 comments on commit 346cfaf

Please sign in to comment.