1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
Commit Graph

758 Commits

Author SHA1 Message Date
Gastón Fournier
30ed92cbbb
fix: Add missing sortOrder property (#2940)
Add sortOrder property to some OpenAPI schemas
2023-01-20 08:46:01 +01:00
sjaanus
53c11b8585
Add feature name to strategy schema (#2936) 2023-01-19 15:17:36 +02:00
Fredrik Strand Oseberg
f4d857285b
feat: status API (#2931)
Initial status API
2023-01-19 13:27:50 +01:00
Nuno Góis
7d73d772df
feat: add the account abstraction logic (#2918)
https://linear.app/unleash/issue/2-579/improve-user-like-behaviour-for-service-accounts-accounts-concept

Builds on top of https://github.com/Unleash/unleash/pull/2917 by moving
the responsibility of handling both account types from `users` to
`accounts`.

Ideally:
 - `users` - Should only handle users;
 - `service-accounts` - Should only handle service accounts;
 - `accounts` - Should handle any type of account;

This should hopefully also provide a good building block in case we
later decide to refactor this further down the `accounts` path.
2023-01-18 16:08:07 +00:00
Ivar Conradi Østhus
bb20c6d102
fix: project feature_count should not include archived (#2919)
fixes: #2923
2023-01-18 15:58:27 +01:00
andreas-unleash
5ceab6f989
Add flag to control CASE_INSENSITIVE_IN_OPERATORS until SDKs catch up (#2927)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-01-18 15:53:14 +02:00
andreas-unleash
91e20cc09a
Add support for case for IN and NOT_IN operators (#2924)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

Adds support for case for IN and NOT_IN operators
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->

<img width="1547" alt="Screenshot 2023-01-18 at 11 35 10"
src="https://user-images.githubusercontent.com/104830839/213136158-25c525c8-de82-423b-93d1-5ae6eb8469fa.png">

## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-01-18 14:42:26 +02:00
Fredrik Strand Oseberg
89163b8719
refactor/clean-up-get-project (#2925)
This PR moves the getProjectOverview method out from the project health
controller. It doesn't make sense that this method lives here anymore,
as over time it has grown into method that relays all information about
a single project. It makes more sense that this now lives on the root of
the project api. Also removes unwanted duplication of getProjectOverview
from the project-service and the project-health-service.
2023-01-18 13:22:58 +01:00
Nuno Góis
d63b3c69fe
feat: adapt user logic to better adapt to SAs (#2917)
https://linear.app/unleash/issue/2-579/improve-user-like-behaviour-for-service-accounts-accounts-concept

<img width="803" alt="image"
src="https://user-images.githubusercontent.com/14320932/213011584-75870595-988d-49bc-a7bf-cd1ffd146bca.png">

Makes SAs behave more like users. 

Even though they share the same `users` database table, the `is_service`
column distinguishes them. This PR makes the distinction a bit less
obvious by not filtering out SAs for some methods in the user store,
returning both account types and their respective account type
information so we can handle them properly on the UI.

We felt like this was a good enough approach for now, and a decent
compromise to move SAs forward. In the future, we may want to make a
full refactor with the `accounts` concept in mind, which we've
experimented with in the
[accounts-refactoring](https://github.com/Unleash/unleash/tree/accounts-refactoring)
branches (both OSS and Enterprise).
 
https://github.com/Unleash/unleash/pull/2918 - Moves this a bit further,
by introducing the account service and store.
2023-01-18 12:12:44 +00:00
Fredrik Strand Oseberg
bf7ef62059
feat: initial status box implementation (#2913)
First iteration of new status boxes
2023-01-18 10:10:41 +01:00
sjaanus
16bca1260c
Segment export (#2922)
Segment export
2023-01-18 10:41:22 +02:00
sjaanus
b895c99743
Export features (#2905) 2023-01-17 13:10:20 +02:00
Gastón Fournier
005e5b1d15
fix: found an edge case exporting variants (#2900)
## About the changes
When exporting v3, for variants backward compatibility, we need to find
one featureEnvironment and fetch variants from there.
In cases where the default environment is disabled (therefore does not
get variants per environment when added), it can be still be selected
for the export process. Therefore variants don't appear in the feature
when they should be there.

An e2e test that fails with the previous implementation was added to
validate the behavior

This comes from our support ticket 404
2023-01-13 14:55:57 +01:00
Mateusz Kwasniewski
5569101f30
feat: import feature strategies (#2885) 2023-01-12 15:24:34 +01:00
Mateusz Kwasniewski
a52d3b0f77
test: fix test runs to 1 (#2886) 2023-01-12 13:53:05 +01:00
Gastón Fournier
ce815e5f29
feat: report app names only if below a threshold (#2737)
## About the changes
Introduce a snapshot version of instanceStats inside
instance-stats-service to provide a cached state of the statistics
without compromising the DB.

### Important notes
Some rule-of-thumb applied in the PR that can be changed:
1. The snapshot refresh time
2. The threshold to report appName with the metrics

## Discussion points
1. The snapshot could be limited to just the information needed (things
like `hasOIDC` don't change until there's a restart), to optimize the memory usage
3. metrics.ts (used to expose Prometheus metrics) has a [refresh
interval of
2hs](2d16730cc2/src/lib/metrics.ts (L189-L195)),
but with this implementation, we could remove that background task and
rely on the snapshot
4. We could additionally update the snapshot every time someone queries
the DB to fetch stats (`getStats()` method), but it may increase
complexity without a significant benefit

Co-authored-by: Mateusz Kwasniewski <kwasniewski.mateusz@gmail.com>
Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>
2023-01-12 11:26:59 +01:00
Mateusz Kwasniewski
be1762d33f
Scheduler abstraction (#2829) 2023-01-11 16:15:53 +01:00
sjaanus
eb7e82dff2
Export with strategies (#2877) 2023-01-11 15:00:20 +00:00
Mateusz Kwasniewski
afdcd45042
feat: first skeleton of the batch import (#2868)
First skeleton of batch import:
* injecting feature toggle service because I want to reuse logic and not
just the store
2023-01-11 15:19:16 +01:00
Gastón Fournier
fa47fee55e
feat: RBAC read params from body (#2846)
## About the changes
This is a follow-up on #1953

This implementation generalizes how we fetch some standard parameters
from the query parameters or request body.

## Discussion points
Unfortunately, we have not used standard names for our APIs and one
example is our `projectId` (in some cases we just used `project`).
Ideally, we're only using one way of sending these parameters either
`projectId` or `project` (same applies to `environment` vs
`environmentId`).

If both parameters are present, due to historical reasons, we'll give
precedence to:
- `projectId` over `project`
- `environment` over `environmentId` 

In the presence of both query parameters and body, we'll give precedence
to query parameters also for historical reasons.
2023-01-11 10:48:27 +01:00
andreas-unleash
e050495199
fix feature-schema.ts (#2729)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
This PR fixes the admin feature schema by moving the `strategies`
(featureStrategySchema) from the root of `feature` object to
`feature.environment`
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-01-11 10:53:43 +02:00
Gastón Fournier
9ea67a74b4
feat: add error logs for addons (#2739)
## About the changes
This uses log-level warning so we can turn off the log without turning
off all error logs. This could potentially be tweaked further by using
log categories in the log configuration.

Closes #2057
2023-01-11 09:13:22 +01:00
sjaanus
6c9ef53ea4
Export import flag (#2866)
Export import flag
2023-01-11 09:23:47 +02:00
sjaanus
11d5a157c4
Remove E flag (#2832) 2023-01-11 09:00:26 +02:00
sjaanus
f3f3a59e5e
Import export (#2865) 2023-01-10 15:59:02 +02:00
Ivar Conradi Østhus
0c1e997f0b
fix: store snapshots in temp folder (#2864) 2023-01-10 13:53:00 +01:00
Nuno Góis
997dbbbea5
Feat sa table info (#2848)
https://linear.app/unleash/issue/2-543/show-relevant-information-on-the-service-accounts-table

Shows relevant information on the table, like total PATs and the last
time a service account was active based on latest seen PAT for that
account. Adapts to the latest related PR on enterprise.


![image](https://user-images.githubusercontent.com/14320932/211312719-c4ed940a-723b-4b2e-a79e-8e7cdbda7c58.png)
2023-01-09 16:18:37 +00:00
sjaanus
7a1c18bd35
Ability to add AJV schemas runtime (#2792) 2023-01-06 11:41:39 +02:00
Mateusz Kwasniewski
5ac08e06d9
fix: when health is 0 we should not show 100 (#2833) 2023-01-05 15:14:27 +01:00
Gastón Fournier
29be130757
fix: enforce weight precision to 1 decimal (#2749)
## About the changes
According to our docs, we only support up to 1 decimal place for
weights. This is to use integers to represent the percentages (we divide
them by 10) and supporting more decimals results in bad maths due to
floating point arithmetics.

This PRs adds Frontend and Backend validations to enforce this
restriction

Closes #2222

## Discussion points
Should we reconsider supporting more decimal places, that door remains
open, but for now we'll just adhere to our documentation because that
change would require some development.
2023-01-05 12:39:18 +01:00
Tymoteusz Czech
1653b0449a
Orval generator POC (#2724)
for #2715
2023-01-05 11:57:53 +01:00
Gastón Fournier
58dd09f3e1
fix: export features with variants event when feature is disabled (#2824)
## About the changes
When exporting features one is normally also interested in disabled
features, so they are also included in the export file, while the
variants are not. I do not see a good reason for that, so this PR
removes the check and exports the variants then as well.
I could also add an option as well, but as long as there is no good
reason for ignoring the variants I would just export them with the
features.

This PR adds tests on #2719

Closes #2719

Co-authored-by: Martin Joehren <martin.joehren@esailors.de>
2023-01-05 12:30:07 +02:00
Ivar Conradi Østhus
3a8107ce6e
fix: state-service should always keep api keys (#2552)
We have experienced side-effects where the import was unexpected and
resulted in environments thought to be removed. This had the unexpected
side-effect of also deleting API keys for some environments not part of
the import file.

This commit removes the ability of the state-service to mutate api keys
directly. There is no compelling reasons why we should remove API keys
as part of an import query.

Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-01-04 11:24:34 +00:00
Gastón Fournier
bf77182ca7
feat: limit the amount of results coming from Prometheus (#2776)
## About the changes
To avoid showing too much data in the traffic screen, limit the number
of results to `topk`.

## Discussion points
Top 10 is a rule of thumb, but maybe we could do top 25. Until we gather
more data, I believe this should be good enough
2023-01-04 11:00:04 +01:00
Nuno Góis
28fbcf69ec
feat: enterprise service accounts (BE) (#2806)
https://linear.app/unleash/issue/2-537/back-end-for-service-accounts

Supersedes https://github.com/Unleash/unleash/pull/2731
2023-01-03 15:15:32 +00:00
sjaanus
bae623d69e
Fix joi failing starting from 17.7.0 release (#2790) 2023-01-03 11:50:00 +02:00
sjaanus
8a8cd1bf27
UI Flags cleanup (#2778) 2023-01-02 15:41:43 +02:00
Nuno Góis
88004a6138
feat: allows creation of PATs for other users (#2718)
https://linear.app/unleash/issue/2-530/api-allow-creation-of-pats-for-other-users


![image](https://user-images.githubusercontent.com/14320932/208720680-5d5ccee7-1972-4f5b-8024-3a69d50a571f.png)

Adds and takes into account the following permissions:
 - **READ_USER_PAT**;
 - **CREATE_USER_PAT**;
 - **DELETE_USER_PAT**;
 
 API only, will make some exploration on UI soon.

Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
2023-01-02 10:49:57 +00:00
sjaanus
ec535ad7cc
Make it possible to validate enterprise schema with respondWithValidation (#2781)
Now respondWithValidation<T, S = SchemaId> can be called in oss and
enterprise to validate against needed schema.
2023-01-02 12:08:27 +02:00
sjaanus
6c621bf65b
Fix crashing search bars (#2765) 2022-12-28 12:35:27 +02:00
Nuno Góis
aaa96f71cb
feat: message banner (#2726)
Related to:
https://linear.app/unleash/issue/2-511/exploration-build-data-for-the-possibility-of-showing-an-alert-to-the
Namely:
https://unleash-internal.slack.com/archives/C046LV85N3C/p1671443897386729

The idea is to have a general message banner that can be controlled
through a feature flag in Unleash to display announcements, warnings,
informations, etc.

Currently using mock feature flags, but the idea is to bind this to a
feature flag we can manage in our Unleash instance, and use its payload
to provide information to end users whenever we want.

Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
2022-12-22 15:16:51 +00:00
Christopher Kolstad
5b66346e56
fixes 2-456: Preserve all data from strategy import (#2720)
## What
Previously when importing strategies we've used the same data type we've
used for creating strategies (the minimal, a name, an optional
description, optional parameters and an optional editable column). This
meant that exporting strategies and then importing them would reactivate
deprecated strategies. This PR changes to allow the import to preserve
all the data coming in the export file.

## Tests
Added four new tests, two new unit tests using our fake stores and two
new e2e tests. Interestingly the ones in the fake store ran green before
this change as well, probably because we just insert the parsed json
object in the fake store, whereas the real store actually converts the
object from camelCasing to the postgresql snake_casing standard.

## Discussion points:
### Mismatch between fake and real stores
This is inevitable since storing things in javascript arrays vs saving
in a real database will have some differences, but this again shows the
value of our e2e tests.

### Invariants
Should we see if we can add some invariants to our import/export so that
we can write some proptests for it? One candidate is commutativity of
import/export. On a fresh database importing and then exporting should
yield the same file that was imported provided all flags are turned on.
Candidate for Q1 improvement of import/export.
2022-12-21 13:33:41 +01:00
sjaanus
be045dc13a
Remove favorites feature flag (#2722) 2022-12-21 12:03:06 +00:00
sjaanus
a0619e963d
Maintenance mode for users (#2716) 2022-12-21 13:23:44 +02:00
Nuno Góis
7ce5b3de64
refactor: flag resolver should use stricter types (#2571)
Adding stricter types to `FlagResolver` can possibly help improve our DX
- Help us prevent errors like typos, guide us to correctly add a flag
when needed, and warn us of stray checks whenever we do a clean up at a
later stage.
2022-12-20 15:10:06 +00:00
Gastón Fournier
4b519ead4f
perf: Simplify queries to prometheus (#2706)
## About the changes
This PR improves our queries to Prometheus (instead of making multiple queries do only one) and improves the UI and the code. 

The reports aggregate all HTTP methods (GET, POST, PUT, DELETE, OPTIONS, HEAD and PATCH) without distinction under the same "endpoint" (a relative path inside unleash up to a certain depth)

Co-authored-by: Nuno Góis <nuno@getunleash.ai>
2022-12-19 17:06:59 +01:00
sjaanus
2d5455d203
Maintenance mode middleware (#2707) 2022-12-19 09:01:04 +02:00
Nuno Góis
a3ac96f763
Feat network overview (#2708)
https://linear.app/unleash/issue/2-512/exploration-network-overview-represented-as-a-flow-chart

<img width="1307" alt="image"
src="https://user-images.githubusercontent.com/14320932/208110067-294a0b91-d52e-49d1-9024-fa5e8530e2d8.png">
2022-12-16 14:12:36 +00:00
Gastón Fournier
2979f21631
feat: expose number of registered applications metric (#2692)
## About the changes
This metric will expose an aggregated view of how many client
applications are registered in Unleash. Since applications are ephemeral
we are exposing this metric in different time windows based on when the
application was last seen.

The caveat is that we issue a database query for each new range we want
to add. Hopefully, this should not be a problem because:
a) the amount of ranges we'd expose is small and unlikely to grow
b) this is currently updated at startup time and even if we update it on
a scheduled basis the refresh rate will be rather sparse

## Sample data
This is how metrics will look like
```
# HELP client_apps_total Number of registered client apps aggregated by range by last seen
# TYPE client_apps_total gauge
client_apps_total{range="allTime"} 3
client_apps_total{range="30d"} 3
client_apps_total{range="7d"} 2
```
2022-12-16 11:16:51 +00:00
Christopher Kolstad
eafba10cac
feature: add query support to features endpoint (#2693)
## About the changes
The deprecated /api/admin/features endpoint supported querying with tag
and namePrefix parameters.

This PR adds this functionality to
/api/admin/projects/<project>/features as well, allowing to replicate
queries that used to work.

Closes #2306

### Important files
src/lib/db/feature-strategy-store.ts
src/test/e2e/stores/feature-strategies-store.e2e.test.ts

## Discussion points
I'm extending our query parameters support for
/api/admin/projects/<projectId>/features endpoint. This will be
reflected in our open-api spec, so I also made an
adminFeaturesQuerySchema for this.

Also, very open for something similar to what we did for the modifyQuery
for the archived parameter, but couldn't come up with a good way to
support subselects using the query builder, it just ended up blowing the
stack. If anyone has a suggestion, I'm all ears.

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-12-16 12:05:18 +01:00