86 lines
2.8 KiB
Python
86 lines
2.8 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Test script to identify the exact namespace of the ms-qc-db-dev job.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from dotenv import load_dotenv
|
|
import nomad
|
|
from pprint import pprint
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv()
|
|
|
|
def get_nomad_client():
|
|
"""Create a direct nomad client without going through our service layer."""
|
|
nomad_addr = os.getenv("NOMAD_ADDR", "http://localhost:4646").rstrip('/')
|
|
host_with_port = nomad_addr.replace("http://", "").replace("https://", "")
|
|
host = host_with_port.split(":")[0]
|
|
|
|
# Safely extract port
|
|
port_part = host_with_port.split(":")[-1] if ":" in host_with_port else "4646"
|
|
port = int(port_part.split('/')[0])
|
|
|
|
return nomad.Nomad(
|
|
host=host,
|
|
port=port,
|
|
timeout=10,
|
|
namespace="*", # Try with explicit wildcard
|
|
verify=False
|
|
)
|
|
|
|
def main():
|
|
print(f"Creating Nomad client...")
|
|
client = get_nomad_client()
|
|
|
|
print(f"\n=== Testing with namespace='*' ===")
|
|
try:
|
|
# List all jobs with namespace '*'
|
|
jobs = client.jobs.get_jobs(namespace="*")
|
|
print(f"Found {len(jobs)} jobs using namespace='*'")
|
|
|
|
# Look for our specific job and show its namespace
|
|
found = False
|
|
for job in jobs:
|
|
if job.get('ID') == 'ms-qc-db-dev':
|
|
found = True
|
|
print(f"\nFound job 'ms-qc-db-dev' in namespace: {job.get('Namespace', 'unknown')}")
|
|
print(f"Job status: {job.get('Status')}")
|
|
print(f"Job type: {job.get('Type')}")
|
|
print(f"Job priority: {job.get('Priority')}")
|
|
break
|
|
|
|
if not found:
|
|
print(f"\nJob 'ms-qc-db-dev' not found with namespace='*'")
|
|
except Exception as e:
|
|
print(f"Error with namespace='*': {str(e)}")
|
|
|
|
# Try listing all available namespaces
|
|
print(f"\n=== Listing available namespaces ===")
|
|
try:
|
|
namespaces = client.namespaces.get_namespaces()
|
|
print(f"Found {len(namespaces)} namespaces:")
|
|
for ns in namespaces:
|
|
print(f" - {ns.get('Name')}")
|
|
|
|
# Try finding the job in each namespace specifically
|
|
print(f"\n=== Searching for job in each namespace ===")
|
|
for ns in namespaces:
|
|
ns_name = ns.get('Name')
|
|
try:
|
|
job = client.job.get_job('ms-qc-db-dev', namespace=ns_name)
|
|
print(f"Found job in namespace '{ns_name}'!")
|
|
print(f" Status: {job.get('Status')}")
|
|
print(f" Type: {job.get('Type')}")
|
|
break
|
|
except Exception:
|
|
print(f"Not found in namespace '{ns_name}'")
|
|
|
|
except Exception as e:
|
|
print(f"Error listing namespaces: {str(e)}")
|
|
|
|
print("\nTest completed.")
|
|
|
|
if __name__ == "__main__":
|
|
main() |