openshift-metal3/dev-scripts

oc version reporting empty build date field

Closed this issue · 1 comments

Describe the bug
The oc binary we are extracting from the default release right now is reporting an empty build date field, and because dev-scripts tries to use that to verify the client is new enough it causes the 01_install_requirements script to fail at

oc_date=$(date -d $(oc version -o json | jq -r '.clientVersion.buildDate') +%s)
with the following error:

+++ oc version -o json
+++ jq -r .clientVersion.buildDate
W1213 11:58:41.610365 18445 loader.go:223] Config not found: /home/bnemec/dev-scripts/ocp/auth/kubeconfig
++ date -d +%s
date: invalid date ‘+%s’

To Reproduce
Run dev-scripts (currently at 22e464b) with OpenShift release registry.svc.ci.openshift.org/ocp/release:4.4.0-0.ci-2019-12-13-145806.

Expected/observed behavior
Expected: dev-scripts runs the deployment successfully.
Observed: After dev-scripts extracts the oc binary from the release, it fails because of the empty build date field.

Additional context
This seems to work the first time because it is checking the old binary, but after a dev-scripts run where it extracts the broken binary this problem will happen. Deleting /usr/local/bin/oc is a temporary workaround, but it will come back the next time you run it.

The problematic oc returns this from oc version -o json:

{
  "clientVersion": {
    "major": "",
    "minor": "",
    "gitVersion": "unknown",
    "gitCommit": "",
    "gitTreeState": "",
    "buildDate": "",
    "goVersion": "go1.13.5",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "serverVersion": {
    "major": "1",
    "minor": "11+",
    "gitVersion": "v1.11.0+d4cacc0",
    "gitCommit": "d4cacc0",
    "gitTreeState": "clean",
    "buildDate": "2019-05-02T11:52:09Z",
    "goVersion": "go1.10.8",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "releaseClientVersion": "4.4.0-0.ci-2019-12-13-122757"
}

A proper oc returns something like this:

{
  "clientVersion": {
    "major": "",
    "minor": "",
    "gitVersion": "v4.4.0",
    "gitCommit": "ec80374ec063e2b37018e868ba7d004e0acdd97f",
    "gitTreeState": "clean",
    "buildDate": "2019-12-13T12:25:03Z",
    "goVersion": "go1.12.12",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "serverVersion": {
    "major": "1",
    "minor": "11+",
    "gitVersion": "v1.11.0+d4cacc0",
    "gitCommit": "d4cacc0",
    "gitTreeState": "clean",
    "buildDate": "2019-05-02T11:52:09Z",
    "goVersion": "go1.10.8",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}

I filed openshift/oc#215. I'll push a workaround as well.