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

On Battlefield as a namespaced user warnet logs <name of scenario> gives a permission error #657

Open
m3dwards opened this issue Oct 16, 2024 · 2 comments

Comments

@m3dwards
Copy link
Collaborator

On Battlefield as a namespaced user warnet logs gives a permission error

@pinheadmz
Copy link
Contributor

does it work if you find the desired scenario in the inquirer menu of warnet logs ?

@mplsgrant
Copy link
Collaborator

mplsgrant commented Oct 16, 2024

It looks to me like a user in, say, namespace wargames-orange is calling warnet logs my-scenario, but the implicit --namespace is actually default.

@click.option("--namespace", type=str, default="default", show_default=True)
def logs(pod_name: str, follow: bool, namespace: str):

Since a user in wargames-orange cannot access default, they get an error.

That said, when users do not specify a namespace, we use get_mission which calls get_pod. These functions rely on simply retrieving the default namespace. That's why wargames logs just works.

When the users specify the scenario name, the default namespace comes into play, and this code gets called:

try:
pod = get_pod(pod_name, namespace=namespace)
eligible_container_names = [BITCOINCORE_CONTAINER, COMMANDER_CONTAINER]

I think we should wrap the bare call to get_pod with a for loop that iterates over namespaces using get_namespaces. Something like this:

    try:
        pod = None
        for v1namespace in get_namespaces():
            namespace = v1namespace.metadata.name
            try:
                pod = get_pod(pod_name, namespace=namespace)
            except Exception:
                pass

        if not pod:
            print(f"Could not find: {pod_name}")
            sys.exit(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants