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

Release 2.21.1 #2439

Merged
merged 16 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .github/workflows/workflow-deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ name: Workflow Deployments

on:
workflow_call:
inputs:
node_lts_current_version:
description: "Current Node LTS Version"
required: true
default: "18"
type: string
node_lts_active_version:
description: "Active Node LTS Version"
required: true
default: "16"
type: string
docker_platforms:
description: "Docker platforms"
required: true
default: "linux/amd64,linux/arm64"
type: string
workflow_dispatch:
inputs:
doc_deploy:
Expand All @@ -19,6 +35,21 @@ on:
required: true
default: true
type: boolean
node_lts_current_version:
description: "Current Node LTS Version"
required: true
default: "18"
type: string
node_lts_active_version:
description: "Active Node LTS Version"
required: true
default: "16"
type: string
docker_platforms:
description: "Docker platforms"
required: true
default: "linux/amd64,linux/arm64"
type: string

jobs:
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -56,7 +87,7 @@ jobs:
- uses: ./.github/actions/install-packages
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_LTS_CURRENT_VERSION }}
node-version: ${{ inputs.node_lts_current_version }}
- uses: actions/cache@v2
with:
path: "**/node_modules"
Expand Down Expand Up @@ -87,7 +118,7 @@ jobs:
context: .
file: ./docker/images/kuzzle/Dockerfile
push: true
platforms: ${{ env.DOCKER_PLATFORMS }}
platforms: ${{ inputs.docker_platforms }}
tags: kuzzleio/kuzzle:${{ steps.get-version.outputs.major-version }},kuzzleio/kuzzle:latest,kuzzleio/kuzzle:${{ steps.get-version.outputs.version }}

npm-deploy:
Expand All @@ -99,7 +130,7 @@ jobs:
- uses: ./.github/actions/install-packages
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_LTS_ACTIVE_VERSION }}
node-version: ${{ inputs.node_lts_active_version }}
registry-url: "https://registry.npmjs.org"
- run: npm install
- run: npm publish
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
echo "::set-output name=matrix::{\"node-version\": [\"$NODE_LTS_MAINTENANCE_VERSION\", \"$NODE_LTS_ACTIVE_VERSION\"]}"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
node_lts_active_version: ${{ env.NODE_LTS_ACTIVE_VERSION }}
node_lts_current_version: ${{ env.NODE_LTS_CURRENT_VERSION }}
docker_platforms: ${{ env.DOCKER_PLATFORMS }}

danger-js:
name: Danger JS
Expand Down Expand Up @@ -199,6 +202,10 @@ jobs:

deploy-workflow:
name: Deployment Workflow
needs: [cluster-monkey-tests]
needs: [cluster-monkey-tests, prepare-matrix]
uses: ./.github/workflows/workflow-deployments.yaml
secrets: inherit
with:
node_lts_active_version: ${{ needs.prepare-matrix.outputs.node_lts_active_version }}
node_lts_current_version: ${{ needs.prepare-matrix.outputs.node_lts_current_version }}
docker_platforms: ${{ needs.prepare-matrix.outputs.docker_platforms }}
41 changes: 41 additions & 0 deletions lib/api/controllers/debugController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { KuzzleRequest } from "../request";
import { NativeController } from "./baseController";
import * as kerror from "../../kerror";
import get from "lodash/get";

/**
* @class DebugController
Expand Down Expand Up @@ -49,13 +50,29 @@ export class DebugController extends NativeController {
* Connect the debugger
*/
async enable() {
if (!get(global.kuzzle.config, "security.debug.native_debug_protocol")) {
throw kerror.get(
"core",
"debugger",
"native_debug_protocol_usage_denied"
);
}

await global.kuzzle.ask("core:debugger:enable");
}

/**
* Disconnect the debugger and clears all the events listeners
*/
async disable() {
if (!get(global.kuzzle.config, "security.debug.native_debug_protocol")) {
throw kerror.get(
"core",
"debugger",
"native_debug_protocol_usage_denied"
);
}

await global.kuzzle.ask("core:debugger:disable");
}

