1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
Commit Graph

394 Commits

Author SHA1 Message Date
Nuno Góis
27d48b3437
Feat segments project safeguards (#3359)
https://linear.app/unleash/issue/2-811/ability-to-move-project-specific-segments


![image](https://user-images.githubusercontent.com/14320932/226572047-19ed225c-13d5-4f2e-b10f-e17a7f7e6ae7.png)

Provides some safeguards to project-specific segments when managing them
on a global level (segments page):
- You can always promote a segment to global;
- You can't specify a project if the segment is currently in use in
multiple projects;
- You can't specify a different project if the segment is currently
already in use in a project;
2023-03-21 20:28:43 +00:00
Ivar Conradi Østhus
dc5b53fa4d
Poc: calculate etag based on query and latest revison id (#3062)
This is very much POC and WIP
2023-03-17 14:10:21 +01:00
andreas-unleash
32e1ad44ed
Feat/add cypress tests for project scoped stickiness (#3340)
<!-- 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-03-17 14:41:59 +02:00
Gastón Fournier
7a9ea22eed
feat: project-specific segments tests and fixes (#3339)
## About the changes
- Refactored some E2E tests to use our APIs
- Added test cases for project-specific segments
- Added validation to check a project can access a specific segment
- Fixed an OpenAPI schema that was missing segments

## Discussion points
https://github.com/Unleash/unleash/pull/3339/files#r1140008992
2023-03-17 12:43:34 +01:00
Fredrik Strand Oseberg
e2ad0cae45
fix: refactor calculate time to prod (#3333)
This PR changes how we calculate average time to production. Instead of
calculating fleeting 30 day windows and calculating the past and current
window, we now calculate a flat average across the entire project life.
This is less error prone as each feature will be tied to the earliest
time it was turned on in a production environment.
2023-03-16 15:45:24 +01:00
Mateusz Kwasniewski
1064dfa40c
feat: project mode (#3334) 2023-03-16 15:29:52 +01:00
andreas-unleash
edd12709ef
fix: remove proxy return all toggles functionality (#3331)
<!-- 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 removes the return all toggles functionality. Removes the flag
as well
## 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 #
[1-778](https://linear.app/unleash/issue/1-778/remove-proxyalltoggles-functionality)

<!-- (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-03-16 14:00:18 +02:00
Jaanus Sellin
138ac98094
feat: bulk revive features (#3321) 2023-03-16 09:51:18 +02:00
Gastón Fournier
1d0bc833b3
chore: refactor segments to stop depending on the implementation (#3315)
## About the changes
- Introducing ISegmentService interface to decouple from the actual
implementation
- Moving UpsertSegmentSchema to OSS to be able to use types
- Added comments where our code is coupled with segments just to
highlight and have a conversation about some use cases if needed, but
they can be removed before merging
- Removed segment service from some project features as it was not used
2023-03-15 14:58:19 +01:00
Mateusz Kwasniewski
d9e3ff9cd4
refactor: move project membership check from access to project (#3322) 2023-03-15 14:44:08 +01:00
Jaanus Sellin
a5f1b89b4a
feat: bulk delete features (#3314) 2023-03-15 15:08:08 +02:00
Jaanus Sellin
6c813ab066
feat: bulk stale features (#3311) 2023-03-15 08:37:06 +02:00
Mateusz Kwasniewski
7753082660
feat: expose project members (#3310) 2023-03-14 16:27:57 +01:00
Mateusz Kwasniewski
3837cceafe
fix: type checker happy (#3306) 2023-03-14 10:32:00 +01:00
Jaanus Sellin
1746a951c2
feat: bulk archive features (#3286)
Bulk archiving features logic.
2023-03-14 10:48:29 +02:00
Simon Hornby
5088409c4d
fix: polling in proxy repository now stops correctly (#3268)
### What

This patches two very subtle bugs in the proxy repository that cause it
to never actually stop polling the db in the background

## Details - Issue 1

We've recently started to get the following output when running `yarn
test`:

` Attempted to log "Error: Unable to acquire a connection
at Object.queryBuilder
(/home/simon/dev/unleash/node_modules/knex/lib/knex-builder/make-knex.js:111:26)`
        
This seems to occur for every test suite after running the proxy tests
and the full stack trace doesn't point to anything related to the
running tests that produce this output. Running a `git bisect` points to
this commit:
6e44a65c58
being the culprit but I believe that this may have surfaced the bug
rather than causing it.

Layering in a few console logs and running Unleash, seems to point to
the proxy repository setting up data polling but never actually
terminating it when `stop` was called, which is inline with the output
here - effectively the tests were continuing to run the polling in the
background after the suite had exited and jest freaks out that an async
task is running when it shouldn't be. This is easy to reproduce once the
console logs are in place in the `dataPolling` function, by running
Unleash - creating and deleting a front end token never terminates the
poll cycle.

I believe the cause here is some subtlety around using async functions
with timers - stop was being called, which results in the timer being
cleared but a scheduled async call was already on the stack, causing the
recursive call to resolve after stop, resurrecting the timer and
reinitializing the poll cycle.

I've moved the terminating code into the async callback. Which seems to
solve the problem here.

## Details - Issue 2

Related to the first issue, when the proxy service stops the underlying
Unleash Client, it never actually calls destroy on the client, it only
removes it from its internal map. That in turn means that the Client
never calls stop on the injected repository, it only removes it from
memory. However, the scheduled task is `async` and `unref`, meaning it
continues to spin in the background until every other process also
exits. This is patched by simply calling destroy on the client when
cleaning up

## The Ugly

This is really hard to test effectively, mostly because this is an issue
caused by internals within NodeJS and async. I've added a test that
reads the output from the debug log (and also placed a debug log in the
termination code). This also requires the test code to wait until the
async task completes. This is horribly fragile so if someone has a
better idea on how to prove this I would be a very happy human.

The second ugly part is that this is a subtle issue in complex code that
really, really needs to work correctly. I'm nervous about making changes
here without lots of eyes on this
2023-03-10 10:03:32 +02:00
Mateusz Kwasniewski
898d4f0b70
feat: clean api behind a flag (#3288) 2023-03-09 16:20:12 +01:00
Mateusz Kwasniewski
b05b075ac8
feat: filter out all data fields other than explicit openapi fields (#3284)
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
2023-03-09 14:45:03 +01:00
Jaanus Sellin
a52dd10cf8
feat: bulk update tags (#3274) 2023-03-09 11:58:06 +02:00
Jaanus Sellin
0819d64448
feat: bulk tag features (#3258) 2023-03-08 10:07:06 +02:00
Gastón Fournier
37ce81a727
chore: re-use the same client schema for proxy (#3251)
## About the changes
client-metrics-schema is less strict than proxy-metrics-schema because
the former allows empty `instanceId` and also supports dates as
timestamps as well as date-formatted strings.

Using the same schema makes sense to reduce maintainability costs and
it's less error-prone if we need to modify the schema because underlying
the schema they both use the same code.

The reasoning is that proxy metrics should align with our client
metrics. Alternatively, we have new endpoints for edge metrics that will
aggregate and bucket by client.


![image](https://user-images.githubusercontent.com/455064/222738911-4c443e02-3072-4042-bfde-327da8dd46fe.png)


## Discussion points
Will we ever want to evolve proxy-metrics differently than
client-metrics? I'm under the assumption that the answer is no
2023-03-03 16:36:23 +01:00
Mateusz Kwasniewski
e15aa9795a
feat: shared event emitter (#3241) 2023-03-02 09:52:19 +01:00
Mateusz Kwasniewski
ad588fd0d2
fix: pass shared event store (#3233) 2023-03-01 14:09:52 +01:00
Christopher Kolstad
f4bdd89a1c
fix: Change format for bulk metrics. (#3229)
### What
Change /edge/metrics endpoint to accept list of ClientMetricsEnv

### Rationale
We originally made the assumption that we probably didn't need to keep
splitting from a map of features into ClientMetricsEnv for bulk, instead
the bulk poster could post ClientMetricsEnv directly. However, Unleash
still expected the old client metrics format with a dictionary of
featurename -> metricsForFeature. This PR changes that to now accept the
list of ClientMetricsEnv (preprocessed data from downstream) instead of
expecting metrics to be in the old single application metric format.
2023-03-01 13:08:08 +01:00
Mateusz Kwasniewski
ee20737e4a
refactor: make permission check type less demanding (#3214) 2023-02-28 14:48:27 +01:00
Mateusz Kwasniewski
341e8ead12
feat: extend refs in openapi (#3170) 2023-02-22 13:10:29 +01:00
Gastón Fournier
dc0fe3929e
chore: make event store accept IUser (#3076)
## About the changes
Currently, we need to remember of using the email or else the username
of a user when storing into EventStore, because we don't have
[strictNullChecks](https://www.typescriptlang.org/tsconfig#strictNullChecks),
it's error-prone. Fix for a production issue: #3072

This reuses an existing function that also deals with undefined
2023-02-21 14:11:39 +00:00
Mateusz Kwasniewski
3800877be1
feat: drop full- for import/validate (#3168) 2023-02-21 10:15:57 +01:00
Mateusz Kwasniewski
7996f12974
docs: seam explanation (#3147) 2023-02-20 07:51:44 +01:00
Mateusz Kwasniewski
f0c9f8b08b
feat: oss import (#3123) 2023-02-16 08:08:51 +01:00
Gastón Fournier
f8d30850e5
Network view not experimental (#3124)
## About the changes
Promoted experimental networkView flag into a configuration that relies
on prometheusApi being configured.

Also, a follow-up on https://github.com/Unleash/unleash/pull/3054 moving
this code to enterprise because it doesn't make sense to maintain this
code in OSS where it's not being used.
2023-02-15 16:24:57 +01:00
Jaanus Sellin
5574d27861
feat: Instance stats for export/import (#3121)
feat: instance stats for export/import
2023-02-15 14:39:16 +02:00
Mateusz Kwasniewski
e06ecab642
feat: extract custom context fields from all possible locations (#3118) 2023-02-15 10:26:19 +01:00
Gastón Fournier
7a242ecf2a
chore: add bulk endpoint for metrics and app registration for edge (#3079)
## About the changes
Implementation of bulk metrics and registration endpoint. This will be
used by edge nodes to send all collected information.

Types around metrics were improved and `IClientApp.bucket` with type
`any` is no longer needed

---------

Co-authored-by: sighphyre <liquidwicked64@gmail.com>
2023-02-15 09:13:32 +01:00
Jaanus Sellin
8e38ebf1a7
fix: also export context fields used for stickiness (#3106) 2023-02-15 08:44:59 +01:00
Mateusz Kwasniewski
b1728c5fe2
feat: Export segments limited info (#3109) 2023-02-14 15:35:10 +01:00
Nuno Góis
8729f082d2
refactor: remove variants per environment feature flag (#3102)
https://linear.app/unleash/issue/2-428/clean-up-feature-flag-once-were-done-with-the-migration

Cleans up the variants per environment feature flag due to GA.
2023-02-14 14:02:02 +00:00
Fredrik Strand Oseberg
9cc7b8fdeb
fix: replace assert with error (#3074)
This PR changes the behavior of checking the incoming token on the
`/api/frontend` path. Instead of using assert resulting in a 500 error
we are throwing an error that is caught by the default controller and
emitted back to the user as JSON.

This should be the correct behaviour, since the endpoint can not give
you any meaningful data without the environment that the API token
holds.
2023-02-13 08:40:04 +01:00
renovate[bot]
6e44a65c58
fix(deps): update dependency unleash-client to v3.18.0 (#2956)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [unleash-client](https://togithub.com/Unleash/unleash-client-node) |
[`3.16.1` ->
`3.18.0`](https://renovatebot.com/diffs/npm/unleash-client/3.16.1/3.18.0)
|
[![age](https://badges.renovateapi.com/packages/npm/unleash-client/3.18.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/unleash-client/3.18.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/unleash-client/3.18.0/compatibility-slim/3.16.1)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/unleash-client/3.18.0/confidence-slim/3.16.1)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>Unleash/unleash-client-node</summary>

###
[`v3.18.0`](https://togithub.com/Unleash/unleash-client-node/blob/HEAD/CHANGELOG.md#&#8203;3180)

[Compare
Source](https://togithub.com/Unleash/unleash-client-node/compare/v3.17.0...v3.18.0)

feat: gracefully handle unsuccessful metrics post
([#&#8203;414](https://togithub.com/Unleash/unleash-client-node/issues/414))
feat/flush metrics
([#&#8203;415](https://togithub.com/Unleash/unleash-client-node/issues/415))
feat: add metrics jitter support
([#&#8203;412](https://togithub.com/Unleash/unleash-client-node/issues/412))
fix: Allow SDK to startup when backup data is corrupt
([#&#8203;418](https://togithub.com/Unleash/unleash-client-node/issues/418))
fix: flexible-rollout random stickiness is not random enough
([#&#8203;417](https://togithub.com/Unleash/unleash-client-node/issues/417))
fix: build correct version on npm version
chore(deps): update dependency eslint-plugin-import to v2.27.5
([#&#8203;416](https://togithub.com/Unleash/unleash-client-node/issues/416))
chore(deps): update dependency
[@&#8203;typescript-eslint/eslint-plugin](https://togithub.com/typescript-eslint/eslint-plugin)
to v5.48.2
([#&#8203;413](https://togithub.com/Unleash/unleash-client-node/issues/413))
chore(deps): update dependency eslint to v8.32.0
([#&#8203;410](https://togithub.com/Unleash/unleash-client-node/issues/410))
chore(deps): update dependency prettier to v2.8.3
([#&#8203;406](https://togithub.com/Unleash/unleash-client-node/issues/406))
chore(deps): update dependency eslint-plugin-import to v2.27.4
([#&#8203;404](https://togithub.com/Unleash/unleash-client-node/issues/404))

###
[`v3.17.0`](https://togithub.com/Unleash/unleash-client-node/blob/HEAD/CHANGELOG.md#&#8203;3170)

[Compare
Source](https://togithub.com/Unleash/unleash-client-node/compare/v3.16.1...v3.17.0)

- feat: Only initialize the SDK once.
([#&#8203;368](https://togithub.com/Unleash/unleash-client-node/issues/368))
-   fix: upgrade semver to 7.3.8
-   fix: add resolution for debug
-   fix: add resolution for minimatch
-   fix: add resolution for qs
-   fix: add resolution for json5
-   fix: update yarn.lock
- docs: Update the readme with info from docs.getunleash
([#&#8203;399](https://togithub.com/Unleash/unleash-client-node/issues/399))
-   docs: minor fix in README
- chore(deps): update dependency debug to v4
([#&#8203;402](https://togithub.com/Unleash/unleash-client-node/issues/402))
- chore(deps): update dependency json5 to v2
([#&#8203;401](https://togithub.com/Unleash/unleash-client-node/issues/401))
- chore(deps): update dependency eslint to v8.31.0
([#&#8203;394](https://togithub.com/Unleash/unleash-client-node/issues/394))
- chore(deps): update dependency nock to v13.3.0
([#&#8203;400](https://togithub.com/Unleash/unleash-client-node/issues/400))
- chore(deps): update dependency
[@&#8203;typescript-eslint/eslint-plugin](https://togithub.com/typescript-eslint/eslint-plugin)
to v5.48.1
([#&#8203;395](https://togithub.com/Unleash/unleash-client-node/issues/395))
- chore(deps): update dependency eslint-config-prettier to v8.6.0
([#&#8203;396](https://togithub.com/Unleash/unleash-client-node/issues/396))
- chore(deps): update dependency prettier to v2.8.2
([#&#8203;398](https://togithub.com/Unleash/unleash-client-node/issues/398))
- chore(deps): update dependency
[@&#8203;typescript-eslint/eslint-plugin](https://togithub.com/typescript-eslint/eslint-plugin)
to v5.47.1
([#&#8203;346](https://togithub.com/Unleash/unleash-client-node/issues/346))
- chore(deps): update dependency typescript to v4.9.4
([#&#8203;386](https://togithub.com/Unleash/unleash-client-node/issues/386))
- chore(deps): update dependency sinon to v15
([#&#8203;391](https://togithub.com/Unleash/unleash-client-node/issues/391))
- chore(deps): update dependency
[@&#8203;types/node](https://togithub.com/types/node) to v18
([#&#8203;380](https://togithub.com/Unleash/unleash-client-node/issues/380))
- chore(deps): update dependency
[@&#8203;types/node](https://togithub.com/types/node) to v14.18.36
([#&#8203;382](https://togithub.com/Unleash/unleash-client-node/issues/382))
- chore(deps): update dependency eslint to v8.30.0
([#&#8203;367](https://togithub.com/Unleash/unleash-client-node/issues/367))
- chore(deps): update dependency prettier to v2.8.1
([#&#8203;387](https://togithub.com/Unleash/unleash-client-node/issues/387))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/Unleash/unleash).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDUuNCIsInVwZGF0ZWRJblZlciI6IjM0LjExNy4xIn0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ivar Conradi Østhus <ivar@getunleash.ai>
2023-02-10 10:51:53 +01:00
Jaanus Sellin
8ee9b75e48
Add option to run unleash in strict schema validation (#3073)
feat: strict schema validation
2023-02-09 15:21:03 +02:00
Gastón Fournier
b76e66fc1d
fix: make sure we have a user in event store (#3072)
## About the changes
Spotted some issues in logs:
```json
{
  "level":"warn",
  "message":"Failed to store \"feature-environment-variants-updated\" event: error: insert into \"events\" (\"created_by\", \"data\", \"environment\", \"feature_name\", \"pre_data\", \"project\", \"tags\", \"type\") values (DEFAULT, $1, $2, $3, $4, $5, $6, $7) returning \"id\", \"type\", \"created_by\", \"created_at\", \"data\", \"pre_data\", \"tags\", \"feature_name\", \"project\", \"environment\" - null value in column \"created_by\" violates not-null constraint",
  "name":"lib/db/event-store.ts"
}
```

In all other events we're doing the following:
b7fdcd36c0/src/lib/services/segment-service.ts (L80)

So this is just mimicking that to quickly release a patch, but I'll look
into a safer (type-checked) solution so this problem does not happen
again
2023-02-09 11:01:39 +01:00
Ivar Conradi Østhus
07e8a351bb
Fix/show tag events (#3064)
This PR fixes two issues with events today:

1. Feature toggles "Event log" must include all events, regardless of
the project. This is important as feature toggles may move between
2. Add/remove tags on a feature toggle events should include project id
in order to show up in the project specific event log.
2023-02-08 19:57:21 +01:00
Thu Vo
3387e6fc39
JSON stringify errors to view more info of params (#3033) 2023-02-07 09:21:09 +01:00
Tymoteusz Czech
0656fddbc4
Refactor: Project Overview fetching (#3035) 2023-02-07 08:57:28 +01:00
Tymoteusz Czech
ab9712812a
Project health tests (#3028) 2023-02-02 12:01:16 +01:00
Ivar Conradi Østhus
627958d30f
feat/enable_batch_metrics_for_all (#3027)
Batch Metrics as a capability developed to support the frontend API to
handle more metrics from SDKs without overloading the DB to much. It has
been running in Unleash Cloud for months and has proven to work quite
nice.

This PR simply removes the flag to make the capability GA, also for
self-hosted users.
2023-02-01 20:50:17 +01:00
sjaanus
daa4041d03
Export tag types (#3026)
Adds a simple functionality to export also tag types.
2023-02-01 13:14:49 +02:00
Mateusz Kwasniewski
dc8c95702f
Schedule health report (#3025) 2023-01-31 13:35:16 +01:00
Tymoteusz Czech
59e8e2b1ed
refactor: project health domain (#3024) 2023-01-31 13:08:20 +01:00
sjaanus
ab5da2116a
Remove timeout from store (#3018) 2023-01-30 12:01:44 +01:00