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

cininnati: fix unknown version fetch #114

Merged

Conversation

abhinavdahiya
Copy link
Contributor

@abhinavdahiya abhinavdahiya commented Feb 6, 2019

currently if the current version does not exist in the reponse returned from cincinnati, we use the 0th node as our version
and return the available updates for that version.
example,

If the response from cincinnati is following:

$ curl --silent --header 'Accept:application/json' https://api.openshift.com/api/upgrades_info/v1/graph | jq .
{
  "nodes": [
    {
      "version": "4.0.0-5",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-5",
      "metadata": {}
    },
    {
      "version": "4.0.0-4",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-4",
      "metadata": {}
    },
    {
      "version": "4.0.0-6",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-6",
      "metadata": {}
    },
    {
      "version": "4.0.0-7",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-7",
      "metadata": {}
    },
    {
      "version": "4.0.0-8",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-8",
      "metadata": {}
    },
    {
      "version": "4.0.0-9",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-9",
      "metadata": {}
    },
    {
      "version": "4.0.0-0.1",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.1",
      "metadata": {
        "description": "This is the beta1 image based on the 4.0.0-0.nightly-2019-01-15-010905 build"
      }
    },
    {
      "version": "4.0.0-0.okd-0",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.okd-0",
      "metadata": {}
    },
    {
      "version": "4.0.0-0.2",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.2",
      "metadata": {}
    },
    {
      "version": "4.0.0-0.3",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.3",
      "metadata": {}
    }
  ],
  "edges": [
    [
      1,
      0
    ],
    [
      0,
      2
    ],
    [
      2,
      3
    ],
    [
      3,
      4
    ],
    [
      4,
      5
    ],
    [
      6,
      8
    ],
    [
      8,
      9
    ]
  ]
}

For a cusotm release image generated locally

$ oc get clusterversion -oyaml
apiVersion: v1
items:
- apiVersion: config.openshift.io/v1
  kind: ClusterVersion
  metadata:
    creationTimestamp: 2019-02-06T00:51:12Z
    generation: 1
    name: version
    namespace: ""
    resourceVersion: "956"
    selfLink: /apis/config.openshift.io/v1/clusterversions/version
    uid: 4cbc79c7-29a9-11e9-b85c-664f163f5f0f
  spec:
    channel: fast
    clusterID: a7d11204-7193-41ca-ad4a-337a540a5dac
    upstream: https://api.openshift.com/api/upgrades_info/v1/graph
  status:

    availableUpdates:
    - image: quay.io/openshift-release-dev/ocp-release:4.0.0-6
      version: 4.0.0-6

    conditions:
    - lastTransitionTime: 2019-02-06T00:51:21Z
      status: "False"
      type: Available
    - lastTransitionTime: 2019-02-06T00:53:21Z
      status: "False"
      type: Failing
    - lastTransitionTime: 2019-02-06T00:51:21Z
      message: 'Working towards 0.0.1-2019-02-06-003220: 22% complete'
      status: "True"
      type: Progressing
    - lastTransitionTime: 2019-02-06T00:51:21Z
      status: "True"
      type: RetrievedUpdates
    desired:
      image: quay.io/abhinavdahiya/origin-release@sha256:4e9f3686380d26566e9112fdd53262068004a22a85f93111a0f10d0b3dfdc3a9
      version: 0.0.1-2019-02-06-003220
    history:
    - completionTime: null
      image: quay.io/abhinavdahiya/origin-release@sha256:4e9f3686380d26566e9112fdd53262068004a22a85f93111a0f10d0b3dfdc3a9
      startedTime: 2019-02-06T00:51:21Z
      state: Partial
      version: 0.0.1-2019-02-06-003220
    observedGeneration: 1
    versionHash: G0evldCtMHI=
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

The current version is 0.0.1-2019-02-06-003220 and since this is version is not present in the response from cincinnati with use the 0th node ie 4.0.0-5 and returns available update to 4.0.0-6

This returns error when current version is not found in response from cincinnati.

/cc @crawford @smarterclayton

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 6, 2019
@smarterclayton
Copy link
Contributor

Lgtm, might be good to add a test to cvo_test (which should have a table driven test for available update computation)

@openshift-merge-robot
Copy link
Contributor

/retest

1 similar comment
@openshift-merge-robot
Copy link
Contributor

/retest

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 6, 2019
@abhinavdahiya
Copy link
Contributor Author

@smarterclayton @crawford with 5e34549 -> 4454e8d

added unit test for GetUpdates.

currently if the current version does not exist in the reponse returned from cincinnati, we use the `0`th node as our version
and return the available updates for that version.
example,

