Commit 65ce9d24 authored by Stan Hu's avatar Stan Hu

Fix rake gitlab:setup failing on new installs

For source installs, running `rake gitlab:setup` will fail with this
error:

```

$ bundle exec rake gitlab:setup RAILS_ENV=production
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation
"features" does not exist LINE 8: WHERE a.attrelid =
'"features"'::regclass
```

This happens because the setup Rake task does the following:

1. Checks that Gitaly servers are up
2. The gRPC message attempts to send the activated feature flags
in the metadata.
3. However, since the `features` table doesn't exist, this fails.

To fix this, we just return an empty set if neither the database nor the
`features` table exists.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/212759
parent c38ce405
---
title: Fix rake gitlab:setup failing on new installs
merge_request: 28270
author:
type: fixed
......@@ -14,6 +14,9 @@ class Feature
end
def server_feature_flags
# We need to check that both the DB connection and table exists
return {} unless ::Gitlab::Database.cached_table_exists?(FlipperFeature.table_name)
Feature.persisted_names
.select { |f| f.start_with?(PREFIX) }
.map do |f|
......
......@@ -32,5 +32,15 @@ describe Feature::Gitaly do
it { is_expected.to be_a(Hash) }
it { is_expected.to eq("gitaly-feature-mep-mep" => "true") }
context 'when table does not exist' do
before do
allow(::Gitlab::Database).to receive(:cached_table_exists?).and_return(false)
end
it 'returns an empty Hash' do
expect(subject).to eq({})
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment