Bug 1429398 - clear-route-status.sh can not clean the route stale status field by using '-r' option
Summary: clear-route-status.sh can not clean the route stale status field by using '-r...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Networking
Version: 3.5.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Jacob Tanenbaum
QA Contact: zhaozhanqi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-06 09:58 UTC by Yan Du
Modified: 2022-08-04 22:20 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: The script does not check the version of jq and does not populate its array of routes correctly Consequence: When using the -r the script failes Fix: Check to makes sure the user has an appropriate version of jq and populate the array of target routes properly Result: The script correctly clears the routes specified of status messages
Clone Of:
Environment:
Last Closed: 2017-08-10 05:18:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Origin (Github) 13246 0 None None None 2017-03-06 14:15:52 UTC
Origin (Github) 14200 0 None None None 2017-05-15 18:00:05 UTC
Red Hat Product Errata RHEA-2017:1716 0 normal SHIPPED_LIVE Red Hat OpenShift Container Platform 3.6 RPM Release Advisory 2017-08-10 09:02:50 UTC

Description Yan Du 2017-03-06 09:58:59 UTC
Description of problem:
clear-route-status.sh can not clean the route stale status field by using '-r' option

Version-Release number of selected component (if applicable):
openshift v3.5.0.39
kubernetes v1.5.2+43a9be4


How reproducible:
always

Steps to Reproduce:
1. Create router
2. Create some routes
3. Delete the old router and recreate a new router named router1
4. Clear the status set by a specific router
$ wget https://raw.githubusercontent.com/openshift/origin/master/images/router/clear-route-status.sh
$ ./clear-route-status.sh -r router


Actual results:
$ ./clear-route-status.sh -r router
Error from server (NotFound): routes "docker-registry registry-console" not found

Expected results:
Should not show route could not found, since the routes are existed, and the status fields for old router could be cleared.
# oc describe route docker-registry
Name:            docker-registry
Namespace:        default
Created:        31 hours ago
Labels:            <none>
Annotations:        openshift.io/host.generated=true
Requested Host:        docker-registry-default.0305-mnr.qe.rhcloud.com
              exposed on router router 31 hours ago
              exposed on router router1 17 minutes ago

Comment 1 Jacob Tanenbaum 2017-03-06 14:15:52 UTC
origin PR: https://github.com/openshift/origin/pull/13246

Comment 2 Yan Du 2017-03-15 06:06:43 UTC
Test on latest OCP env V3.5.0.52 with the latest script in https://github.com/openshift/origin/pull/13246

Seem the -r option is still not working:

$ ./clear-route-status.sh -r router1
error: index is not defined
.status.ingress | map(.routerName != "router1") | index(false)
                                                  ^^^^^
1 compile error

Comment 3 Eric Paris 2017-03-17 17:22:03 UTC
https://github.com/openshift/origin/issues/13246

Comment 5 Jacob Tanenbaum 2017-04-05 19:08:20 UTC
I can't reproduce the error that you see with the clear route script could you be more specific?

Comment 7 Jacob Tanenbaum 2017-04-19 17:18:10 UTC
https://github.com/openshift/origin/pull/13678 removed the call to index could you retest?

Comment 8 Yan Du 2017-04-24 05:16:07 UTC
Retest with the script in https://github.com/openshift/origin/pull/13678, got below error:

[root@host-8-174-54 ~]# ./clear-route-status.sh -r router
error: syntax error, unexpected QQSTRING_START, expecting $end
."status"."ingress"|=map(select(.routerName != "router"))
 ^
1 compile error

Comment 10 Yan Du 2017-04-28 02:39:12 UTC
The script in https://github.com/openshift/origin/pull/13678 could not work normally and get the error as #comment 8

Comment 11 Ben Bennett 2017-04-28 12:48:57 UTC
@Yan Du: Can you run:  jq --version 

Thanks

Comment 12 Yan Du 2017-05-02 01:48:39 UTC
# jq --version
jq version 1.3

Comment 13 Yan Du 2017-05-02 02:15:24 UTC
After using jq 1.5 for test, the script could work well.

