brigadecore / brigade

Event-driven scripting for Kubernetes
https://brigade.sh/
Apache License 2.0
2.41k stars 246 forks source link

brig update -c fails if project doesn't exist and not logged in as root #1947

Closed krancour closed 2 years ago

krancour commented 2 years ago

With -c set, the project should be created if it doesn't already exist, but instead there is an auth error.

This doesn't occur if you're root.

This may be a similar issue to #1893

cc @AnuragThePathak since you have experience fixing this exact sort of issue.

AnuragThePathak commented 2 years ago

Oh, the problem seems to exist in many of the actions. Should I try to find all possible places where that may exist and fix them?

AnuragThePathak commented 2 years ago

Btw can I work on this issue? I have end-semester exams throughout the next week, still can try to manage some time. If that doesn't get possible then shall fix it once it's over.

krancour commented 2 years ago

the problem seems to exist in many of the actions. Should I try to find all possible places where that may exist and fix them?

That would be great. To help narrow it down, I think all such places would be project-related.

AnuragThePathak commented 2 years ago

Do I need to check for the READER role before informing that the project doesn't exist? I was thinking of doing that after project creation attempt fails only (i.e. towards the end of the function). I have observed that if opts.CreateIfNotFound is set to false, user is already being informed about non-existence of project without checking for READER role.

AnuragThePathak commented 2 years ago

By having a look at the Update function, it seemed to me that project-authorization attempt in case of a non-existing project is leading to authorization error. Haven't studied the Authorize function of project authorizer properly yet, as it involves principal and some other stuff which I am not aware at this moment.

krancour commented 2 years ago

Forgive me... I haven't looked yet, but is the root cause of the issue not identical to https://github.com/brigadecore/brigade/issues/1893?

AnuragThePathak commented 2 years ago

Oh yeah, most probably they are indeed. I sadly was unnecessarily focusing on the -c flag. Anyway will fix it within today.

AnuragThePathak commented 2 years ago

Btw I wanted to mention that use of tilt with ctlptl made the hacking experience really awesome.

krancour commented 2 years ago

Btw I wanted to mention that use of tilt with ctlptl made the hacking experience really awesome.

So happy to hear that! It's been a major focus lately to try to make it as easy as possible to work on this.