Commit e729ae85 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'update-knative-for-helm-3' into 'master'

Fix installation of Knative under Helm 3

See merge request gitlab-org/gitlab!49843
parents e970bf06 48e15923
......@@ -65,7 +65,7 @@ module Clusters
end
def retry_command(command)
"for i in $(seq 1 90); do #{command} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)"
Gitlab::Kubernetes::PodCmd.retry_command(command, times: 90)
end
def post_delete_script
......
......@@ -3,7 +3,7 @@
module Clusters
module Applications
class Knative < ApplicationRecord
VERSION = '0.9.0'
VERSION = '0.10.0'
REPOSITORY = 'https://charts.gitlab.io'
METRICS_CONFIG = 'https://gitlab.com/gitlab-org/charts/knative/-/raw/v0.9.0/vendor/istio-metrics.yml'
FETCH_IP_ADDRESS_DELAY = 30.seconds
......
---
title: Fix installation of Knative under Helm 3
merge_request: 49843
author:
type: fixed
......@@ -17,7 +17,7 @@ module Gitlab
def delete_crds_from_group(group)
api_resources_args = %w(-o name --api-group).push(group)
api_resources(*api_resources_args) + " | xargs " + delete('--ignore-not-found', 'crd')
PodCmd.retry_command(api_resources(*api_resources_args) + " | xargs -r " + delete('--ignore-not-found', 'crd'))
end
def api_resources(*args)
......
# frozen_string_literal: true
module Gitlab
module Kubernetes
# Miscellaneous commands that run in the helm-install-image pod, tuned to
# the idiosynchrasies of the default shell of helm-install-image
module PodCmd
class << self
def retry_command(command, times: 3)
"for i in $(seq 1 #{times.to_i}); do #{command} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)"
end
end
end
end
end
......@@ -56,9 +56,10 @@ RSpec.describe Gitlab::Kubernetes::KubectlCmd do
describe '.delete_crds_from_group' do
it 'constructs string properly' do
expected_command = 'kubectl api-resources -o name --api-group foo | xargs kubectl delete --ignore-not-found crd'
command = 'kubectl api-resources -o name --api-group foo | xargs -r kubectl delete --ignore-not-found crd'
command_with_retries = "for i in $(seq 1 3); do #{command} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)"
expect(described_class.delete_crds_from_group("foo")).to eq expected_command
expect(described_class.delete_crds_from_group("foo")).to eq command_with_retries
end
end
end
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Gitlab::Kubernetes::PodCmd do
describe '.retry_command' do
it 'constructs string properly' do
command = 'my command'
command_with_retries = "for i in $(seq 1 3); do #{command} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)"
expect(described_class.retry_command(command)).to eq command_with_retries
end
end
end
......@@ -150,7 +150,7 @@ RSpec.describe Clusters::Applications::Knative do
subject { knative.install_command }
it 'is initialized with latest version' do
expect(subject.version).to eq('0.9.0')
expect(subject.version).to eq('0.10.0')
end
it_behaves_like 'a command'
......@@ -204,8 +204,8 @@ RSpec.describe Clusters::Applications::Knative do
expect(subject.postdelete).to include(*remove_knative_istio_leftovers_script)
expect(subject.postdelete.size).to eq(full_delete_commands_size)
expect(subject.postdelete[2]).to eq("kubectl api-resources -o name --api-group #{api_groups[0]} | xargs kubectl delete --ignore-not-found crd")
expect(subject.postdelete[3]).to eq("kubectl api-resources -o name --api-group #{api_groups[1]} | xargs kubectl delete --ignore-not-found crd")
expect(subject.postdelete[2]).to include("kubectl api-resources -o name --api-group #{api_groups[0]} | xargs -r kubectl delete --ignore-not-found crd")
expect(subject.postdelete[3]).to include("kubectl api-resources -o name --api-group #{api_groups[1]} | xargs -r kubectl delete --ignore-not-found crd")
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