Legacy license support for GitLab Duo
What does this MR do and why?
Self-managed instances can end up on a legacy license for a myriad of reasons. When visiting /admin/code_suggestions
this is not an obvious problem because the empty state just encourages purchasing GitLab Duo seats, which may not be reasonable or relevant.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
How to set up and validate locally
- Apply patch:
diff --git a/ee/app/graphql/resolvers/admin/cloud_licenses/current_license_resolver.rb b/ee/app/graphql/resolvers/admin/cloud_licenses/current_license_resolver.rb
index f2cb629500e4..0146a63641ff 100644
--- a/ee/app/graphql/resolvers/admin/cloud_licenses/current_license_resolver.rb
+++ b/ee/app/graphql/resolvers/admin/cloud_licenses/current_license_resolver.rb
@@ -10,6 +10,25 @@ class CurrentLicenseResolver < BaseResolver
type ::Types::Admin::CloudLicenses::CurrentLicenseType, null: true
def resolve
+ return OpenStruct.new(
+ id: '1',
+ plan: 'ultimate',
+ license_type: 'legacy_license',
+ licensee_name: 'name',
+ licensee_email: 'email',
+ licensee_company: 'company',
+ starts_at: 1.day.ago,
+ created_at: 1.day.ago,
+ expires_at: 1.year.from_now,
+ block_changes_at: 1.year.from_now,
+ activated_at: 1.day.ago,
+ restricted_user_count: 10,
+ last_synced_at: 1.day.ago,
+ daily_billable_users_count: 10,
+ maximum_user_count: 100,
+ overage_with_historical_max: 100,
+ trial?: false
+ )
authorize!
license
diff --git a/ee/app/models/license.rb b/ee/app/models/license.rb
index aac4ae494b56..87e2fa8b7f8b 100644
--- a/ee/app/models/license.rb
+++ b/ee/app/models/license.rb
@@ -56,6 +56,7 @@ class License < ApplicationRecord
class << self
def current
+ return ::OpenStruct.new(starts_at: 1.year.ago, expires_at: 1.year.from_now, paid?: true)
cache.fetch(CACHE_KEY, as: License, expires_in: 1.minute) { load_license }
end
@@ -77,6 +78,7 @@ def block_changes?
end
def feature_available?(feature)
+ return true
# Include features available per plan + usage ping features if Usage Pings is enabled
# as instance setting.
!!current&.feature_available?(feature) ||
- or apply license following these docs: https://docs.gitlab.com/ee/development/ai_features/index.html#option-b-run-gdk-in-self-managed-mode-and-enable-ai-features-for-the-instance
- Export this environment variable
export GITLAB_SIMULATE_SAAS=0
and restart GDK. - Sign in as admin. Visit
/admin/code_suggestions
.
Related to #473402
Edited by Serhii Yarynovskyi