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

Centralize configuration using a Configs struct #53

Merged
merged 5 commits into from
Jun 7, 2021

Conversation

helgi
Copy link
Contributor

@helgi helgi commented May 6, 2021

Uses github.com/caarlos0/env/ to read ENV configuration, set type rules, and few other helpers. Moves from vars and const's to passing in values consistently via functions, making testing more predictable and the flow a tad bit easier to understand.

ROLLER_CHECK_DELAY is now deprecated in favor of ROLLER_INTERVAL to allow for stronger type management. This moves from an int to time.Duration, 30 vs 30s (or 30m, 30d, whatever time.ParseDuration can handle).
ROLLER_CHECK_DELAY still works and is auto applied as ROLLER_INTERVAL in seconds if set.

Brings in github.com/stretchr/testify as a direct dependency (previously indirect), helping with the new config testing.

Also, adds the ability to control if the roller drains and if it uses force …
ccd2f9f
Introduces ROLLER_DRAIN and ROLLER_DRAIN_FORCE, both defaulting to true to keep existing behavior for compatibility

Fixes #52

@helgi helgi force-pushed the feature/env-handling branch from aae90bf to aaf49ca Compare May 8, 2021 06:02
Copy link
Owner

@deitch deitch left a comment

Choose a reason for hiding this comment

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

This is really good, thank you! I had one question about a log message in the code, and some requested changes in the docs. Other than that, should be ready to go.

README.md Outdated
* `ROLLER_DRAIN_FORCE` [`bool` default: `true`]: If drain will force delete kubernetes resources if they violate PDB or grace periods.
* `ROLLER_IGNORE_DAEMONSETS` [`bool`, default: `true`]: If set to `false`, will not reclaim a node until there are no DaemonSets running on the node; if set to `true` (default), will reclaim node when all regular pods are drained off, but will ignore the presence of DaemonSets, which should be present on every node anyways. Normally, you want this set to `true`.
* `ROLLER_DELETE_LOCAL_DATA` [`bool`, default: `false`]: If set to `false` (default), will not reclaim a node until there are no pods with [emptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) running on the node; if set to `true`, will continue to terminate the pod and delete the local data before reclaiming the node. The default is `false` to maintain backward compatibility.
* `ROLLER_INTERVAL` [`time.Duration`, default: `30s`]: Time between roller runs. Takes time duration such as 10s, 10m, 10d
Copy link
Owner

Choose a reason for hiding this comment

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

Can you link here to what formats are acceptable, and add a few samples? You and I may be very comfortable with time.Duration; plenty of other users may not.

Copy link
Owner

Choose a reason for hiding this comment

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

That having been said, I like this INTERVAL better than the old DELAY

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, pushed a change

@helgi
Copy link
Contributor Author

helgi commented May 12, 2021

Thanks! Will update based on the feedback and/or reply to individual things.

@helgi
Copy link
Contributor Author

helgi commented May 28, 2021

I wanted to check in and see if there was anything else needed?

deitch
deitch previously approved these changes Jun 7, 2021
@deitch
Copy link
Owner

deitch commented Jun 7, 2021

Looks like CI failed. Not directly due to this, just because it was using go 1.12.1, when some of these packages use go 1.13+ features.

I will bump to go 1.15, then you can rebase.

@deitch
Copy link
Owner

deitch commented Jun 7, 2021

OK, bumped. Rebase this and push, and CI should go green.

helgi added 5 commits June 7, 2021 10:11
Uses github.com/caarlos0/env/ to read ENV configuration, set type rules and few other helpers. Moves from vars and const's to passing in values consistently via functions, making testing more predictable and the flow a tad bit easier to understand.

ROLLER_CHECK_DELAY is now deprecated in favor of ROLLER_INTERVAL to allow for stronger type management. This moves from an int to time.Duration, 30 vs 30s (or 30m, 30d, whatever time.ParseDuration can handle).
ROLLER_CHECK_DELAY still works and is auto applied as ROLLER_INTERVAL in seconds if set.

Brings in github.com/stretchr/testify as a direct depdency (previously indirect), helping with the new config testing.

Further enhancements can be done in future commits to bring log handling more centralized and moving more things to structs to make assigning value easier
Introduces ROLLER_DRAIN and ROLLER_DRAIN_FORCE, both defaulting to true to keep existing behaviour for compatibility

Fixes deitch#52
@helgi
Copy link
Contributor Author

helgi commented Jun 7, 2021

@deitch rebased :)

@deitch deitch merged commit f2fd590 into deitch:master Jun 7, 2021
@helgi helgi deleted the feature/env-handling branch June 8, 2021 00:28
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.

Option to not force drain a node from kubernetes
2 participants