If the response from cincinnati is following:
```console
$ curl --silent --header 'Accept:application/json' https://api.openshift.com/api/upgrades_info/v1/graph | jq .
{
  "nodes": [
    {
      "version": "4.0.0-5",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-5",
      "metadata": {}
    },
    {
      "version": "4.0.0-4",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-4",
      "metadata": {}
    },
    {
      "version": "4.0.0-6",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-6",
      "metadata": {}
    },
    {
      "version": "4.0.0-7",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-7",
      "metadata": {}
    },
    {
      "version": "4.0.0-8",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-8",
      "metadata": {}
    },
    {
      "version": "4.0.0-9",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-9",
      "metadata": {}
    },
    {
      "version": "4.0.0-0.1",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.1",
      "metadata": {
        "description": "This is the beta1 image based on the 4.0.0-0.nightly-2019-01-15-010905 build"
      }
    },
    {
      "version": "4.0.0-0.okd-0",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.okd-0",
      "metadata": {}
    },
    {
      "version": "4.0.0-0.2",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.2",
      "metadata": {}
    },
    {
      "version": "4.0.0-0.3",
      "payload": "quay.io/openshift-release-dev/ocp-release:4.0.0-0.3",
      "metadata": {}
    }
  ],
  "edges": [
    [
      1,
      0
    ],
    [
      0,
      2
    ],
    [
      2,
      3
    ],
    [
      3,
      4
    ],
    [
      4,
      5
    ],
    [
      6,
      8
    ],
    [
      8,
      9
    ]
  ]
}
```

For a cusotm release image generated locally
```console
$ oc get clusterversion -oyaml
apiVersion: v1
items:
- apiVersion: config.openshift.io/v1
  kind: ClusterVersion
  metadata:
    creationTimestamp: 2019-02-06T00:51:12Z
    generation: 1
    name: version
    namespace: ""
    resourceVersion: "956"
    selfLink: /apis/config.openshift.io/v1/clusterversions/version
    uid: 4cbc79c7-29a9-11e9-b85c-664f163f5f0f
  spec:
    channel: fast
    clusterID: a7d11204-7193-41ca-ad4a-337a540a5dac
    upstream: https://api.openshift.com/api/upgrades_info/v1/graph
  status:

    availableUpdates:
    - image: quay.io/openshift-release-dev/ocp-release:4.0.0-6
      version: 4.0.0-6

    conditions:
    - lastTransitionTime: 2019-02-06T00:51:21Z
      status: "False"
      type: Available
    - lastTransitionTime: 2019-02-06T00:53:21Z
      status: "False"
      type: Failing
    - lastTransitionTime: 2019-02-06T00:51:21Z
      message: 'Working towards 0.0.1-2019-02-06-003220: 22% complete'
      status: "True"
      type: Progressing
    - lastTransitionTime: 2019-02-06T00:51:21Z
      status: "True"
      type: RetrievedUpdates
    desired:
      image: quay.io/abhinavdahiya/origin-release@sha256:4e9f3686380d26566e9112fdd53262068004a22a85f93111a0f10d0b3dfdc3a9
      version: 0.0.1-2019-02-06-003220
    history:
    - completionTime: null
      image: quay.io/abhinavdahiya/origin-release@sha256:4e9f3686380d26566e9112fdd53262068004a22a85f93111a0f10d0b3dfdc3a9
      startedTime: 2019-02-06T00:51:21Z
      state: Partial
      version: 0.0.1-2019-02-06-003220
    observedGeneration: 1
    versionHash: G0evldCtMHI=
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
```
The current version is `0.0.1-2019-02-06-003220` and since this is version is not present in the response from cincinnati with use the `0`th node ie `4.0.0-5` and returns available update to `4.0.0-6`

This returns error when current version is not found in response from cincinnati.
@abhinavdahiya
Copy link
Contributor Author

/test integration

Integration tests set glog flags which cause `flag used but not defined error` in cincinnati package.
```console
$ go test ./... -test.run=^TestIntegration -args -alsologtostderr -v=5
flag provided but not defined: -alsologtostderr
Usage of /tmp/go-build337832706/b371/cincinnati.test:
  -httptest.serve string
        if non-empty, httptest.NewServer serves on this address and blocks
  -test.bench regexp
        run only benchmarks matching regexp
  -test.benchmem
        print memory allocations for benchmarks
  -test.benchtime d
        run each benchmark for duration d (default 1s)
  -test.blockprofile file
        write a goroutine blocking profile to file
  -test.blockprofilerate rate
        set blocking profile rate (see runtime.SetBlockProfileRate) (default 1)
  -test.count n
        run tests and benchmarks n times (default 1)
  -test.coverprofile file
        write a coverage profile to file
  -test.cpu list
        comma-separated list of cpu counts to run each test with
  -test.cpuprofile file
        write a cpu profile to file
  -test.failfast
        do not start new tests after the first test failure
  -test.list regexp
        list tests, examples, and benchmarks matching regexp then exit
  -test.memprofile file
        write an allocation profile to file
  -test.memprofilerate rate
        set memory allocation profiling rate (see runtime.MemProfileRate)
  -test.mutexprofile string
        write a mutex contention profile to the named file after execution
  -test.mutexprofilefraction int
        if >= 0, calls runtime.SetMutexProfileFraction() (default 1)
  -test.outputdir dir
        write profiles to dir
  -test.parallel n
        run at most n tests in parallel (default 8)
  -test.run regexp
        run only tests and examples matching regexp
  -test.short
        run smaller test suite to save time
  -test.testlogfile file
        write test action log to file (for use only by cmd/go)
  -test.timeout d
        panic test binary after duration d (default 0, timeout disabled)
  -test.trace file
        write an execution trace to file
  -test.v
        verbose: print additional output
FAIL    github.com/openshift/cluster-version-operator/pkg/cincinnati    0.033s
```
@smarterclayton
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 6, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [abhinavdahiya,smarterclayton]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 8620284 into openshift:master Feb 6, 2019
@abhinavdahiya abhinavdahiya deleted the cvo_fetch_updates branch February 6, 2019 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants