-
Notifications
You must be signed in to change notification settings - Fork 95
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
THREESCALE-9558: Separate env vars for Core API and public route #821
Conversation
Skipping CI for Draft Pull Request. |
1fe7039
to
393dc68
Compare
} | ||
|
||
s.options.BackendServiceEndpoint = urlObj.String() | ||
urlObj.Path += "/internal/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not checking for possible trailing slashes in the base URL, so may potentially result in double slashes (which is not very critical, IMO).
In Go 1.19 the following can be done instead:
s.options.CoreInternalAPIEndpoint = urlObj.JoinPath("/internal/").String()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not yet there (Go 1.19). We recently updated to 1.18 #814
If we needed to upgrade the secret content (which I think it is not needed), I would remove this logic in the 3scale operator of adding internal
and rely on the value of the secret. I do not know the reason why the operator needs to add this /internal
to the path.
However, we do not need to upgrade the content of the secret, so I would just leave as it is:
if urlObj.Path == "" {
urlObj.Path = "/internal/"
}
s.options.CoreInternalAPIEndpoint = urlObj.String()
For me the initial intention was to allow any custom path if required. Only if the custom path is not there, the operator adds the /internal
. With urlObj.Path += "/internal/"
you are breaking that behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comment here that provides more contexts.
With regards to how to append the /internal/
path (only applicable if we go with the option 2), I think the option I suggested is more flexible. It permits the service URL for backend listener to have some path already.
So, if we set https://my-apisonator-stub.somedomain.com/whatever
as service_endpoint
(assuming apisonator is listening at that address), then the core API endpoint will be set to https://my-apisonator-stub.somedomain.com/whatever/internal
correctly.
While, in the option you suggest it will not work (the /internal
will not be appended).
|
||
s.options.BackendServiceEndpoint = urlObj.String() | ||
urlObj.Path += "/internal/" | ||
s.options.CoreInternalAPIEndpoint = urlObj.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the PR builds the CoreInternalAPIEndpoint
here to set its value to THREESCALE_CORE_INTERNAL_API
env var, but I am wondering if it could make sense to remove this completely, and instead have the operator only set the env vars for the route (BACKEND_PUBLIC_URL
) and the internal service (e.g. call it BACKEND_URL
), and append /internal/
path in porta configuration (e.g. "#{BACKEND_URL}/internal/"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be my guest
With the current implementation in this PR, there are three env vars
APICAST_BACKEND_ROOT_ENDPOINT
->https://backend-3scale.eguzki-3scale.apps.example.com
THREESCALE_CORE_INTERNAL_API
->http://backend-listener:3000/internal
BACKEND_PUBLIC_URL
->https://backend-3scale.eguzki-3scale.apps.example.com
APICAST_BACKEND_ROOT_ENDPOINT and BACKEND_PUBLIC_URL will always have the same value. For now at least. Seems duplicated, shall we simplify it?
For me it seems like we need two of them:
- BACKEND_PUBLIC_URL -> https://backend-3scale.eguzki-3scale.apps.example.com
- BACKEND_INTERNAL_URL -> http://backend-listener:3000/internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In system we still need the backend internal URL without the /internal
prefix, more info on that in this comment.
As for APICAST_BACKEND_ROOT_ENDPOINT
and BACKEND_PUBLIC_URL
indeed the values are duplicated, and I also thought about whether we need to merge them into one.
I think there could potentially be a scenario where the customer would want to have different values.
BACKEND_PUBLIC_URL
would be used by Active Docs (so that the customer can make requests to the Service Management API from the browser)
APICAST_BACKEND_ROOT_ENDPOINT
is used by APIcast (so that APIcast can make requests to the Service Management API)
So, depending on where APIcast is deployed (if it's outside of OCP), maybe these two values could be different (within private network vs public).
On the other hand, we could indeed make it simple, and just use one value, and if somebody needs to distinguish these two, they can open an RFE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I maintained both APICAST_BACKEND_ROOT_ENDPOINT
and BACKEND_PUBLIC_URL
, even though they have the same value.
0684f0e
to
90cb5e2
Compare
Missing upgrade procedure. Let's say 3scale is running 2.13. The new 2.14 is deployed. The operator will needs to do the changes, removing deprecated env vars and adding new ones to the existing deployment config. I can help with that procedure. |
I see. Thanks @eguzki! Do you maybe have an example of a similar upgrade? |
First, I would decide on what we do and then execute |
Thank you for the comments @eguzki ! Let me provide some context (which I should have done upon opening the PR). The
From system component, for different things we need different values. Backend (apisonator) also exposes different APIs, one is the "transactions" one, and the other one is called Core API, which is behind I am just trying to figure out what's the best way to append this We can do it in multiple places:
This is the most flexible, because it would allow the user to configure the route themselves. On the other hand - why would they do that? The only use case I can think of is to be able to mock this API, but in this case the whole apisonator should be stubbed/mocked, I think.
Then porta configuration file would need to append @3scale/system what do you think? I am more inclined to option 3 to be honest. I think the operator doesn't need to know the internals - just "connect" system to backend, and let them figure out their communication on their own. |
While writing my previous comment, I actually realized that we are currently missing this environment variable:
And this is because this value is hardcoded in the porta config: https://github.com/3scale/porta/blob/3scale-2.13.2-GA/openshift/system/config/backend.yml#L2 I think it's not cool, and we need to add this env var. Latest |
Agreed that porta and backend better figure out between themselves. Also why provide two values that are basically the same except for the |
Thanks @akostadinov So, you agree with the 3rd option? |
0639d2d
to
68c5875
Compare
I'm not sure why assets-validate check fails, the file it references is auto-generated. |
Because of this https://github.com/3scale/3scale-operator/pull/821/files#diff-559feb95c027cff90747b7e89b79d2886afcc3b13c7741a25752981b64236f20L292 |
Code Climate has analyzed commit 663071b and detected 0 issues on this pull request. View more on Code Climate. |
Related to 3scale/porta#3324
The description about different Backend URLs that are used in the System component are provided in the porta PR description.
This PR removes the
BACKEND_ROUTE
environment variable, whose value is nowhttp://backend-listener:3000/internal/
- which is confusing because "route" kind of suggests that it would be the value of the backend OCP route.What
system-app
env varAPICAST_BACKEND_ROOT_ENDPOINT
system-app
env varBACKEND_ROUTE
system-app
env varBACKEND_URL
:service_endpoint
value frombackend-listener
secret (i.e.http://backend-listener:3000
). Note/internal
is no longer provided. That will be added by System.system-app
env varBACKEND_PUBLIC_URL
:route_endpoint
value frombackend-listener
secret (i.e.https://backend-3scale.apps.mycluster.com
).Verification steps
New deployment
wildcardDomain
must be something valid (only if it is going to be used later). Usually${PROJECT_NAME}.apps.${CLUSTER_DOMAIN}
The above "wait" ensures the pods are up and running.
APICAST_BACKEND_ROOT_ENDPOINT
orBACKEND_ROUTE
env varsBACKEND_URL
env var from thebackend-listener
secret andservice_endpoint
fieldIt is replicated 4 times in 4 different deployment: pre-hook pod deployment container and
system-master
,system-provider
,system-developer
containers.BACKEND_PUBLIC_URL
env var from thebackend-listener
secret androute_endpoint
fieldThe
backend-listener
secret valuesUpgrade from 2.13
wildcardDomain
must be something valid (only if it is going to be used later). Usually${PROJECT_NAME}.apps.${CLUSTER_DOMAIN}
The above "wait" ensures the pods are up and running.
APICAST_BACKEND_ROOT_ENDPOINT
andBACKEND_ROUTE
env var. Note thatBACKEND_ROUTE
is set tohttp://backend-listener:3000/internal/
The upgrade should happen automatically
The above "wait" ensures the pods are up and running.
ready
. Note thesystem-app
deployment as it should have been rolled out automatically.APICAST_BACKEND_ROOT_ENDPOINT
orBACKEND_ROUTE
env varsBACKEND_URL
env var from thebackend-listener
secret andservice_endpoint
fieldIt is replicated 4 times in 4 different deployment: pre-hook pod deployment container and
system-master
,system-provider
,system-developer
containers.BACKEND_PUBLIC_URL
env var from thebackend-listener
secret androute_endpoint
fieldThe
backend-listener
secret values