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

intercept: Dependent environment variable not being expanded #3680

Closed
akojo opened this issue Sep 2, 2024 · 0 comments · Fixed by #3682
Closed

intercept: Dependent environment variable not being expanded #3680

akojo opened this issue Sep 2, 2024 · 0 comments · Fixed by #3682

Comments

@akojo
Copy link

akojo commented Sep 2, 2024

Describe the bug

I'm passing k8s node's host IP to an application via an environment variable and during intercept the variable's value doesn't get expanded. This happens consistently (which means the root cause is probably different than in #2853)

To Reproduce

Steps to reproduce the behavior:

  1. I have a service with environment variable definitions:

    spec:                                                                                                                                                                           
      containers:                                                                                                                                                                   
      - env:                                                                                                                                                                        
        - name: HOST_IP                                                                                                                                                             
          valueFrom:                                                                                                                                                                
            fieldRef:                                                                                                                                                               
              apiVersion: v1                                                                                                                                                        
              fieldPath: status.hostIP                                                                                                                                              
        - name: OTEL_EXPORTER_OTLP_ENDPOINT                                                                                                                                         
          value: http://$(HOST_IP):4317
  2. When I run telepresence intercept for the service $(HOST_IP) in OTEL_EXPORTER_OTLP_ENDPOINT doesn't get expanded, e.g.

    $ telepresence intercept ui-421a635a -- env | grep OTEL
    OTEL_EXPORTER_OTLP_ENDPOINT=http://$(HOST_IP):4317

Expected behavior

Environment variable gets expanded into remote environment.

Versions (please complete the following information):

  • Output of telepresence version

    OSS Client         : v2.19.1
    OSS Root Daemon    : v2.19.1
    OSS User Daemon    : v2.19.1
    OSS Traffic Manager: v2.19.1
    Traffic Agent      : docker.io/datawire/tel2:2.19.1
    
  • Operating system of workstation running telepresence commands

    Ubuntu 22.04

  • Kubernetes environment and Version [e.g. Minikube, bare metal, Google Kubernetes Engine]

    Minikube v1.33.1

Additional information

Running a shell inside the same container I get:

app@ui-421a635a-7774989488-fb2gk:/app$ env | grep OTEL
OTEL_EXPORTER_OTLP_ENDPOINT=http://192.168.49.2:4317

as expected

thallgren added a commit that referenced this issue Sep 3, 2024
An environment looking like this for the application container:
```yaml
  - env:
    - name: HOST
      value: example.com
    - name: URL
      value: http://$(ALPHA):1234
```
would get this prefixed equivalent in the traffic-agent:
```yaml
  - env:
    - name: _TEL_APP_A_HOST
      value: example.com
    - name: _TEL_APP_A_URL
      value: http://$(ALPHA):1234
```
which then resulted in an invalid value for `TEL_APP_A_URL` because
the `$(ALPHA)` was never prefixed.

This commit changes so that the last line of the traffic-agent env is:
```yaml
      value: http://$(_TEL_APP_A_ALPHA):1234
```

Closes #3680

Signed-off-by: Thomas Hallgren <thomas@tada.se>
thallgren added a commit that referenced this issue Sep 3, 2024
An environment looking like this for the application container:
```yaml
  - env:
    - name: HOST
      value: example.com
    - name: URL
      value: http://$(HOST):1234
```
would get this prefixed equivalent in the traffic-agent:
```yaml
  - env:
    - name: _TEL_APP_A_HOST
      value: example.com
    - name: _TEL_APP_A_URL
      value: http://$(HOST):1234
```
which then resulted in an invalid value for `TEL_APP_A_URL` because
the `$(HOST)` was never prefixed.

This commit changes so that the last line of the traffic-agent env is:
```yaml
      value: http://$(_TEL_APP_A_HOST):1234
```

Closes #3680

Signed-off-by: Thomas Hallgren <thomas@tada.se>
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

Successfully merging a pull request may close this issue.

1 participant