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

fix: add parent namespace and cluster information #3608

Closed
wants to merge 11 commits into from
Closed
4 changes: 4 additions & 0 deletions src/util/customTransformer-faas.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
executeFaasFunction,
FAAS_AST_FN_NAME,
FAAS_AST_VID,
PARENT_NAMESPACE,
PARENT_CLUSTER,
} = require('./openfaas');
const { getLibraryCodeV1 } = require('./customTransforrmationsStore-v1');

Expand All @@ -26,6 +28,8 @@ function generateFunctionName(userTransformation, libraryVersionIds, testMode, h
(libraryVersionIds || []).sort(),
);

ids = ids.concat([PARENT_NAMESPACE, PARENT_CLUSTER]);

if (hashSecret !== '') {
ids = ids.concat([hashSecret]);
}
Expand Down
7 changes: 7 additions & 0 deletions src/util/openfaas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const FAAS_READINESS_HTTP_FAILURE_THRESHOLD =
const FAAS_READINESS_HTTP_SUCCESS_THRESHOLD =
process.env.FAAS_READINESS_HTTP_SUCCESS_THRESHOLD || '1';

const PARENT_NAMESPACE = process.env.NAMESPACE || 'default';
const PARENT_CLUSTER = process.env.FAAS_FN_PARENT_CLUSTER || 'default';

const CONFIG_BACKEND_URL = process.env.CONFIG_BACKEND_URL || 'https://api.rudderlabs.com';
const GEOLOCATION_URL = process.env.GEOLOCATION_URL || '';
const FAAS_AST_VID = 'ast';
Expand Down Expand Up @@ -313,6 +316,8 @@ function buildOpenfaasFn(name, code, versionId, libraryVersionIDs, testMode, trM
const labels = {
'openfaas-fn': 'true',
'parent-component': 'openfaas',
'parent-namespace': PARENT_NAMESPACE,
'parent-cluster': PARENT_CLUSTER,
'com.openfaas.scale.max': FAAS_MAX_PODS_IN_TEXT,
'com.openfaas.scale.min': FAAS_MIN_PODS_IN_TEXT,
'com.openfaas.scale.zero': FAAS_SCALE_ZERO,
Expand Down Expand Up @@ -431,6 +436,8 @@ module.exports = {
buildOpenfaasFn,
FAAS_AST_VID,
FAAS_AST_FN_NAME,
PARENT_NAMESPACE,
PARENT_CLUSTER,
setFunctionInCache,
reconcileFunction,
};
3 changes: 2 additions & 1 deletion test/__tests__/user_transformation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const pyLibCode = (name, versionId) => {

const pyfaasFuncName = (workspaceId, versionId, libraryVersionIds=[], hashSecret="") => {
let ids = [workspaceId, versionId].concat(libraryVersionIds.sort());
ids = ids.concat(["default", "default"]);
if (hashSecret !== "") {
ids = ids.concat([hashSecret]);
}
Expand Down Expand Up @@ -119,7 +120,7 @@ describe("User transformation utils", () => {
[],
false,
'hash-secret');
expect(fnName).toEqual('fn-workspaceid-34a32ade07ebbc7bc5ea795b8200de9f');
expect(fnName).toEqual('fn-workspaceid-91d66b4cea6f0ed16cd41258d138d0a8');
});

});
Expand Down
Loading