Files
ubicloud/kubernetes/csi/bin/ubi-csi-server
mohi-kalantari 52b6ebba53 Add Dockerfile for the CSI project
Uses a multi-stage build: first installs deps, then assembles final.
2025-07-21 14:18:09 +02:00

41 lines
1.2 KiB
Plaintext
Executable File

# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
$LOAD_PATH.unshift(File.expand_path("..", __dir__))
require "bundler/setup"
require "ubi_csi"
def main
$stdout.sync = true
puts "Starting main function..."
endpoint = ENV["CSI_ENDPOINT"].strip
raise "CSI_ENDPOINT environment variable is not set" if endpoint.nil? || endpoint.empty?
raise "CSI_ENDPOINT must have unix:// prefix" unless endpoint.start_with?("unix://")
puts "Checking NODE_ID..."
raise "NODE_ID environment variable is not set" if ENV["NODE_ID"].nil? || ENV["NODE_ID"].strip.empty?
puts "Creating gRPC server..."
server = GRPC::RpcServer.new
socket_path = endpoint.sub("unix://", "")
puts "Socket path: #{socket_path}"
File.delete(socket_path) if File.exist?(socket_path)
server.add_http2_port("unix:#{socket_path}", :this_port_is_insecure)
puts "Registering services..."
server.handle(Csi::V1::IdentityService)
server.handle(Csi::V1::ControllerService)
server.handle(Csi::V1::NodeService)
puts "Starting UbiCSI server on #{endpoint}..."
begin
server.run_till_terminated
rescue => e
puts "Error starting server: #{e.message}"
raise
end
end
main if __FILE__ == $PROGRAM_NAME