Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-06 21:09:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-06 21:09:43 +0300
commit33998a0e768263828f497685ae030f585193317f (patch)
tree791e2c3322a17f668a2a4abdd251a8362885f381 /tooling
parent7b69a22d499787378aa30561822ef797a99c22e5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'tooling')
-rw-r--r--tooling/lib/tooling/kubernetes_client.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/tooling/lib/tooling/kubernetes_client.rb b/tooling/lib/tooling/kubernetes_client.rb
index 1d7b924e2c3..ab914db5777 100644
--- a/tooling/lib/tooling/kubernetes_client.rb
+++ b/tooling/lib/tooling/kubernetes_client.rb
@@ -6,8 +6,9 @@ require_relative '../../../lib/gitlab/popen' unless defined?(Gitlab::Popen)
module Tooling
class KubernetesClient
- RESOURCE_LIST = 'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa,crd'
- CommandFailedError = Class.new(StandardError)
+ RESOURCE_LIST = 'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa,crd'
+ K8S_ALLOWED_NAMESPACES_REGEX = /^review-(?!apps).+/.freeze
+ CommandFailedError = Class.new(StandardError)
attr_reader :namespace
@@ -129,14 +130,16 @@ module Tooling
command = [
'get',
'namespace',
- "-l tls=review-apps-tls", # Get only namespaces used for review-apps
"--sort-by='{.metadata.creationTimestamp}'",
'-o json'
]
response = run_command(command)
- resources_created_before_date(response, created_before)
+ stale_namespaces = resources_created_before_date(response, created_before)
+
+ # `kubectl` doesn't allow us to filter namespaces with a regexp. We therefore do the filtering in Ruby.
+ stale_namespaces.select { |ns| K8S_ALLOWED_NAMESPACES_REGEX.match?(ns) }
end
def resources_created_before_date(response, date)