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

panic when getting pull request info #24

Closed
vbehar opened this issue Mar 26, 2020 · 4 comments
Closed

panic when getting pull request info #24

vbehar opened this issue Mar 26, 2020 · 4 comments

Comments

@vbehar
Copy link
Contributor

vbehar commented Mar 26, 2020

with version 0.0.17

after fixing the missing permissions #23 I got the following panic.

It is trying to create a git user, because it failed to retrieve the existing one. for some reason it failed to retrieve the ghOwner at https://github.com/jenkins-x/jx/blob/master/pkg/gits/provider.go#L512
I thought it was a missing permission to read the jx-auth-config configmap, but even after adding this permission it is still failing.

do you have an idea?

thanks

Watching slackbots in namespace jx
Watching pipeline activities in namespace jx and slackbot config test-slack-bot
activity ...
ERROR: logging before flag.Parse: E0326 13:27:57.304913       1 runtime.go:69] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid
memory address or nil pointer dereference)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4d4fa7]

goroutine 73 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/runtime/runtime.go:58 +0x105
panic(0x23d69e0, 0x4977650)
        /usr/local/go/src/runtime/panic.go:522 +0x1b5
fmt.Fprintf(0x0, 0x0, 0x277ef5f, 0x5, 0xc0016a8ed0, 0x1, 0x1, 0x40c148, 0xc0, 0x288af90)
        /usr/local/go/src/fmt/print.go:200 +0x77
gopkg.in/AlecAivazis/survey.v1/terminal.(*Cursor).HorizontalAbsolute(...)
        /go/pkg/mod/gopkg.in/!alec!aivazis/survey.v1@v1.8.3/terminal/cursor.go:54
gopkg.in/AlecAivazis/survey.v1/core.(*Renderer).resetPrompt(0xc000293b90, 0x0)
        /go/pkg/mod/gopkg.in/!alec!aivazis/survey.v1@v1.8.3/core/renderer.go:59 +0x12c
gopkg.in/AlecAivazis/survey.v1/core.(*Renderer).Render(0xc000293b90, 0x285344a, 0x1f0, 0x25a2d80, 0xc00122cd80, 0x0, 0xc0001f2a40)
        /go/pkg/mod/gopkg.in/!alec!aivazis/survey.v1@v1.8.3/core/renderer.go:69 +0x3b
gopkg.in/AlecAivazis/survey%2ev1.(*Input).Prompt(0xc000293b90, 0x0, 0x0, 0x0, 0x0)
        /go/pkg/mod/gopkg.in/!alec!aivazis/survey.v1@v1.8.3/input.go:44 +0xe9
gopkg.in/AlecAivazis/survey%2ev1.Ask(0xc0016a9280, 0x1, 0x1, 0x22491a0, 0xc00090e3e0, 0xc0016a92f0, 0x1, 0x1, 0x10b65c1, 0x2576d00)
        /go/pkg/mod/gopkg.in/!alec!aivazis/survey.v1@v1.8.3/survey.go:148 +0x187
gopkg.in/AlecAivazis/survey%2ev1.AskOne(0x3192600, 0xc000293b90, 0x22491a0, 0xc00090e3e0, 0x2889770, 0xc0016a92f0, 0x1, 0x1, 0xc0016a9318, 0x2)
        /go/pkg/mod/gopkg.in/!alec!aivazis/survey.v1@v1.8.3/survey.go:94 +0xcd
github.com/jenkins-x/jx/pkg/util.PickValue(0xc001305920, 0x14, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/jenkins-x/jx@v0.0.0-20200305075422-16ecced629f9/pkg/util/pickers.go:25 +0x192
github.com/jenkins-x/jx/pkg/auth.(*AuthConfig).EditUserAuth(0xc001797500, 0xc001233248, 0xa, 0xc001252aa0, 0x0, 0x0, 0x0, 0xc001252af0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/jenkins-x/jx@v0.0.0-20200305075422-16ecced629f9/pkg/auth/auth_config.go:352 +0x2d1
github.com/jenkins-x/jx/pkg/gits.createUserForServer(0x25e1100, 0xc001252aa0, 0x31c5c00, 0xc0016dec60, 0xc001797620, 0x32377e0, 0xc00186ea78, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/jenkins-x/jx@v0.0.0-20200305075422-16ecced629f9/pkg/gits/provider.go:543 +0x151
github.com/jenkins-x/jx/pkg/gits.CreateProviderForURL(0x2376401, 0x31c5c00, 0xc0016dec60, 0x2780ae7, 0x6, 0xc001233240, 0x12, 0x0, 0x0, 0x32377e0, ...)
        /go/pkg/mod/github.com/jenkins-x/jx@v0.0.0-20200305075422-16ecced629f9/pkg/gits/provider.go:523 +0x583
github.com/jenkins-x/jx/pkg/cmd/opts.(*CommonOptions).GitProviderForGitServerURL(0xc00031b500, 0xc001233240, 0x12, 0x2780ae7, 0x6, 0x0, 0x0, 0x20bd00b, 0xc0014ee803, 0x4, ...)
        /go/pkg/mod/github.com/jenkins-x/jx@v0.0.0-20200305075422-16ecced629f9/pkg/cmd/opts/git.go:269 +0x25e
github.com/jenkins-x/jx/pkg/cmd/opts.(*CommonOptions).CreateGitProviderForURLWithoutKind(0xc00031b500, 0xc00061a800, 0x32, 0x0, 0xc000a85848, 0x40c148, 0x60, 0x260c860)
        /go/pkg/mod/github.com/jenkins-x/jx@v0.0.0-20200305075422-16ecced629f9/pkg/cmd/opts/git.go:287 +0x178
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).getPullRequest(0xc0002597a0, 0xc0013471d0, 0xb, 0xc00005e501, 0xc00005e500, 0xc000a85918)
        /workspace/source/pkg/slackbot/bot.go:686 +0x19e
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).isEnabled(0xc0002597a0, 0xc0013471d0, 0xc0003afa10, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc000a85a80, 0x18, ...)
        /workspace/source/pkg/slackbot/bot.go:132 +0xff
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).PipelineMessage(0xc0002597a0, 0xc0013471d0, 0x278b5e4, 0xc)
        /workspace/source/pkg/slackbot/bot.go:161 +0x180
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).onObj(0xc0002597a0, 0x2732ce0, 0xc0013471d0)
        /workspace/source/pkg/slackbot/activity.go:49 +0x110
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
        /go/pkg/mod/k8s.io/client-go@v0.0.0-20190528110200-4f3abb12cae2/tools/cache/controller.go:195
