Commit ee28255b authored by Dylan Griffith's avatar Dylan Griffith

Refresh service_account_token for kubernetes_namespaces

There seems to be several examples where service_account_token is blank
even in GitLab.com newly created kubernetes_namespaces . We have not
figured out why they are blank but this should hopefully fix some issues
similar to https://gitlab.com/gitlab-org/gitlab-ce/issues/55362
parent f35d3a24
---
title: Refresh service_account_token for kubernetes_namespaces
merge_request: 29657
author:
type: fixed
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
deployment_cluster.present? && deployment_cluster.present? &&
deployment_cluster.managed? && deployment_cluster.managed? &&
!deployment_cluster.project_type? && !deployment_cluster.project_type? &&
kubernetes_namespace.new_record? (kubernetes_namespace.new_record? || kubernetes_namespace.service_account_token.blank?)
end end
def complete! def complete!
......
...@@ -16,5 +16,9 @@ FactoryBot.define do ...@@ -16,5 +16,9 @@ FactoryBot.define do
trait :with_token do trait :with_token do
service_account_token { FFaker::Lorem.characters(10) } service_account_token { FFaker::Lorem.characters(10) }
end end
trait :without_token do
service_account_token nil
end
end end
end end
...@@ -35,9 +35,15 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do ...@@ -35,9 +35,15 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
end end
context 'and a namespace is already created for this project' do context 'and a namespace is already created for this project' do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, cluster: cluster, project: build.project) } let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :with_token, cluster: cluster, project: build.project) }
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
context 'and the service_account_token is blank' do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :without_token, cluster: cluster, project: build.project) }
it { is_expected.to be_truthy }
end
end end
context 'and cluster is project type' do context 'and cluster is project type' do
......
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