Mercurial > repos > enis > gcp_batch_netcat
changeset 7:fcfb703748b1 draft
planemo upload for repository https://github.com/afgane/gcp_batch_netcat commit ece227052d14d755b0d0b07a827152b2e98fb94b-dirty
author | enis |
---|---|
date | Thu, 24 Jul 2025 22:32:12 +0000 |
parents | d25792770df8 |
children | 7c660a6be068 |
files | gcp_batch_netcat.py gcp_batch_netcat.xml |
diffstat | 2 files changed, 28 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/gcp_batch_netcat.py Thu Jul 24 21:59:57 2025 +0000 +++ b/gcp_batch_netcat.py Thu Jul 24 22:32:12 2025 +0000 @@ -14,49 +14,18 @@ ) logger = logging.getLogger(__name__) -def discover_nfs_loadbalancer_ip(): - """ - Try to discover NFS LoadBalancer IP via Kubernetes API - Returns the external IP if found, None otherwise - """ - try: - import subprocess - logger.info("Attempting to discover NFS LoadBalancer IP via kubectl...") - result = subprocess.run(['kubectl', 'get', 'svc', '-n', 'nfs-provisioner', '-o', 'json'], capture_output=True, text=True) - if result.returncode == 0: - services = json.loads(result.stdout) - for item in services.get('items', []): - name = item.get('metadata', {}).get('name', '') - # Look for NFS-related service names - if any(keyword in name.lower() for keyword in ['nfs-provisioner-nfs-server-provisioner']): - spec = item.get('spec', {}) - if spec.get('type') == 'LoadBalancer': - ingress = item.get('status', {}).get('loadBalancer', {}).get('ingress', []) - if ingress: - ip = ingress[0].get('ip') - if ip: - logger.info(f"Found NFS LoadBalancer service '{name}' with external IP: {ip}") - return ip - logger.warning("No NFS LoadBalancer services found via kubectl") - else: - logger.warning(f"kubectl command failed: {result.stderr}") - except Exception as e: - logger.warning(f"Could not discover NFS LoadBalancer IP via kubectl: {e}") - return None + def determine_test_target(args): """Determine the target host and port based on test type""" if args.test_type == 'nfs': - # Extract NFS server address if not provided - if args.nfs_address: - nfs_address = args.nfs_address - logger.info(f"Using provided NFS address: {nfs_address}") - else: - # Try to auto-discover NFS LoadBalancer IP via Kubernetes API - nfs_address = discover_nfs_loadbalancer_ip() - if not nfs_address: - raise ValueError("Could not auto-detect NFS LoadBalancer IP. Please provide --nfs_address parameter with the LoadBalancer external IP.") + # NFS server address is required + if not args.nfs_address: + raise ValueError("NFS server address is required. Please provide --nfs_address parameter with the LoadBalancer external IP.") + + nfs_address = args.nfs_address + logger.info(f"Using provided NFS address: {nfs_address}") return nfs_address, 2049 else: @@ -64,7 +33,7 @@ def main(): parser = argparse.ArgumentParser() - parser.add_argument('--nfs_address', required=False, help='NFS server LoadBalancer IP address (if not provided, will be auto-detected via Kubernetes API)') + parser.add_argument('--nfs_address', required=True, help='NFS server LoadBalancer external IP address (required)') parser.add_argument('--output', required=True) parser.add_argument('--project', required=False, help='GCP Project ID (if not provided, will be extracted from service account key)') parser.add_argument('--region', required=True)
--- a/gcp_batch_netcat.xml Thu Jul 24 21:59:57 2025 +0000 +++ b/gcp_batch_netcat.xml Thu Jul 24 22:32:12 2025 +0000 @@ -11,9 +11,7 @@ --service_account_key '$service_account_key' --network '$network' --subnet '$subnet' -#if $nfs_address - --nfs_address '$nfs_address' -#end if +--nfs_address '$nfs_address' ]]></command> <inputs> <param name="region" type="text" label="GCP Batch Region" optional="false" help="Region where the Batch job will run (e.g., us-central1)"/> @@ -21,7 +19,7 @@ <param name="subnet" type="text" label="GCP Subnet name" optional="false" help="Subnet name where Galaxy is deployed"/> <param name="service_account_key" type="data" format="json" label="GCP Service Account Key File" help="JSON key file for GCP service account with Batch API permissions"/> <param name="project" type="text" label="GCP Project ID" help="The ID of the GCP project to use. If not provided, will be extracted from the service account key." optional="true"/> - <param name="nfs_address" type="text" label="NFS Server Address" help="The LoadBalancer external IP address of the NFS server (e.g., 10.150.0.17). If not provided, the tool will attempt to auto-discover it via Kubernetes API." optional="true"/> + <param name="nfs_address" type="text" label="NFS Server Address" help="The LoadBalancer external IP address of the NFS server (e.g., 10.150.0.17). This must be the external IP, not the internal ClusterIP." optional="false"/> </inputs> <outputs> <data name="output" format="txt"/> @@ -31,11 +29,21 @@ This tool submits a job to GCP Batch to test network connectivity between Batch workers and your NFS server. It provides network debugging to help identify connectivity issues in Galaxy deployments on Google Kubernetes Engine (GKE). -**NFS Address Auto-Discovery** +**Required: NFS LoadBalancer External IP** + +You must provide the external IP address of your NFS server's LoadBalancer service. This is crucial because: +- Galaxy sees the NFS server via its internal ClusterIP (e.g., 10.96.0.1) +- GCP Batch jobs run outside the cluster and need the LoadBalancer external IP (e.g., 10.150.0.17) + +**Finding Your NFS LoadBalancer IP** -If you don't provide an NFS server address, the tool will attempt to auto-discover it by: -- Using Kubernetes API to find NFS LoadBalancer services and their external IPs -- Looking for services with names containing 'nfs', 'nfs-server', 'nfs-provisioner', or 'nfs-ganesha' +To find the correct IP address, run: +``` +kubectl get svc | grep nfs +kubectl get svc <nfs-service-name> -o wide +``` + +Look for the "EXTERNAL-IP" column for LoadBalancer type services. **Important: LoadBalancer Configuration** @@ -46,12 +54,12 @@ The tool helps identify the root cause of connectivity issues: - **Connection timeouts**: Usually indicates firewall rules blocking traffic or NFS service not accessible externally - **DNS resolution failures**: May indicate DNS configuration issues -- **Auto-discovery fails**: NFS service may only be exposed as ClusterIP (internal only) +- **Wrong IP address**: Ensure you're using the LoadBalancer external IP, not the ClusterIP **Best Practices** -1. For most reliable results, provide the LoadBalancer external IP explicitly in the "NFS Server Address" field -2. If auto-discovery fails, check that your NFS service is properly exposed with a LoadBalancer type -3. Ensure GCP firewall rules allow traffic from Batch subnet to NFS LoadBalancer IP on port 2049 +1. Ensure your NFS service is exposed as type LoadBalancer with an external IP +2. Verify GCP firewall rules allow traffic from Batch subnet to NFS LoadBalancer IP on port 2049 +3. Test the connection manually: `telnet <EXTERNAL-IP> 2049` ]]></help> </tool>