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

Cron log #141

Merged
merged 5 commits into from
Jul 15, 2022
Merged

Cron log #141

merged 5 commits into from
Jul 15, 2022

Conversation

thegentlemanphysicist
Copy link
Contributor

Simple fix to check that a directory exists and prevents the job from erroring out when it's absent.
Add a network policy to allow the prod cron job to access the tools db

Add the service account forgold production viewer-cli
Connect up a network policy to allow prod cron job to run
Add a flag to prevent empty dir
@@ -18,3 +18,24 @@ spec:
name: {{ .Chart.Name }}
policyTypes:
- Ingress
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have one network policy already; do we need another one or can just update the existing one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need one for the cron job in the tools namespace to access patroni, and I believe we need one for the job in the prod namespace to access the tools patroni instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm.. not clear.. did something not work without this Network policy?

Copy link
Contributor Author

@thegentlemanphysicist thegentlemanphysicist Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the log job wasn't running for me until I added it. Once I did there were no more issues. Before I added the network police, the job would trigger, but the initdb step failed run. I made sure the credentials in prod and tools namespaces matched, but that didn't fix the issue. Only the network policy did.

- from:
- podSelector:
matchLabels:
app.kubernetes.io/name: kc-cron-job
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have this name dynamically so that it syncs up with other labels in cronjobx
such as {{ include "..name" . }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, I did use the name override value since I believe that determines the pod names

input: fs.createReadStream(`${dirname}/${filename}`),
});
promises.push(saveLogsForFile(lineReader, client));
if (fs.existsSync(dirname)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for readability, can we handle the edge case first and exit?
such as

if (!fs.existsSync(dirname)) {
console.info(`Directory ${dirname} does not exist.`);
return
}

so that it prevents the main logic is in a nested structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -31,3 +31,10 @@ service-acount-secret:
--from-literal=keycloak-url=${URL} \
--from-literal=client-id=script-cli \
--from-literal=client-secret=${CLIENTSECRET}

.PHONY: service-acount-secret-gold-prod
Copy link
Contributor

@junminahn junminahn Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like a duplicate function with the one above:
since Makefile is more for the deployment, can we have this function in a separate bash script that takes client-id as an argument? also, let's have a check to make sure the secret does not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, though I left the check out, using kubctl create will error out if it tries to create a secret that already exists.

implemented jm changes on the code
fixed the makefile in helm
Copy link
Contributor

@junminahn junminahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in overall, I see some places can be improved on.. but as it is working, let's address them in another time.

@thegentlemanphysicist thegentlemanphysicist merged commit 104061d into dev Jul 15, 2022
@thegentlemanphysicist thegentlemanphysicist deleted the cronLog branch July 15, 2022 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants