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

[oauth2] Remove oauth2 go.mod and go.sum #802

Merged
merged 3 commits into from
Aug 12, 2022

Conversation

pgier
Copy link
Contributor

@pgier pgier commented Jul 5, 2022

Motivation

When the oauth2 sub-directory was added in PR #313 there wasn't any justification given (AFAICT) for creating a separate sub-module instead of just treating the oauth2 sources as a normal directory. Since the oauth2 module does not have a separate release cycle, treating it as a sub-module just adds unnecessary complexity.

Modifications

Removed go.mod and go.sum from the oauth2 sub-directory. Updated the main go.mod and go.sum to included the necessary dependencies.

@pgier
Copy link
Contributor Author

pgier commented Jul 7, 2022

The main module contained a newer version of golang.org/x/oauth2 dependency than the oauth2 sub-module, so I had to update some of the tests to match the output of the newer dependency. This type of dependency mismatch will be avoided in the future using a single module defined in the root directory.

@pgier
Copy link
Contributor Author

pgier commented Jul 8, 2022

I did a bit of testing just to make sure that this change doesn't break existing apps. AFAICT, a normal go get github.com/apache/pulsar-client-go@latest possibly followed by go mod tidy should work for most users without any additional changes needed.

In some cases, users may see an ambiguous import error after upgrading.

github.com/apache/pulsar-client-go/oauth2: ambiguous import: found package github.com/apache/pulsar-client-go/oauth2 in multiple modules

The fix for this is to remove the indirect dependency line from go.mod, and the run go mod tidy.

github.com/apache/pulsar-client-go/oauth2 v0.0.0-20220630195735-e95cf0633348 // indirect

Copy link
Contributor

@liangyuanpeng liangyuanpeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and i believe that we need add notes for this problem when release.
In some cases, users may see an ambiguous import error after upgrading.

@pgier
Copy link
Contributor Author

pgier commented Jul 13, 2022

@liangyuanpeng Thanks for the feedback, I have added some info to the README about the possible error.

Copy link
Contributor

@zzzming zzzming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This removes the module definition in the oauth2 subdirectory.  Since the oauth2 module
is not released independently of the main module, it can/should be treated as a normal
module subdirectory.

Signed-off-by: Paul Gier <paul.gier@datastax.com>
Signed-off-by: Paul Gier <paul.gier@datastax.com>
Signed-off-by: Paul Gier <paul.gier@datastax.com>
Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michaeljmarshall michaeljmarshall merged commit 934c867 into apache:master Aug 12, 2022
@tisonkun
Copy link
Member

IIRC streamnative/pulsar-ctl uses oauth2 only and provides an admin API. It will be affected due to this patch and it proves that there're existing packages depends on the isolated releases.

cc @nodece

@tisonkun
Copy link
Member

And we may add some doc (README.md under oauth2?) to say this situation.

@nodece
Copy link
Member

nodece commented Aug 15, 2022

IIRC streamnative/pulsar-ctl uses oauth2 only and provides an admin API. It will be affected due to this patch and it proves that there're existing packages depends on the isolated releases.

cc @nodece

Thanks for telling me, that changes should break the pulsarctl.

I verified the pulsarctl, it works fine.

@tisonkun
Copy link
Member

@nodece thanks for your validation!

Interesting. I ever thought of you can only add a dep in the top level of go.mod.

@nodece
Copy link
Member

nodece commented Aug 15, 2022

@nodece thanks for your validation!

Interesting. I ever thought of you can only add a dep in the top level of go.mod.

When using the go get github.com/apache/pulsar-client-go/oauth2@master, the golang will add top level mod to our project, but it seems to have little effect on us:

❯ go get github.com/apache/pulsar-client-go/oauth2@master
go: added github.com/apache/pulsar-client-go v0.9.0-candidate-1.0.20220812163439-934c867b3727

@tisonkun
Copy link
Member

@nodece as long as the whole codebase is small and it isn't polluted in the linking stage, it's fine.

Although, such usage may indicate that oauth2 deserves an isolated release lifecycle. You can trade off the choices. I tend to revert this patch and keep oauth2 a separate go module. Because we accept this patch due to "there wasn't any justification given (AFAICT) for creating a separate sub-module", now we have one.

@pgier
Copy link
Contributor Author

pgier commented Aug 15, 2022

@tisonkun I tested the pulsar-ctl build, and this change has no immediate effect on it. Go modules are tied to specific checksums, so this change would only be noticeable during the next upgrade. The pulsar-ctl go.mod currently also has a replace directive which prevents upgrade.

Here are the steps to upgrade, if you want to test:

  1. remove these two lines from go.mod
    github.com/apache/pulsar-client-go/oauth2 v0.0.0-20211108044248-fe3b7c4e445b
    
    replace github.com/apache/pulsar-client-go/oauth2 => github.com/apache/pulsar-client-go/oauth2 v0.0.0-20211006154457-742f1b107403
    
  2. Get the latest commit of pulsar-client-go
    go get github.com/apache/pulsar-client-go@934c867b3727fe231100715d04e363992ca5ea38
    
  3. Run go mod tidy
  4. Build as normal make pulsarctl

Although, such usage may indicate that oauth2 deserves an isolated release lifecycle. You can trade off the choices. I tend to revert this patch and keep oauth2 a separate go module. Because we accept this patch due to "there wasn't any justification given (AFAICT) for creating a separate sub-module", now we have one.

I don't think this justifies the need for a sub-module. Go is pretty efficient in terms of using only the code that it needs, so depending on the root module instead of the oauth2 module should not add any additional code/size to your binary. The oauth2 module has never actually had an isolated release lifecycle (separate release process and version), it's always just been released along with the main project.

@tisonkun
Copy link
Member

@pgier thanks for your explanation! I'll try to learn how go.mod works nowadays in details :)

Actually, such an assumption prevents me reuse a package inner inside vitess and I'm happy to see there's no restriction.

@tisonkun
Copy link
Member

tisonkun commented Aug 16, 2022

@pgier I read your comment now. And it seems my statement above holds:

As long as the whole codebase is small and it isn't polluted in the linking stage, it's fine.

Out of topic, still, I can hardly reuse a package inner inside vitess since the top level mod is a relative large codebase to pull.

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

Successfully merging this pull request may close these issues.

6 participants