Bug 1873007

Summary: [downstream] failed to read config when running the operator-sdk in the home path
Product: OpenShift Container Platform Reporter: Jian Zhang <jiazha>
Component: Operator SDKAssignee: Jesus M. Rodriguez <jesusr>
Status: CLOSED ERRATA QA Contact: Cuiping HUO <chuo>
Severity: low Docs Contact:
Priority: low    
Version: 4.6CC: aos-bugs, jesusr, jfan, jiazha
Target Milestone: ---Keywords: UpcomingSprint
Target Release: 4.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: All subcommands attempted to read the PROJECT file (even if it was a directory) Consequence: Subcommands that do not need the PROJECT file would fail to work. Fix: Changed the code so that subcommands that do not need the PROJECT file will skip reading it. Result: Subcommands like version, help, etc. that do not need information from the PROJECT file will work even if there is an invalid PROJECT file present.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-24 15:16:22 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 Jian Zhang 2020-08-27 06:33:12 UTC
Description of problem:

mac:~ jianzhang$ operator-sdk version
FATA[0000] failed to read config: read PROJECT: is a directory 

Version-Release number of selected component (if applicable):
Downsream repo: https://github.com/openshift/ocp-release-operator-sdk
The master branch

How reproducible:
always

Steps to Reproduce:

1. Clone the downstream repo.
mac:openshift jianzhang$ git clone git:openshift/ocp-release-operator-sdk.git

2. Compile the operator-sdk binary.
mac:ocp-release-operator-sdk jianzhang$ make tidy
go: downloading github.com/coreos/prometheus-operator v0.38.1-0.20200424145508-7e176fda06cc
go: downloading github.com/operator-framework/operator-registry v1.12.6-0.20200611222234-275301b779f8
go: downloading sigs.k8s.io/controller-runtime v0.6.0
go: downloading github.com/operator-framework/api v0.3.8
go: downloading sigs.k8s.io/kubebuilder v1.0.9-0.20200618125005-36aa113dbe99
go: downloading golang.org/x/net v0.0.0-20200301022130-244492dfa37a
go: downloading go.uber.org/zap v1.14.1
go: downloading k8s.io/code-generator v0.18.2
go: downloading golang.org/x/crypto v0.0.0-20200414173820-0848c9571904
go: downloading github.com/rogpeppe/go-internal v1.5.0
go: downloading github.com/prometheus/procfs v0.0.8
go: downloading k8s.io/gengo v0.0.0-20200114144118-36b2048a9120
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/json-iterator/go v1.1.9
go: downloading google.golang.org/grpc v1.27.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading go.uber.org/atomic v1.6.0
go: downloading github.com/Azure/go-autorest/autorest v0.9.3-0.20191028180845-3492b2aff503
go: downloading github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33
go: downloading github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd
go: downloading github.com/Azure/go-autorest/autorest/adal v0.8.1-0.20191028180845-3492b2aff503
go: downloading github.com/gophercloud/gophercloud v0.6.0
go: downloading github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
go: downloading honnef.co/go/tools v0.0.1-2019.2.3
go: downloading github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50
go: downloading go.uber.org/multierr v1.5.0
go: downloading github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1
go: downloading google.golang.org/genproto v0.0.0-20200117163144-32f20d992d24
go: downloading gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966
go: downloading github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0
go: downloading github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7
go: downloading github.com/Azure/go-autorest/autorest/mocks v0.3.0
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916
go: downloading go.opencensus.io v0.22.2
go: downloading github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43
go: downloading github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b
go: downloading github.com/Azure/go-autorest/autorest/date v0.2.0
go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: downloading github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f
go: downloading cloud.google.com/go v0.49.0
go: downloading github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f
go: downloading github.com/mattn/go-runewidth v0.0.6
go: downloading go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee
mac:ocp-release-operator-sdk jianzhang$ make install

3. Run the operator-sdk command in the home path.

Actual results:

mac:~ jianzhang$ pwd
/Users/jianzhang
mac:~ jianzhang$ operator-sdk version
FATA[0000] failed to read config: read PROJECT: is a directory 

Expected results:
The operator-sdk works well.

Additional info:
But, it works well in other path. 
mac:~ jianzhang$ cd project/
mac:project jianzhang$ pwd
/Users/jianzhang/project
mac:project jianzhang$ operator-sdk version
operator-sdk version: "550e9947", commit: "550e9947d23e122f36f6159167b2e670b2430a05", kubernetes version: "v1.18.2", go version: "go1.14.3 darwin/amd64"

Comment 1 Joe Lanford 2020-08-27 13:18:15 UTC
This seems to be a coincidence of the environment. operator-sdk looks for a PROJECT file in the current working directory of the command to setup the CLI. If it finds a PROJECT directory it errors out.

It seems like you may have a directory named /Users/jianzhang/PROJECT.

If you rename that directory, or try the operator-sdk version command from a different directory that does not contain a PROJECT directory, you should see the expected result.

Technically, I think this could be considered a minor bug since it shouldn't be necessary to read a PROJECT file to print the version information.

However, note that the Operator SDK binary is not shipped downstream AND Operator SDK 0.19 is aligned with OpenShift 4.6

Comment 2 Jesus M. Rodriguez 2020-11-01 02:02:18 UTC
Filed upstream kubebuilder issue https://github.com/kubernetes-sigs/kubebuilder/issues/1755

Comment 4 Jesus M. Rodriguez 2021-01-04 16:42:07 UTC
Fixed upstream in v1.3.0. Pending downstream sync of 1.4.0 later this sprint.

Comment 6 Cuiping HUO 2021-01-05 08:43:41 UTC
Verified.

Run the operator-sdk command home path successfully.
$ pwd
/home/chuo
[chuo@localhost ~]$ operator-sdk version
operator-sdk version: "7cc6f20c", commit: "7cc6f20cccd9a16b1af0c270197dc7b374e2048c", kubernetes version: "v1.18.8", go version: "go1.14.2", GOOS: "linux", GOARCH: "amd64"

Comment 9 errata-xmlrpc 2021-02-24 15:16:22 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 (Moderate: OpenShift Container Platform 4.7.0 security, bug fix, and enhancement 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/RHSA-2020:5633