# ./clear-route-status.sh -r router
route status for route route1 set by router router cleared
route status for route route2 set by router router cleared
route status for route route3 set by router router cleared
route status for route route4 set by router router cleared
route status for route route5 set by router router cleared
route status for route docker-registry set by router router cleared
route status for route registry-console set by router router cleared
route status for route cakephp-mysql-example set by router router cleared
No routes found for namespace kube-system
No routes found for namespace logging
No routes found for namespace management-infra
No routes found for namespace openshift
No routes found for namespace openshift-infra

Comment 14 Jacob Tanenbaum 2017-05-08 17:26:51 UTC
yan since this past your test could you move this forward?

Comment 15 Yan Du 2017-05-09 05:20:56 UTC
@jtanenba
Sure, but could you please kindly move to bug status to ON_QA, then I could move it to verified.

Comment 16 Yan Du 2017-05-10 02:42:30 UTC
@jtanenba

One more question, do we need to mention that the script only works with version jq >= 1.4 in documentation warning message in script?

Comment 17 Ben Bennett 2017-05-11 17:24:27 UTC
How did you upgrade jq?  What version of RHEL did 1.3 ship with?

Comment 18 Yan Du 2017-05-12 02:20:22 UTC
I am using rhel 7.2, and I just upgrade jq by downloading a binary from https://stedolan.github.io/jq/download/

Comment 19 Meng Bo 2017-05-12 04:21:24 UTC
The jq package from epel-7 repo is version 1.5-1
And seems it is not available in rhel-7-server-rpms and rhel-7-server-extras-rpms

Comment 20 Yan Du 2017-05-12 07:17:56 UTC
The command with -r option actually need to be ran on master with cluster-admin, but actually there is no jq installed by default on master. So do we plan to have jq installed by default on master?

Comment 21 Ben Bennett 2017-05-15 13:48:59 UTC
Ok, given what Meng Bo and Yan Du have found (thank you both, by the way!) I think we need to amend the checks around https://github.com/JacobTanenbaum/origin/blob/eb5f10682ea72f54fec0b7714ede032d273f3182/images/router/clear-route-status.sh#L86 to check for a minimum version too... and we should state the version needed in the message that tells people what to install.

Comment 22 Ben Bennett 2017-05-15 13:55:10 UTC
Although, in the interests of not going mad doing version parsing, perhaps we ought to do feature detection and add a line like:
 echo '' | jq '."status"."ingress"|=map(select(.routerName != "test"))'

And make sure that $? is 0.  If not, then we can tell them they need at least version 1.4.

Comment 23 Jacob Tanenbaum 2017-05-15 18:00:06 UTC
Origin PR: https://github.com/openshift/origin/pull/14200

Comment 25 openshift-github-bot 2017-05-20 07:20:05 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/866f8bbfadc082a18e5a0d3bbe9dfd0e0c56bbe2
Change version check on jq in clear route status script

jq is required for the JSON processing required for clearing the route status. During QA
it was found that the version of jq has to be greater than 1.4. Expand the check on jq
for the capabilities needed and the message to include the version number

Bug 1429398

Comment 27 Yan Du 2017-06-01 09:02:00 UTC
Test on latest OCP-3.6 env 
openshift v3.6.86
kubernetes v1.6.1+5115d708d7

[root@ip-172-18-4-211 ~]# ./clear-route-status.sh -r router
Command line JSON processor 'jq' not found.
please install 'jq' version greater than 1.4 to use this script.

[root@ip-172-18-4-211 ~]# jq --version
jq version 1.3
[root@ip-172-18-4-211 ~]# ./clear-route-status.sh -r router
Command line JSON processor 'jq' version is incorrect.
Please install 'jq' version greater than 1.4 to use this script

[root@ip-172-18-4-211 ~]# jq --version
jq-1.5
[root@ip-172-18-4-211 ~]# ./clear-route-status.sh -r router
No routes found for namespace d1
No routes found for namespace d2
route status for route test-service set by router router cleared
route status for route docker-registry set by router router cleared
route status for route registry-console set by router router cleared
route status for route cakephp-mysql-example set by router router cleared

Comment 29 errata-xmlrpc 2017-08-10 05:18:47 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, 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/RHEA-2017:1716


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