generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: wire up cron again #3452
Merged
+260
−19
Merged
fix: wire up cron again #3452
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,6 +236,15 @@ jobs: | |
- uses: cashapp/[email protected] | ||
- uses: ./.github/actions/build-cache | ||
- run: just build-docker provisioner | ||
docker-build-cron: | ||
name: Build Cron Docker Image | ||
# if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cashapp/[email protected] | ||
- uses: ./.github/actions/build-cache | ||
- run: just build-docker cron | ||
docker-build-runners: | ||
name: Build Runner Docker Images | ||
# if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,25 @@ jobs: | |
name: docker-provisioner-artifact | ||
path: artifacts/ftl-provisioner | ||
retention-days: 1 | ||
build-cron: | ||
name: Build Cron Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Init Hermit | ||
uses: cashapp/[email protected] | ||
- name: Build | ||
run: | | ||
just build-docker cron | ||
mkdir -p artifacts/ftl-provisioner | ||
docker save -o artifacts/ftl-cron/ftl-cron.tar ftl0/ftl-cron:latest | ||
- name: Temporarily save Docker image | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: docker-cron-artifact | ||
path: artifacts/ftl-cron | ||
retention-days: 1 | ||
build-box: | ||
name: Build FTL-in-a-box Docker Image | ||
runs-on: ubuntu-latest | ||
|
@@ -125,6 +144,11 @@ jobs: | |
with: | ||
name: docker-provisioner-artifact | ||
path: artifacts/ftl-provisioner | ||
- name: Retrieve Cron Docker image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docker-cron-artifact | ||
path: artifacts/ftl-cron | ||
- name: Retrieve FTL-in-a-box Docker image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
|
@@ -138,6 +162,8 @@ jobs: | |
run: docker load -i artifacts/ftl-controller/ftl-controller.tar | ||
- name: Load Provisioner Docker image | ||
run: docker load -i artifacts/ftl-provisioner/ftl-provisioner.tar | ||
- name: Load Cron Docker image | ||
run: docker load -i artifacts/ftl-cron/ftl-cron.tar | ||
- name: Load FTL-in-a-box Docker image | ||
run: docker load -i artifacts/ftl-box/ftl-box.tar | ||
- name: Log in to the Container registry | ||
|
@@ -160,6 +186,9 @@ jobs: | |
docker tag ftl0/ftl-provisioner:latest ftl0/ftl-provisioner:"$GITHUB_SHA" | ||
docker tag ftl0/ftl-provisioner:latest ftl0/ftl-provisioner:"$version" | ||
docker push -a ftl0/ftl-provisioner | ||
docker tag ftl0/ftl-cron:latest ftl0/ftl-cron:"$GITHUB_SHA" | ||
docker tag ftl0/ftl-cron:latest ftl0/ftl-cron:"$version" | ||
docker push -a ftl0/ftl-cron | ||
docker tag ftl0/ftl-box:latest ftl0/ftl-box:"$GITHUB_SHA" | ||
docker tag ftl0/ftl-box:latest ftl0/ftl-box:"$version" | ||
docker push -a ftl0/ftl-box | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM ubuntu:24.04 AS builder | ||
RUN apt-get update | ||
RUN apt-get install -y curl git zip | ||
|
||
# Copy Hermit bin stubs and install all packages. This is done | ||
# separately so that Docker will cache the tools correctly. | ||
COPY ./bin /src/bin | ||
ENV PATH="/src/bin:$PATH" | ||
WORKDIR /src | ||
|
||
# Seed some of the most common tools - this will be cached | ||
RUN go version | ||
RUN node --version | ||
|
||
# Download Go dependencies separately so Docker will cache them | ||
COPY go.mod go.sum ./ | ||
RUN go mod download -x | ||
|
||
# Download PNPM dependencies separately so Docker will cache them | ||
COPY frontend/console/package.json ./frontend/console/ | ||
COPY frontend/vscode/package.json ./frontend/vscode/ | ||
COPY pnpm-workspace.yaml pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Build | ||
COPY . /src/ | ||
RUN just errtrace | ||
# Reset timestamps so that the build state is reset | ||
RUN git ls-files -z | xargs -0 touch -r go.mod | ||
RUN just build ftl-cron | ||
|
||
# Finally create the runtime image. | ||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
|
||
WORKDIR /plugins/ | ||
|
||
WORKDIR /service/ | ||
COPY --from=builder /src/build/release/ftl-cron . | ||
|
||
EXPOSE 8893 | ||
|
||
CMD ["/service/ftl-cron"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ .Values.cron.serviceAccountName }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- if .Values.cron.cronsRoleArn }} | ||
annotations: | ||
eks.amazonaws.com/role-arn: {{ .Values.cron.cronsRoleArn }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{{ $version := printf "v%s" .Chart.Version -}} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "ftl.fullname" . }}-cron | ||
labels: | ||
{{- include "ftl.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.cron.replicas }} | ||
revisionHistoryLimit: {{ .Values.cron.revisionHistoryLimit }} | ||
selector: | ||
matchLabels: | ||
{{- include "ftl-cron.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "ftl-cron.selectorLabels" . | nindent 8 }} | ||
{{- if .Values.cron.podAnnotations }} | ||
annotations: | ||
{{- toYaml .Values.cron.podAnnotations | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
serviceAccountName: {{ .Values.cron.serviceAccountName }} | ||
containers: | ||
- name: app | ||
image: "{{ .Values.cron.image.repository }}:{{ .Values.cron.image.tag | default $version }}" | ||
imagePullPolicy: {{ .Values.cron.image.pullPolicy }} | ||
{{- if .Values.cron.envFrom }} | ||
envFrom: | ||
{{- if .Values.cron.envFrom }} | ||
{{- toYaml .Values.cron.envFrom | nindent 12 }} | ||
{{- end }} | ||
{{- end }} | ||
env: | ||
{{- if .Values.cron.env }} | ||
{{- toYaml .Values.cron.env | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.cron.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml .Values.cron.nodeSelector | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.cron.affinity }} | ||
affinity: | ||
{{- toYaml .Values.cron.affinity | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.cron.topologySpreadConstraints }} | ||
topologySpreadConstraints: | ||
{{- toYaml .Values.cron.topologySpreadConstraints | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.cron.tolerations }} | ||
tolerations: | ||
{{- toYaml .Values.cron.tolerations | nindent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/alecthomas/kong" | ||
|
||
"github.com/TBD54566975/ftl" | ||
"github.com/TBD54566975/ftl/backend/cron" | ||
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect" | ||
_ "github.com/TBD54566975/ftl/internal/automaxprocs" // Set GOMAXPROCS to match Linux container CPU quota. | ||
"github.com/TBD54566975/ftl/internal/log" | ||
"github.com/TBD54566975/ftl/internal/observability" | ||
"github.com/TBD54566975/ftl/internal/rpc" | ||
) | ||
|
||
var cli struct { | ||
Version kong.VersionFlag `help:"Show version."` | ||
ObservabilityConfig observability.Config `embed:"" prefix:"o11y-"` | ||
LogConfig log.Config `embed:"" prefix:"log-"` | ||
CronConfig cron.Config `embed:""` | ||
ConfigFlag string `name:"config" short:"C" help:"Path to FTL project cf file." env:"FTL_CONFIG" placeholder:"FILE"` | ||
} | ||
|
||
func main() { | ||
t, err := strconv.ParseInt(ftl.Timestamp, 10, 64) | ||
if err != nil { | ||
panic(fmt.Sprintf("invalid timestamp %q: %s", ftl.Timestamp, err)) | ||
} | ||
kctx := kong.Parse(&cli, | ||
kong.Description(`FTL - Cron`), | ||
kong.UsageOnError(), | ||
kong.Vars{"version": ftl.Version, "timestamp": time.Unix(t, 0).Format(time.RFC3339)}, | ||
) | ||
|
||
ctx := log.ContextWithLogger(context.Background(), log.Configure(os.Stderr, cli.LogConfig)) | ||
err = observability.Init(ctx, false, "", "ftl-cron", ftl.Version, cli.ObservabilityConfig) | ||
kctx.FatalIfErrorf(err, "failed to initialize observability") | ||
|
||
verbClient := rpc.Dial(ftlv1connect.NewVerbServiceClient, cli.CronConfig.ControllerEndpoint.String(), log.Error) | ||
schemaClient := rpc.Dial(ftlv1connect.NewSchemaServiceClient, cli.CronConfig.ControllerEndpoint.String(), log.Error) | ||
|
||
err = cron.Start(ctx, schemaClient, verbClient) | ||
kctx.FatalIfErrorf(err, "failed to start provisioner") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM ubuntu:24.04 | ||
|
||
WORKDIR /root/ | ||
|
||
COPY docker-build/ftl-cron . | ||
EXPOSE 8893 | ||
|
||
CMD ["/root/ftl-cron"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general we should prefix all embedded configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not the pattern we have been using for the 'main' config though. Cron, Runner, Provisioner, Controller etc all have one 'main' config that is not prefixed.