Skip to content

Commit

Permalink
Configure kubernetes job retries (on failure)
Browse files Browse the repository at this point in the history
- Modify Changelog format
  • Loading branch information
akshat committed Oct 10, 2018
1 parent 43929df commit 9e65076
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 116 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: trusty
sudo: required
language: go
go:
- "1.8"
- "1.10"

env:
global:
Expand All @@ -14,6 +14,7 @@ env:
- PROCTOR_REDIS_ADDRESS="localhost:6379"
- PROCTOR_REDIS_MAX_ACTIVE_CONNECTIONS="10"
- PROCTOR_KUBE_JOB_ACTIVE_DEADLINE_SECONDS="60"
- PROCTOR_KUBE_JOB_RETRIES="0"
- PROCTOR_LOGS_STREAM_READ_BUFFER_SIZE="140"
- PROCTOR_LOGS_STREAM_WRITE_BUFFER_SIZE="4096"
- PROCTOR_KUBE_CLUSTER_HOST_NAME="localhost:8001"
Expand Down
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## Changelog
# Changelog
All notable changes to this project will be documented in this file.

### v0.1.0
## [WIP: v0.2.0] - 2018-10-10
### Added
- Configurable kubernetes job retries (on failure)
### Modified
- Changelog format
- CI golang version. Reason: [kubernetes client-go issue](https://github.com/kubernetes/client-go/issues/449)

## v0.1.0 - 2018-10-08
### Added
- Add Authentication Headers: Email-Id and Access-Token
- Add Job success and failure metrics

[WIP: v0.2.0]: https://github.com/gojektech/proctor/compare/v0.1.0...v0.2.0
1 change: 1 addition & 0 deletions proctord/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export PROCTOR_DEFAULT_NAMESPACE="default"
export PROCTOR_REDIS_ADDRESS="localhost:6379"
export PROCTOR_REDIS_MAX_ACTIVE_CONNECTIONS="10"
export PROCTOR_KUBE_JOB_ACTIVE_DEADLINE_SECONDS="60"
export PROCTOR_KUBE_JOB_RETRIES="0"
export PROCTOR_LOGS_STREAM_READ_BUFFER_SIZE="140"
export PROCTOR_LOGS_STREAM_WRITE_BUFFER_SIZE="4096"
export PROCTOR_KUBE_CLUSTER_HOST_NAME="localhost:8001"
Expand Down
1 change: 1 addition & 0 deletions proctord/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* If unset, service will execute jobs in the same kubernetes cluster where it is run
* When set to "out-of-cluster", service will fetch kube config based on current-context from `.kube/config` file in home directory
* If a job doesn't reach completion, it is terminated after `PROCTOR_KUBE_JOB_ACTIVE_DEADLINE_SECONDS`
* `PROCTOR_KUBE_JOB_RETRIES` is the number of retries for a kubernetes job (on failure)
* `PROCTOR_DEFAULT_NAMESPACE` is the namespace under which jobs will be run in kubernetes cluster. By default, K8s has namespace "default". If you set another value, please create namespace in K8s before deploying `proctord`
* `PROCTOR_KUBE_CLUSTER_HOST_NAME` is address/ip address to api-server of kube cluster. It is used for fetching logs of a pod using https
* `PROCTOR_KUBE_CA_CERT_ENCODED` is the CA cert file encoded in base64. This is used for establishing authority while talking to kubernetes api-server on a public https call
Expand Down
5 changes: 5 additions & 0 deletions proctord/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func KubeJobActiveDeadlineSeconds() *int64 {
return &tmp
}

func KubeJobRetries() *int32 {
tmp := int32(viper.GetInt("KUBE_JOB_RETRIES"))
return &tmp
}

func PostgresUser() string {
return viper.GetString("POSTGRES_USER")
}
Expand Down
9 changes: 9 additions & 0 deletions proctord/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ func TestKubeJobActiveDeadlineSeconds(t *testing.T) {
assert.Equal(t, &expectedValue, KubeJobActiveDeadlineSeconds())
}

func TestKubeJobRetries(t *testing.T) {
os.Setenv("PROCTOR_KUBE_JOB_RETRIES", "0")

viper.AutomaticEnv()

expectedValue := int32(0)
assert.Equal(t, &expectedValue, KubeJobRetries())
}

func TestPostgresUser(t *testing.T) {
os.Setenv("PROCTOR_POSTGRES_USER", "postgres")

Expand Down
Loading

0 comments on commit 9e65076

Please sign in to comment.