Closed rmntrvn closed 1 year ago
I encounter similar behavior. Toggles are requested from the proxy specifically for the development
environment using an API username specific to the development
environment, but production
environment toggles are returned instead.
I don't know the details how gitlab wraps Unleash API but if you talk to a regular Unleash backend you create an API access token only for ONE environment:
Your token will look like this if it's a token for all projects: *:development.5211c6176c765a80bfda1e624a4f0834c86ae41e886efe1073abbea8
Your token will look like this if it's a token for one project (in this case a project called default): default:development.c999344fd5057bb5f5b7b41b98f4ff239cd4f65c666ca4baf031db86
Please note that each token contains the name of the environment it allows to talk to. In the above 2 cases it's development, so you'll only be able to fetch the toggles for the development environment with those tokens.
Here's a link to our docs for the client tokens: https://docs.getunleash.io/reference/api-tokens-and-client-keys#client-tokens
I found the Gitlab documentation. According to which, to run unleash proxy, you need the following:
As of Unleash Proxy version 0.2, the proxy is compatible with feature flags. To run a Docker container to connect to your project's feature flags, run the following command:Unleash Proxy example As of Unleash Proxy version 0.2, the proxy is compatible with feature flags. To run a Docker container to connect to your project's feature flags, run the following command:
docker run \
-e UNLEASH_PROXY_SECRETS=<secret> \
-e UNLEASH_URL=<project feature flags URL> \
-e UNLEASH_INSTANCE_ID=<project feature flags instance ID> \
-e UNLEASH_APP_NAME=<project environment> \
-e UNLEASH_API_TOKEN=<tokenNotUsed> \
-p 3000:3000 \
unleashorg/unleash-proxy
Variable | Value | |
---|---|---|
UNLEASH_PROXY_SECRETS |
Shared secret used to configure an Unleash Proxy client. | |
UNLEASH_URL |
Your project's API URL. For more details, read Get access credentials. | |
UNLEASH_INSTANCE_ID |
Your project's Instance ID. For more details, read Get access credentials. | |
UNLEASH_APP_NAME |
The name of the environment the application runs in. For more details, read Get access credentials. | |
UNLEASH_API_TOKEN |
Required to start the Unleash Proxy, but not used to connect to GitLab. Can be set to any value. | Variable |
Value
UNLEASH_PROXY_SECRETS Shared secret used to configure an Unleash Proxy client.
UNLEASH_URL Your project's API URL. For more details, read Get access credentials.
UNLEASH_INSTANCE_ID Your project's Instance ID. For more details, read Get access credentials.
UNLEASH_APP_NAME The name of the environment the application runs in. For more details, read Get access credentials.
UNLEASH_API_TOKEN Required to start the Unleash Proxy, but not used to connect to GitLab. Can be set to any value.
There is a limitation when using the Unleash Proxy where each proxy instance can request flags only for the environment named in UNLEASH_APP_NAME
. The Proxy sends this to GitLab on behalf of the client, which means the client can't override it.
Thus, earlier I specified the Gitlab Access Token for the UNLEASH_API_TOKEN value, although I could specify any value. And UNLEASH_APP_NAME indicated the value of CI_PROJECT_NAME, but it was necessary to specify the name of the environment.
My problem is solved.
@rmntrvn Thanks for letting us know. It looks like more people stumbled upon this issue: https://gitlab.com/gitlab-org/gitlab/-/issues/354087. Anyway I'm closing this ticket for now since Unleash itself can't do anything about it.
Describe the bug
Feature Flags have been created in the Gitlab repository named test-feature1 (for All Environments) and test-feature2 (for dev environments).
Unleash-proxy is configured with this repository - the following environment variables are set:
When I try to get Feature Flags from unleash-proxy I only get test-feature1 (For All Environments) and not for test-feature2 (for dev).
If you set the Feature Flags for test-feature2 to All Environments, then the query returns two Feature Flags.
test-feature1 (For All Environments) and test-feature2 (For dev) are both enabled.
How to get Feature Flag from request to unleash proxy for dev environment?
Steps to reproduce the bug
No response
Expected behavior
Should return flags for dev environments.
Logs, error output, etc.
No response
Screenshots
No response
Additional context
No response
Unleash version
0.13.1
Subscription type
Open source
Hosting type
Self-hosted
SDK information (language and version)
No response