Skip to content

Commit

Permalink
make rrm watch optional w env var (#462)
Browse files Browse the repository at this point in the history
Co-authored-by: Katie Dai <kdai7@ibm.com>
  • Loading branch information
kdai7 and Katie Dai authored Jan 26, 2023
1 parent 7805bec commit a1be96b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
6 changes: 6 additions & 0 deletions kubernetes/MustacheTemplate/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ items:
name: razeedeploy-overrides
key: CRD_WATCH_TIMEOUT_SECONDS
optional: true
- name: WATCH_RESOURCE_REFERENCES
valueFrom:
configMapKeyRef:
name: razeedeploy-overrides
key: WATCH_RESOURCE_REFERENCES
optional: true
imagePullPolicy: Always
name: mustachetemplate-controller
livenessProbe:
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@razee/kubernetes-util": "^1.1.0",
"@razee/kubernetes-util": "^1.1.1",
"@razee/razeedeploy-core": "^1.3.3",
"handlebars": "^4.7.7",
"js-yaml": "^4.1.0",
Expand Down
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const ParentResourceKinds = ['MustacheTemplate'];
const ControllerString = 'MustacheTemplate';
const Controller = require(`./${ControllerString}Controller`);
const log = require('./logger').createLogger(ControllerString);
const log1 = require('./logger').createLogger('ReferencedResourceManager');
const WATCH_RESOURCE_REFERENCES = process.env.WATCH_RESOURCE_REFERENCES != undefined ? process.env.WATCH_RESOURCE_REFERENCES : 'true';

async function createNewEventHandler(kc) {
let result;
Expand Down Expand Up @@ -52,7 +54,7 @@ async function createParentRRMEventHandler(kc, parentResourceKind) {
kubeResourceMeta: resourceMeta,
factory: ReferencedResourceManager,
kubeClass: kc,
logger: log,
logger: log1,
requestOptions: { qs: { timeoutSeconds: process.env.CRD_WATCH_TIMEOUT_SECONDS || 300 } },
livenessInterval: true,
managedResourceType: 'parent'
Expand All @@ -68,8 +70,10 @@ async function main() {
log.info(`Running ${ControllerString}Controller.`);
const kc = new KubeClass();
await createNewEventHandler(kc);
for (const parentResourceKind of ParentResourceKinds) {
await createParentRRMEventHandler(kc, parentResourceKind);
if (WATCH_RESOURCE_REFERENCES === 'true') {
for (const parentResourceKind of ParentResourceKinds) {
await createParentRRMEventHandler(kc, parentResourceKind);
}
}
}

Expand Down

0 comments on commit a1be96b

Please sign in to comment.