Bug 1973643

Summary: oc logs doesn't work with piepeline builds
Product: OpenShift Container Platform Reporter: Maciej Szulik <maszulik>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.8CC: aos-bugs, jokerman, mfojtik
Target Milestone: ---   
Target Release: 4.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Missing client setup in logs command. Consequence: oc logs doesn't work with pipeline builds. Fix: Properly setup client in logs command. Result: oc logs works with pipeline builds.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-18 17:35:43 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:
Bug Depends On:    
Bug Blocks: 1974267    

Description Maciej Szulik 2021-06-18 11:43:19 UTC
Description of problem:
oc logs doesn't work against BuildConfig with JenkinsPipelineStrategy defined. 


How reproducible:
Always


Steps to Reproduce:
1. create BuildConfig with JenkinsPipelineStrategy
2. oc logs bc/<name>


Actual results:
Command fails with:

$ oc logs -f bc/jenkins-verifyservice-pipeline
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x34e930d]

goroutine 1 [running]:
github.com/openshift/oc/pkg/cli/logs.(*LogsOptions).RunLog(0xc000699380, 0x0, 0x3fb0338)
	/go/src/github.com/openshift/oc/pkg/cli/logs/logs.go:127 +0x6ed
github.com/openshift/oc/pkg/cli/logs.NewCmdLogs.func1(0xc000a12000, 0xc0003382a0, 0x1, 0x2)
	/go/src/github.com/openshift/oc/pkg/cli/logs/logs.go:86 +0x156
github.com/spf13/cobra.(*Command).execute(0xc000a12000, 0xc000338280, 0x2, 0x2, 0xc000a12000, 0xc000338280)
	/go/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000f4c80, 0x2, 0xc0000f4c80, 0x2)
	/go/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/go/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:897
main.main()
	/go/src/github.com/openshift/oc/cmd/oc/oc.go:93 +0x645

Comment 2 zhou ying 2021-06-21 05:39:51 UTC
can't reproduce the error with oc4.9:

[root@localhost home]# oc version --client
Client Version: 4.8.0-202106130124.p0.git.1077b05.assembly.stream-1077b05


[root@localhost roottest]# oc logs -f bc/sample-pipeline
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x34e930d]

goroutine 1 [running]:
github.com/openshift/oc/pkg/cli/logs.(*LogsOptions).RunLog(0xc000ab18e0, 0x0, 0x3fb0338)
	/builddir/build/BUILD/openshift-clients-4.8.0/__gopath/src/github.com/openshift/oc/pkg/cli/logs/logs.go:127 +0x6ed
github.com/openshift/oc/pkg/cli/logs.NewCmdLogs.func1(0xc000878000, 0xc000869080, 0x1, 0x2)
	/builddir/build/BUILD/openshift-clients-4.8.0/__gopath/src/github.com/openshift/oc/pkg/cli/logs/logs.go:86 +0x156
github.com/spf13/cobra.(*Command).execute(0xc000878000, 0xc000869060, 0x2, 0x2, 0xc000878000, 0xc000869060)
	/builddir/build/BUILD/openshift-clients-4.8.0/__gopath/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc000893400, 0x2, 0xc000893400, 0x2)
	/builddir/build/BUILD/openshift-clients-4.8.0/__gopath/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/builddir/build/BUILD/openshift-clients-4.8.0/__gopath/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:897
main.main()
	/builddir/build/BUILD/openshift-clients-4.8.0/__gopath/src/github.com/openshift/oc/cmd/oc/oc.go:93 +0x645



[root@localhost home]# ./oc version --client
Client Version: 4.9.0-0.nightly-2021-06-20-015701
[root@localhost home]# ./oc  logs -f bc/sample-pipeline
error: the pipeline strategy build  does not yet contain the log URL; wait a few moments, then try again

Comment 5 errata-xmlrpc 2021-10-18 17:35:43 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.9.0 bug fix and security 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-2021:3759