Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1965376

Summary: Wrong interpolation in environment values in the build pod
Product: OpenShift Container Platform Reporter: Nikolaos Leandros Moraitis <nmoraiti>
Component: BuildAssignee: Corey Daley <cdaley>
Status: CLOSED ERRATA QA Contact: Jitendar Singh <jitsingh>
Severity: low Docs Contact:
Priority: low    
Version: 4.7CC: aaleman, adam.kaplan, aos-bugs, cdaley, skuznets
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-12 06:01:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nikolaos Leandros Moraitis 2021-05-27 15:10:56 UTC
Description of problem:

Then the JSON value of the environment variable contains escaped quotes the build pod's interpolation causes failures while unmarshaling the JSON data.


Version-Release number of selected component (if applicable):
4.7


How reproducible:

kind: ImageStream
apiVersion: v1
metadata:
  name: output
---
apiVersion: v1
kind: BuildConfig
metadata:
  name: output
spec:
  output:
    to:
      kind: ImageStreamTag
      name: output:latest
  source:
    dockerfile: |
      FROM registry.ci.openshift.org/openshift/release:golang-1.16
      RUN echo $'package main\nimport "encoding/json"\nimport "os"\nimport "fmt"\ntype data struct{\n    Title string\n}\nfunc main() {\n    fmt.Println(os.Getenv("DATA")) \n    var d data\n    if err := json.Unmarshal([]byte(os.Getenv("DATA")), &d); err != nil {\n        panic(err)\n    } else {\n        fmt.Println(d.Title)\n    }\n}' > read.go
      RUN cat read.go
      RUN go run read.go
  strategy:
    dockerStrategy:
      from:
        kind: DockerImage
        name: registry.ci.openshift.org/openshift/release:golang-1.16
      imageOptimizationPolicy: SkipLayers
      env:
      - name: DATA
        value: "{\"title\":\"Revert \\\"Wait for expected number of drivers starting API\\\"\"}"

Comment 1 Steve Kuznetsov 2021-05-27 15:16:22 UTC
Notably, we pass in:

> "{\"title\":\"Revert \\\"Wait for expected number of drivers starting API\\\"\"}"

As the value. By the time the Go program reads it, this looks like:

> {"title":"Revert \\"Wait for expected number of drivers starting API\\""}

On a normal system:

$ DATA="{\"title\":\"Revert \\\"Wait for expected number of drivers starting API\\\"\"}"
$ echo $DATA
{"title":"Revert \"Wait for expected number of drivers starting API\""}

Comment 3 Corey Daley 2021-07-07 03:52:34 UTC
@nmoraiti 
Can you verify what the value of the env var looks like in the build yaml?
And I am guessing that you were able to rsh into the build pod to get the referenced output above for the value of the `DATA` env var?

Comment 7 Steve Kuznetsov 2021-07-14 17:58:11 UTC
This seems fixed in 4.8.0-rc.1

Comment 11 Jitendar Singh 2021-09-29 09:43:20 UTC
verified

Comment 13 errata-xmlrpc 2021-10-12 06:01:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.8.14 bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:3682

Comment 14 Red Hat Bugzilla 2023-09-15 01:08:43 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 500 days