Skip to content

Commit

Permalink
136635 add missed status for scheduled job (#42)
Browse files Browse the repository at this point in the history
* Extend job status with pod state and event message

* Extracted logic to server repo

* Added created field to status

* Added pod status condition check, when there is no container states

* Removed workflow, which is moved to server

* Renewed radix-operator version
  • Loading branch information
satr authored Nov 11, 2021
1 parent 4dfce8f commit 8afc086
Show file tree
Hide file tree
Showing 42 changed files with 368 additions and 3,825 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/deploy-docker.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ __debug_bin
# Dependency directories (remove the comment below to include it)
# vendor/

swaggerui/statik.go
swaggerui_src/swagger.json
../radix-job-scheduler-server/swaggerui/statik.go
../radix-job-scheduler-server/swaggerui_src/swagger.json

.idea
48 changes: 0 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,7 @@
ENVIRONMENT ?= dev
VERSION ?= latest
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
TAG := $(BRANCH)-$(VERSION)

# If you want to escape branch-environment constraint, pass in OVERRIDE_BRANCH=true
ifeq ($(ENVIRONMENT),prod)
DNS_ZONE = radix.equinor.com
else
DNS_ZONE = dev.radix.equinor.com
endif

CONTAINER_REPO ?= radix$(ENVIRONMENT)
DOCKER_REGISTRY ?= $(CONTAINER_REPO).azurecr.io

echo:
@echo "ENVIRONMENT : " $(ENVIRONMENT)
@echo "DNS_ZONE : " $(DNS_ZONE)
@echo "CONTAINER_REPO : " $(CONTAINER_REPO)
@echo "DOCKER_REGISTRY : " $(DOCKER_REGISTRY)
@echo "BRANCH : " $(BRANCH)
@echo "TAG : " $(TAG)

.PHONY: test
test:
go test -cover `go list ./...`

# This make command is only needed for local testing now
# we also do make swagger inside Dockerfile
.PHONY: swagger
swagger:
rm -f ./swaggerui_src/swagger.json ./swaggerui/statik.go
swagger generate spec -o ./swagger.json --scan-models
mv swagger.json ./swaggerui_src/swagger.json
statik -src=./swaggerui_src/ -p swaggerui

.PHONY: docker-build
docker-build:
docker build -t $(DOCKER_REGISTRY)/radix-job-scheduler:$(TAG) -f Dockerfile .

.PHONY: docker-push
docker-push:
az acr login --name $(CONTAINER_REPO)
make docker-build
docker push $(DOCKER_REGISTRY)/radix-job-scheduler:$(TAG)

.PHONY: docker-push-main
docker-push-main:
docker build -t $(DOCKER_REGISTRY)/radix-job-scheduler:main-latest -f Dockerfile .
az acr login --name $(CONTAINER_REPO)
docker push $(DOCKER_REGISTRY)/radix-job-scheduler:main-latest

.PHONY: generate-mock
generate-mock:
mockgen -source ./api/handlers/job/handler.go -destination ./api/handlers/job/test/handler_mock.go -package mock
33 changes: 2 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
The job scheduler for application jobs

## Usage
Request from application container URLs
* `POST` `http://<job-name>:8080/api/v1/jobs` - start new job
* `GET` `http://<job-name>:8080/api/v1/jobs` - get job list
* `GET` `http://<job-name>:8080/api/v1/jobs/<job-name>` - get job status
* `DELETE` `http://<job-name>:8080/api/v1/jobs/<job-name>` - stop and delete job
Use [Radix job scheduler server](https://github.com/equinor/radix-job-scheduler-server) or this component as a reference to work with scheduled jobs.

## Developing

You need Go installed. Make sure `GOPATH` and `GOROOT` are properly set up.

Also needed:

- [`go-swagger`](https://github.com/go-swagger/go-swagger) (on a Mac, you can install it with Homebrew: `brew install go-swagger`)
- [`statik`](https://github.com/rakyll/statik) (install with `go get github.com/rakyll/statik`)

Clone the repo into your `GOPATH` and run `go mod download`.

### Generating mocks
Expand All @@ -28,30 +19,10 @@ Run `make generate-mock` to regenerate mocks

#### Update version
We follow the [semantic version](https://semver.org/) as recommended by [go](https://blog.golang.org/publishing-go-modules).
`radix-api` has three places to set version
* `apiVersionRoute` in `router/server.go` and `BasePath`in `docs/docs.go` - API version, used in API's URL
* `Version` in `docs/docs.go` - indicates changes in radix-job-scheduler logic - to see (e.g in swagger), that the version in the environment corresponds with what you wanted

Run following command to update version in `swagger.json`
```
make swagger
```
* `tag` in git repository (in `main` branch) - matching to the version of `Version` in `docs/docs.go`
* `tag` in git repository (in `main` branch)

Run following command to set `tag` (with corresponding version)
```
git tag v1.0.0
git push origin v1.0.0
```
### Custom configuration
By default `Info` and `Error` messages are logged. This can be configured via environment variable `LOG_LEVEL` (pods need to be restarted after changes)
* `LOG_LEVEL=ERROR` - log only `Error` messages
* `LOG_LEVEL=INFO` or not set - log `Info` and `Error` messages
* `LOG_LEVEL=WARNING` or not set - log `Info`, `Warning` and `Error` messages
* `LOG_LEVEL=DEBUG` - log `Debug`, `Warning`, `Info` and `Error` messages
By default `swagger UI` is not available. This can be configured via environment variable `USE_SWAGGER`
* `USE_SWAGGER=true` - allows to use swagger UI with URL `<api-endpoint>/swaggerui`
28 changes: 0 additions & 28 deletions api/controllers/controller_base.go

This file was deleted.

Loading

0 comments on commit 8afc086

Please sign in to comment.