This repository has been archived by the owner on Feb 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use k8s-args.root-dir in drain script when watching for PVC detach (#314
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec' | ||
require 'spec_helper' | ||
|
||
def get_k8s_disks_dir(rendered_drain) | ||
lsblk_line = rendered_drain.split("\n").select { |line| line[/MOUNTPOINT/i] } | ||
expect(lsblk_line.length).to be(1) | ||
lsblk_line[0].match(/awk '\/(.+)\/ {print \$1}'/).captures[0] | ||
end | ||
|
||
describe 'kubelet drain' do | ||
|
||
it 'substitutes in the k8s-args.root-dir property for get_k8s_disks()' do | ||
manifest_properties = { | ||
'k8s-args' => { | ||
'root-dir' => '/var/vcap/data/kubelet' | ||
} | ||
} | ||
|
||
rendered_drain = compiled_template('kubelet', 'bin/drain', manifest_properties, {}, {}, nil, nil, nil) | ||
k8s_disks_dir = get_k8s_disks_dir(rendered_drain) | ||
expect(k8s_disks_dir).to eq(manifest_properties['k8s-args']['root-dir'].gsub("/", "\\/")) | ||
end | ||
|
||
it 'uses /var/lib/kubelet for get_k8s_disks() by default' do | ||
rendered_drain = compiled_template('kubelet', 'bin/drain', {}, {}, {}, nil, nil, nil) | ||
k8s_disks_dir = get_k8s_disks_dir(rendered_drain) | ||
expect(k8s_disks_dir).to eq("/var/lib/kubelet".gsub("/", "\\/")) | ||
end | ||
end |