bluemixgaragelondon / cf-blue-green-deploy

Cloud Foundry CLI plugin for zero downtime deploys
Apache License 2.0
139 stars 61 forks source link

Could not delete old app version "An operation for the service binding between app ** and service instance ** is in progress." #104

Open atmcourse-1 opened 9 months ago

atmcourse-1 commented 9 months ago

Hello, When I trying to cf blue-green-deploy --delete-old-apps -f manifest-dev.yml, this error popup.

Deleting app <app name> in org <org name> / space <space name> as <user>...
Could not delete old app version - Server error, status code: 502, error code: 150009, message: Deletion of app <app name-old> failed because one or more associated resources could not be deleted.

        An operation for the service binding between app <app name-old> and service instance <service binding> is in progress.

Here is the source code where the error raised:

// cloud_controller_ng/app/actions/mixins/bindings_delete.rb
def delete_bindings(bindings, user_audit_info:)
        type = nil
        binding_delete_action = nil

        bindings.each_with_object([]) do |binding, errors|
          type ||= DeleteServiceBindingFactory.type_of(binding)
          binding_delete_action ||= DeleteServiceBindingFactory.action(type, user_audit_info)

          result = binding_delete_action.delete(binding)
          unless result[:finished]
            polling_job = DeleteBindingJob.new(type, binding.guid, user_audit_info:)
            Jobs::Enqueuer.new(polling_job, queue: Jobs::Queues.generic).enqueue_pollable
            unbinding_operation_in_progress!(binding)
          end
        rescue StandardError => e
          errors << e
        end
end

// cloud_controller_ng/app/actions/app_delete.rb
def unbinding_operation_in_progress!(binding)
      raise AsyncBindingDeletionsTriggered.new(
        "An operation for the service binding between app #{binding.app.name} and service instance #{binding.service_instance.name} is in progress."
      )
end
// cf-blue-green-deploy/blue_green_deploy.go
func (p *BlueGreenDeploy) DeleteAppVersions(apps []plugin_models.GetAppsModel) {
    for _, app := range apps {
        if _, err := p.Connection.CliCommand("delete", app.Name, "-f", "-r"); err != nil {
            p.ErrorFunc("Could not delete old app version", err)
        }
    }
}

I think you should treat AsyncBindingDeletionsTriggered Error in a different way with others, cause this process is still on going. And this unbinding operation is successful on delay.

Thanks Xuelong Bai