Bug 1965376 - Wrong interpolation in environment values in the build pod
Summary: Wrong interpolation in environment values in the build pod
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.7
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 4.8.0
Assignee: Corey Daley
QA Contact: Jitendar Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-27 15:10 UTC by Nikolaos Leandros Moraitis
Modified: 2023-09-15 01:08 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-10-12 06:01:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:3682 0 None None None 2021-10-12 06:01:56 UTC

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


Note You need to log in before you can comment on or make changes to this bug.