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

Remove v1 hack from CanonicalFnAPIUrl #31

Merged

Conversation

vzDevelopment
Copy link
Contributor

@vzDevelopment vzDevelopment commented Apr 10, 2019

The v1 API is no longer supported so we can now remove this hack. C.f. the discussion on pull request 30 and the issue: fnproject/fn#1347.

Before this change, if the FN_API_URL was set to anything ending in /v1 e.g. http://localhost:8888/fn-routing/v1/ then it wouldn't work:

# Sever is running on localhost:8081
# Reverse proxy is sending localhost:8888:fn-routing/v1/ -> localhost:8081

vzarola-Mac:~ vzarola$ echo $FN_API_URL
http://localhost:8888/fn-routing/v1/
vzarola-Mac:~ vzarola$ fn version
Client version is latest version: 0.5.71
Server version:  ?

Proxy logs:

INFO      Apr 10 11:54:43 [17970]: Added reverse proxy rule: /fn-routing/v1/ -> http://127.0.0.1:8081/
CONNECT   Apr 10 11:56:38 [17979]: Request (file descriptor 10): GET /fn-routing/version HTTP/1.1
ERROR     Apr 10 11:56:38 [17979]: Bad request, no mapping for '/fn-routing/version' found


vzarola-Mac:~ vzarola$ fn list app

Fn: no consumer: "text/html"

vzarola-Mac:~ vzarola$ fn invoke testpython testpython

Fn: no consumer: "text/html"

After this change it is working as expected:

# Sever is running on localhost:8081
# Reverse proxy is sending localhost:8888:fn-routing/v1/ -> localhost:8081

vzarola-Mac:~ vzarola$ fn version
Client version is latest version: 0.5.71
Server version:  0.3.687

CONNECT   Apr 10 11:57:52 [17976]: Rewriting URL: /fn-routing/v1/version -> http://127.0.0.1:8081/version

vzarola-Mac:~ vzarola$ fn list app
NAME		ID
testapp		01D7MD7GTBNG8G00GZJ0000001
testpython	01D7PVG04HNG8G00GZJ0000001

vzarola-Mac:~ vzarola$ fn invoke testpython testpython
{"host": "localhost", "user-agent": "Go-http-client/1.1", "content-length": "0", "accept-encoding": "gzip", "content-type": "text/plain", "fn-call-id": "01D83ECV1BNG8G00GZJ0000001", "fn-deadline": "2019-04-10T10:59:16Z"}

I have also updated the unit tests accordingly which can be tested with cd provider && go test

N.b. you'll need my changes from #30 in order for fn version to work with paths.

The v1 API is no longer supported so we can now remove this hack. C.f.
the discussion on fnproject#30 and fnproject/fn#1347.
@vzDevelopment
Copy link
Contributor Author

vzDevelopment commented Apr 10, 2019

Some more testing in case it helps:

Testing with a URL not containing v1

# Server is running on localhost:8081
# Reverse proxy is redirecting locahost:8888/fn/ -> localhost:8081

vzarola-Mac:~ vzarola$ echo $FN_API_URL
http://localhost:8888/fn/
vzarola-Mac:~ vzarola$ fn version
Client version is latest version: 0.5.71
Server version:  0.3.687

No path, but non-standard port

# Server is running on localhost:8081

vzarola-Mac:~ vzarola$ export FN_API_URL=http://localhost:8081
vzarola-Mac:~ vzarola$ fn version
Client version is latest version: 0.5.71
Server version:  0.3.687

Default settings

Server is running on localhost:8080

vzarola-Mac:~ vzarola$ fn list context
CURRENT	NAME		PROVIDER	API URL				REGISTRY
*	default		default		http://localhost:8080		fndemouser
	distributed-fn	default		http://api.fn.local:8080	localhost

vzarola-Mac:~ vzarola$ echo $FN_API_URL

vzarola-Mac:~ vzarola$ fn version
Client version is latest version: 0.5.71
Server version:  0.3.687

@vzDevelopment
Copy link
Contributor Author

Although looking at https://github.com/search?p=1&q=org%3Afnproject+%2Fv1&type=Code there are still quite a few references to /v1 so maybe it'd be safer to clean these up before merging this.

@rdallman rdallman reopened this Apr 11, 2019
@rdallman
Copy link
Contributor

@vzDevelopment can we merge this? i think we should remove this and clean up refs to v1 everywhere, I know that extensions still root things at v1 but i'm kinda doubting anyone was regenerating the client bindings by copying our swagger and adding their endpoints with v1 (our swagger is v2)

i'll kick circleci, they've been having issues...

thanks for PR

@rdallman rdallman merged commit 407fd7e into fnproject:master Apr 11, 2019
@vzDevelopment
Copy link
Contributor Author

vzDevelopment commented Apr 12, 2019

Thanks for reviewing and merging, Reed. Yeah I closed as I wanted to go through the v1 references and ensure these changes wouldn't cause anything to break before disrupting you with the PR. If you're happy then that's good with me.

@vzDevelopment vzDevelopment deleted the bugfix/fn_1347-remove_v1_hack branch April 12, 2019 08:33
vzDevelopment added a commit to vzDevelopment/ui that referenced this pull request Apr 12, 2019
The V1 Fn Server API is no longer supported. Therefore, make a start on
migrating the UI over the the V2 API. This commit migrates the App
functionality over and means users can now add/delete/edit apps.

This contributes to: fnproject#52, fnproject/fn#1347, fnproject/fn_go#31, and
fnproject/fn#1258
vzDevelopment added a commit to vzDevelopment/ui that referenced this pull request Apr 15, 2019
The V1 Fn Server API is no longer supported. Therefore, make a start on
migrating the UI over the the V2 API. This commit migrates the App
functionality over and means users can now add/delete/edit apps.

This contributes to: fnproject#52, fnproject/fn#1347, fnproject/fn_go#31, and
fnproject/fn#1258
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.

2 participants