Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC-0030 - Add support to Diego for file based service bindings #942

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
branch = main
[submodule "src/code.cloudfoundry.org/bbs"]
path = src/code.cloudfoundry.org/bbs
url = https://github.com/cloudfoundry/bbs
branch = main
url = https://github.com/dimitardimitrov13/bbs
branch = CFAR-929_VCAP_SERVICES
[submodule "src/code.cloudfoundry.org/auctioneer"]
ameowlia marked this conversation as resolved.
Show resolved Hide resolved
path = src/code.cloudfoundry.org/auctioneer
url = https://github.com/cloudfoundry/auctioneer
Expand Down
2 changes: 1 addition & 1 deletion jobs/rep/spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ templates:
tls.key.erb: config/certs/tls.key
tls_ca.crt.erb: config/certs/tls_ca.crt
indicators.yml.erb: config/indicators.yml
setup_service_binding_root.erb: bin/setup_service_binding_root
volume_mounted_files.erb: bin/volume_mounted_files

packages:
- pid_utils
Expand Down
2 changes: 1 addition & 1 deletion jobs/rep/templates/bpm-pre-start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ $bin_dir/set-rep-kernel-params

$bin_dir/setup_mounted_data_dirs

$bin_dir/setup_service_binding_root
$bin_dir/volume_mounted_files
4 changes: 2 additions & 2 deletions jobs/rep/templates/rep.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
trusted_certs_dir = "/var/vcap/data/rep/shared/garden/trusted_certs"
instance_identity_dir = "/var/vcap/data/rep/shared/garden/instance_identity"
download_cache_dir= "/var/vcap/data/rep/shared/garden/download_cache"
service_binding_root_dir = "/var/vcap/data/rep/shared/garden/service_binding_root"
volume_mounted_files = "/var/vcap/data/rep/shared/volume_mounted_files"

zone = spec.az
if_p("diego.rep.zone") do |value|
Expand Down Expand Up @@ -105,7 +105,7 @@
report_interval: "1m",
max_data_string_length: p("logging.max_data_string_length"),
max_log_lines_per_second: p("diego.executor.max_log_lines_per_second"),
service_binding_root: "#{service_binding_root_dir}"
volume_mounted_files: "#{volume_mounted_files}"
}

if p("containers.graceful_shutdown_interval_in_seconds") < 10
Expand Down
2 changes: 1 addition & 1 deletion jobs/rep/templates/rep_ctl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ case $1 in

$bin_dir/set-rep-kernel-params
$bin_dir/setup_mounted_data_dirs
$bin_dir/setup_service_binding_root
$bin_dir/volume_mounted_files

# Allowed number of open file descriptors
ulimit -n 100000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@
max_containers=<%= _max_containers %>

# Define the service binding root directory
service_binding_root="/var/vcap/data/rep/shared/garden/service_binding_root"
volume_mounted_files="/var/vcap/data/rep/shared/garden/volume_mounted_files"

# Calculate the size for the tmpfs (1MB per container)
ameowlia marked this conversation as resolved.
Show resolved Hide resolved
root_tmpfs_size=$((max_containers * 1))M

# Ensure the root directory is safely removed and recreated
if [ -d "$service_binding_root" ]; then
if [ -d "$volume_mounted_files" ]; then
# Ensure the root directory is unmounted before removing it
if mountpoint -q "$service_binding_root"; then
fuser -k "$service_binding_root"
umount -l "$service_binding_root"
if mountpoint -q "$volume_mounted_files"; then
fuser -k "$volume_mounted_files"
umount -l "$volume_mounted_files"
fi

sleep 10

rm -rf "$service_binding_root"
rm -rf "$volume_mounted_files"
fi

mkdir -p "$service_binding_root"
mkdir -p "$volume_mounted_files"

# Mount the root tmpfs
mount -t tmpfs -o size="$root_tmpfs_size" tmpfs "$service_binding_root" || exit 1
mount -t tmpfs -o size="$root_tmpfs_size" tmpfs "$volume_mounted_files" || exit 1

# Set permissions and ownership for the root directory and all subdirectories
chmod 0700 "$service_binding_root"
chown vcap:vcap "$service_binding_root"
chmod 0700 "$volume_mounted_files"
chown vcap:vcap "$volume_mounted_files"
4 changes: 2 additions & 2 deletions spec/rep_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
end
end

describe 'setup_service_binding_root.erb' do
let(:template) { job.template('bin/setup_service_binding_root') }
describe 'volume_mounted_files.erb' do
let(:template) { job.template('bin/volume_mounted_files') }

context 'checks the max_containers value' do
it 'raises an error if max_containers is <= 0' do
Expand Down