Expand All @@ -64,6 +81,14 @@ export class DebugController extends NativeController {
* See: https://chromedevtools.github.io/devtools-protocol/v8/
*/
async post(request: KuzzleRequest) {
if (!get(global.kuzzle.config, "security.debug.native_debug_protocol")) {
throw kerror.get(
"core",
"debugger",
"native_debug_protocol_usage_denied"
);
}

const method = request.getBodyString("method");
const params = request.getBodyObject("params", {});

Expand All @@ -75,6 +100,14 @@ export class DebugController extends NativeController {
* See events from: https://chromedevtools.github.io/devtools-protocol/v8/
*/
async addListener(request: KuzzleRequest) {
if (!get(global.kuzzle.config, "security.debug.native_debug_protocol")) {
throw kerror.get(
"core",
"debugger",
"native_debug_protocol_usage_denied"
);
}

if (request.context.connection.protocol !== "websocket") {
throw kerror.get(
"api",
Expand All @@ -98,6 +131,14 @@ export class DebugController extends NativeController {
* Remove the websocket connection from the events' listeners
*/
async removeListener(request: KuzzleRequest) {
if (!get(global.kuzzle.config, "security.debug.native_debug_protocol")) {
throw kerror.get(
"core",
"debugger",
"native_debug_protocol_usage_denied"
);
}

if (request.context.connection.protocol !== "websocket") {
throw kerror.get(
"api",
Expand Down
18 changes: 16 additions & 2 deletions lib/api/funnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const debug = require("../util/debug")("kuzzle:funnel");
const processError = kerror.wrap("api", "process");
const { has } = require("../util/safeObject");
const { HttpStream } = require("../types");
const get = require("lodash/get");

// Actions of the auth controller that does not necessite to verify the token
// when cookie auth is active
Expand Down Expand Up @@ -179,6 +180,12 @@ class Funnel {
throw processError.get("not_enough_nodes");
}

const isRequestFromDebugSession = get(
request,
"context.connection.misc.internal.debugSession",
false
);

if (this.overloaded) {
const now = Date.now();

Expand Down Expand Up @@ -226,7 +233,8 @@ class Funnel {
*/
if (
this.pendingRequestsQueue.length >=
global.kuzzle.config.limits.requestsBufferSize
global.kuzzle.config.limits.requestsBufferSize &&
!isRequestFromDebugSession
) {
const error = processError.get("overloaded");
global.kuzzle.emit("log:error", error);
Expand All @@ -239,7 +247,13 @@ class Funnel {
request.internalId,
new PendingRequest(request, fn, context)
);
this.pendingRequestsQueue.push(request.internalId);

if (isRequestFromDebugSession) {
// Push at the front to prioritize debug requests
this.pendingRequestsQueue.unshift(request.internalId);
} else {
this.pendingRequestsQueue.push(request.internalId);
}

if (!this.overloaded) {
this.overloaded = true;
Expand Down
9 changes: 9 additions & 0 deletions lib/cluster/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ class ClusterNode {
*/
preventEviction(evictionPrevented) {
this.publisher.sendNodePreventEviction(evictionPrevented);
// This node is subscribed to the other node and might not receive their heartbeat while debugging
// so this node should not have the responsability of evicting others when his own eviction is prevented
// when debugging.
// Otherwise when recovering from a debug session, all the other nodes will be evicted.
for (const subscriber of this.remoteNodes.values()) {
subscriber.handleNodePreventEviction({
evictionPrevented,
});
}
}

/**
Expand Down
10 changes: 9 additions & 1 deletion lib/cluster/subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,15 @@ class ClusterSubscriber {
* to recover, otherwise we evict it from the cluster.
*/
async checkHeartbeat() {
if (this.state === stateEnum.EVICTED || this.remoteNodeEvictionPrevented) {
if (this.remoteNodeEvictionPrevented) {
// Fake the heartbeat while the node eviction prevention is enabled
// otherwise when the node eviction prevention is disabled
// the node will be evicted if it did not send a heartbeat before disabling the protection.
this.lastHeartbeat = Date.now();
return;
}

if (this.state === stateEnum.EVICTED) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/cluster/workers/IDCardRenewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class IDCardRenewer {
const redisConf = config.redis || {};
await this.initRedis(redisConf.config, redisConf.name);
} catch (error) {
// eslint-disable-next-line no-console
console.error(
`Failed to connect to redis, could not refresh ID card: ${error.message}`
);
this.parentPort.postMessage({
error: `Failed to connect to redis, could not refresh ID card: ${error.message}`,
});
Expand Down
Loading