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

Go Binaries in Distroless/Debian Don't Get Env Vars Injected #1756

Closed
rejoshed opened this issue Dec 28, 2022 · 5 comments
Closed

Go Binaries in Distroless/Debian Don't Get Env Vars Injected #1756

rejoshed opened this issue Dec 28, 2022 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR that has become stale and will be auto-closed.

Comments

@rejoshed
Copy link

Describe the bug:
When running a Go program directly from either a Distroless or Debian container the env vars are not injected.

Expected behaviour:
I expected the environment variables to be injected.

Steps to reproduce the bug:
Sample Go Program

package main

import (
    "fmt"
    "log"
    "os"
)

func main() {
    //Set env a to b
    err := os.Setenv("a", "b")
    if err != nil {
        log.Fatal(err)
    }

    err = os.Setenv("c", "d")
    if err != nil {
        log.Fatal(err)
    }

    //Get all env variables
    fmt.Println(os.Environ())
    fmt.Println("*************************")
    fmt.Println("*************************")
    fmt.Println("*************************")
    fmt.Println("*************************")
    fmt.Println("*************************")

    fmt.Println(os.Getenv("AWS_INFRA_PLATFORM_NEXUS_ADMIN"))
}

A Dockerfile like this one will do. I was trying to get Crossplane to work with bank-vaults.

FROM debian:latest

# Add upbound binary
COPY --from=xpkg.upbound.io/crossplane-contrib/provider-aws:v0.33.0 /usr/local/bin/crossplane-aws-provider /usr/local/bin/crossplane-aws-provider

RUN apt update -qqq
RUN apt install -yqqq ca-certificates
RUN update-ca-certificates

# Works when binary is not called directly.
ENTRYPOINT ["/bin/bash", "-c", "/usr/local/bin/crossplane-aws-provider --debug"]

Additional context:
If the binary is called directly vault-env will not replace the var.

If called through a shell as above in the entrypoint it will work.

Basically something's up with vault-env, debian, and directly calling Go binaries.

/kind bug

@rejoshed
Copy link
Author

rejoshed commented Jan 2, 2023

So, after much back and forth, I've found that enabling daemon mode works as a workaround.

The issue must in general be to do with needed to be exec-ed or not.

When the vault-env process calls an intermediary or launches the go program without replacing itself with the go program the env vars work properly.

I do still see this as a bug, but at least I have a less ugly workaround for now.

Copy link

github-actions bot commented Dec 3, 2023

Thank you for your contribution! This issue has been automatically marked as stale because it has no recent activity in the last 60 days. It will be closed in 20 days, if no further activity occurs. If this issue is still relevant, please leave a comment to let us know, and the stale label will be automatically removed.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR that has become stale and will be auto-closed. label Dec 3, 2023
@ramizpolic ramizpolic added kind/bug Categorizes issue or PR as related to a bug. and removed lifecycle/stale Denotes an issue or PR that has become stale and will be auto-closed. labels Dec 22, 2023
@ramizpolic
Copy link
Member

Is this behaviour still present @rejoshed?

Copy link

github-actions bot commented May 5, 2024

Thank you for your contribution! This issue has been automatically marked as stale because it has no recent activity in the last 60 days. It will be closed in 20 days, if no further activity occurs. If this issue is still relevant, please leave a comment to let us know, and the stale label will be automatically removed.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR that has become stale and will be auto-closed. label May 5, 2024
Copy link

This issue has been marked stale for 20 days, and is now closed due to inactivity. If the issue is still relevant, please re-open this issue or file a new one. Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR that has become stale and will be auto-closed.
Projects
Status: Done
Development

No branches or pull requests

2 participants