Skip to content

Commit

Permalink
feat(controller): allow default reconcile behavior to be configurable (
Browse files Browse the repository at this point in the history
…#372)

* chore(dep): razee/[email protected]

pick up change to propagate options through the event emitter

* chore(dep): razee/[email protected]

Pick up enhancement to the base controller to allow for controlling the
reconcile behavior on resources managed by razee

* feat(controller): allow default reconcile behavior to be configurable

introduces additional environment variables to control the default
reconcile behavior of the remote resource controllers

The environment variable RR_RECONCILE_BY_DEFAULT will set the reconcile behavior.
The default is true if not set

Co-authored-by: Eric Satterwhite <[email protected]>
  • Loading branch information
alewitt2 and esatterwhite authored Nov 4, 2022
1 parent 1970c6b commit 513cf66
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
6 changes: 6 additions & 0 deletions kubernetes/RemoteResource/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ items:
value: razee-io/remoteresource
- name: USER_AGENT_VERSION
value: "{{{TRAVIS_TAG}}}"
- name: RR_RECONCILE_BY_DEFAULT
valueFrom:
configMapKeyRef:
name: razeedeploy-overrides
key: RR_RECONCILE_BY_DEFAULT
optional: true
- name: CRD_WATCH_TIMEOUT_SECONDS
valueFrom:
configMapKeyRef:
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
},
"license": "Apache-2.0",
"dependencies": {
"@razee/kubernetes-util": "^1.0.1",
"@razee/razeedeploy-core": "^1.2.2",
"@razee/kubernetes-util": "^1.1.0",
"@razee/razeedeploy-core": "^1.3.0",
"axios": "^0.27.2",
"bunyan": "^1.8.15",
"clone": "^2.1.2",
Expand Down
19 changes: 8 additions & 11 deletions src/BackendServiceFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@ const objectPath = require('object-path');
module.exports = class BackendServiceFactory {
constructor(params) {
this.eventParams = params;
const backendService = objectPath.get(this.eventParams, 'eventData.object.spec.backendService', '').toLowerCase();

let controllerString = 'RemoteResource';
if (backendService == 's3') controllerString = 'RemoteResourceS3';
if (backendService == 'git') controllerString = 'RemoteResourceGit';
this.controllerString = controllerString;
}

async execute() {
const backendService = objectPath.get(this.eventParams, 'eventData.object.spec.backendService', '').toLowerCase();
let controllerString;
if (backendService === 's3') {
controllerString = 'RemoteResourceS3';
} else if (backendService === 'git') {
controllerString = 'RemoteResourceGit';
} else { // generic
controllerString = 'RemoteResource';
}
this.eventParams.logger.info(`Running ${controllerString}Controller.`);
const Controller = require(`./${controllerString}Controller`);
this.eventParams.logger.info(`Running ${this.controllerString}Controller.`);
const Controller = require(`./${this.controllerString}Controller`);
const controller = new Controller(this.eventParams);
return await controller.execute();
}
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ async function createNewEventHandler(kc) {
kubeClass: kc,
logger: log,
requestOptions: { qs: { timeoutSeconds: process.env.CRD_WATCH_TIMEOUT_SECONDS || 300 } },
livenessInterval: true
livenessInterval: true,
options: {
reconcileByDefault: process.env.RR_RECONCILE_BY_DEFAULT || true
}
};
result = new EventHandler(params);
} else {
Expand Down

0 comments on commit 513cf66

Please sign in to comment.