Zoekt attempts to index pending deletion repositories

Summary

We've discovered in gitlab-com/gl-infra/production#19308 (closed) that GitLab attempts to send indexing tasks to Zoekt for projects marked for deletion.

Steps to reproduce

It fails if you attempt to create an indexing task for such a project:

[ gstg ] production>         repository_storage = project.repository_storage
=> "nfs-file07"
[ gstg ] production>         connection_info = Gitlab::GitalyClient.connection_data(repository_storage)
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/gitaly_client.rb:230:in `address': storage not found: "nfs-file07" (RuntimeError)
	from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/gitaly_client.rb:249:in `connection_data'
	from (irb):177:in `<main>'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/railties-7.0.8.7/lib/rails/commands/console/console_command.rb:74:in `start'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/railties-7.0.8.7/lib/rails/commands/console/console_command.rb:19:in `start'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/railties-7.0.8.7/lib/rails/commands/console/console_command.rb:106:in `perform'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/railties-7.0.8.7/lib/rails/command/base.rb:87:in `perform'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/railties-7.0.8.7/lib/rails/command.rb:48:in `invoke'
	from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/railties-7.0.8.7/lib/rails/commands.rb:18:in `<top (required)>'
	from <internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from <internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from bin/rails:4:in `<main>'

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Possible fixes

I believe we can add the project.valid_repo? condition to https://gitlab.com/gitlab-org/gitlab/-/blob/08e4b434f74c40c0be66a62fe7393f6fa84ba98a/ee/app/models/search/zoekt/task.rb#L92-95

Edited by Dmitry Gruzd