k8s.io/client-go/tools/cache.(*processorListener).run.func1.1(0x0, 0x0, 0x0)
        /go/pkg/mod/k8s.io/client-go@v0.0.0-20190528110200-4f3abb12cae2/tools/cache/shared_informer.go:554 +0x26d
k8s.io/apimachinery/pkg/util/wait.ExponentialBackoff(0x989680, 0x3ff0000000000000, 0x3fb999999999999a, 0x5, 0xc0016a9e38, 0x42b6af, 0xc0000e8940)
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/wait/wait.go:203 +0xde
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
        /go/pkg/mod/k8s.io/client-go@v0.0.0-20190528110200-4f3abb12cae2/tools/cache/shared_informer.go:548 +0x89
k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1(0xc000a5cf68)
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/wait/wait.go:133 +0x54
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc0016a9f68, 0xdf8475800, 0x0, 0x42bf01, 0xc0000ba600)
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/wait/wait.go:134 +0xf8
k8s.io/apimachinery/pkg/util/wait.Until(...)
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/wait/wait.go:88
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000a33a00)
        /go/pkg/mod/k8s.io/client-go@v0.0.0-20190528110200-4f3abb12cae2/tools/cache/shared_informer.go:546 +0x9c
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1(0xc000316370, 0xc000092080)
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/wait/wait.go:71 +0x4f
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
        /go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190221084156-01f179d85dbc/pkg/util/wait/wait.go:69 +0x62
@vbehar
Copy link
Contributor Author

vbehar commented Mar 26, 2020

after reading the code, I found that it's normal to have an empty ghOwner because we're not using GHA

@vbehar
Copy link
Contributor Author

vbehar commented Mar 26, 2020

I tried to enable batch mode in the common options, and now have the following:

WARNING: creating user for server "https://github.com": running in batch mode and no default Git username found

although I have a jx-auth-config configmap with the following data

  gitAuth.yaml: |
    currentserver: "https://github.com"
    defaultusername: "dailymotion-jenkins-bot"
    pipelineserver: "https://github.com"
    pipelineusername: "dailymotion-jenkins-bot"
    servers:
    - currentuser: "dailymotion-jenkins-bot"
      kind: "github"
      name: "github"
      url: "https://github.com"
      users:
      - apitoken: "vault:jx-green/pipelineUser:token"
        bearertoken: ""
        username: "dailymotion-jenkins-bot"

and everything else is working (the controller-build is able to retrieve pull-request informations from github...)

@vbehar
Copy link
Contributor Author

vbehar commented Mar 26, 2020

ok after copying the permissions from the controllerbuild role, I managed to make it work. I'll find the minimum required permissions and add them to #23

vbehar added a commit to vbehar/slack that referenced this issue Mar 26, 2020
- adding missing read permissions on environments, which resulted in the following error

```
WARNING: error loading TeamSettings to determine if in GitHub app mode: failed to setup the dev environment for namespace 'jx': environments.jenkins.io is forbidden: User "system:serviceaccount:jx:jenkins-x-slack" cannot create resource "environments" in API group "jenkins.io" in the namespace "jx"
```

- adding missing read permissions on configmaps/serviceaccounts/vault, to be able to read git auth config - fixes jenkins-x-plugins#24

- move the role rules in the chart values, to allow customization of the rules without requiring updates of the chart
@vbehar
Copy link
Contributor Author

vbehar commented Mar 26, 2020

found it: it requires serviceaccounts and vault

@vbehar vbehar closed this as completed Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant