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

Persist and partition job #3

Merged
merged 21 commits into from
Mar 13, 2024
Merged

Conversation

artursouza
Copy link
Contributor

@artursouza artursouza commented Mar 8, 2024

  • Multi-tenancy with namespace
  • Partitioning for jobs to be spread across hosts
  • Persist on Etcd
  • GitHub workflow with testing
  • Persist with Protobuf
  • Handle TTL

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
cron.go Outdated
// The type of trigger
TriggerType string
// The payload containg all the information for the trigger
TriggerPayload []byte
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 will convert this to Any again and use protobuf internally to save the state.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Were you going to do this change in this PR or a follow up? I guess it wont hurt to merge since we aren't referencing the commit in dist scheduler yet, but still feel we should update it first.

Func func(context.Context) error

Repeats int32
DueTime string
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 don't want to add this here until we add support for each one of these. Keeping the original Rhythm only for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We will want to keep this in mind then bc I believe this exists and is sent to the ScheduleJob so it'll error during our testing once your PR is merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding it here is not enough if the cron scheduler does not handle it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm already passing it along, so if I update the scheduler to use these changes it will break and I'll have to comment out those lines in the scheduler. I mean, its def not production code, but it's still partly there and being referenced and sent along. If you want I can comment them out. Just seems like extra orchestration

nonAlphaNumerical = regexp.MustCompile("[^a-z0-9_]")
)

func (j Job) canonicalName() string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should not be a limit in the library. It can be in Dapr.

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
@artursouza artursouza mentioned this pull request Mar 9, 2024
@artursouza
Copy link
Contributor Author

artursouza commented Mar 9, 2024 via email

@cicoyle
Copy link
Collaborator

cicoyle commented Mar 9, 2024

I personally don't know Nix, and for consistency sake would prefer Makefiles. However, if he wants to take that ownership and make it easy enough for us to consume and use that's fine.

@artursouza
Copy link
Contributor Author

I personally don't know Nix, and for consistency sake would prefer Makefiles. However, if he wants to take that ownership and make it easy enough for us to consume and use that's fine.

Let me do it with a simple Makefile and Josh can convert to Nix or help us convert it.

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
store.go Outdated
}
}
}
log.Printf("Exited sync for path: %s\n", prefix)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to be logging this? If we need to, please pass a logger into the library and make Debug level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed. Let me delete it. I want to handle logging as a separate PR.

@JoshVanL
Copy link
Collaborator

@artursouza btw, the tests hang for me on TestNoEntries.

@artursouza
Copy link
Contributor Author

@artursouza btw, the tests hang for me on TestNoEntries.

You need to run etcd first.

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
@cicoyle
Copy link
Collaborator

cicoyle commented Mar 12, 2024

@artursouza btw, the tests hang for me on TestNoEntries.

You need to run etcd first.

I remember running into this as well. Can you update the README or add a README to the test folder noting this:

## Tests

Pre-requisites to run the tests locally:
- [Install etcd](https://etcd.io/docs/v3.4/install/) 
- Launch etcd: `etcd --logger=zap`
- Proceed to run tests: `go test`

I have this pending in the PR here that I haven't circled back to yet.

@cicoyle
Copy link
Collaborator

cicoyle commented Mar 12, 2024

I updated my local wip branch to point to this and the scheduleJob hangs then gives context deadline exceeded:

CASSIE: before scheduling job
2024/03/12 08:46:12 CASSIE: after scheduling job: rpc error: code = DeadlineExceeded desc = context deadline exceeded

Maybe I need to change things before trying the code changes, but that should probably error nicer?

Did you run the tests and update in a branch the go mod and other changes needed in scheduler as a test for these changes?

Copy link
Collaborator

@JoshVanL JoshVanL left a comment

Choose a reason for hiding this comment

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

After running the test with ETCD I get a data race:

==================
WARNING: DATA RACE
Write at 0x00c0007ce658 by goroutine 206:
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).tryAcquire()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:111 +0x13c
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).Lock()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:72 +0x40
  github.com/diagridio/go-etcd-cron.(*Cron).run.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:431 +0x530
  github.com/diagridio/go-etcd-cron.(*Cron).run.func2()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:447 +0x60

Previous write at 0x00c0007ce658 by goroutine 205:
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).tryAcquire()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:111 +0x13c
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).Lock()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:72 +0x40
  github.com/diagridio/go-etcd-cron.(*Cron).run.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:431 +0x530
  github.com/diagridio/go-etcd-cron.(*Cron).run.func2()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:447 +0x60

Goroutine 206 (running) created at:
  github.com/diagridio/go-etcd-cron.(*Cron).run()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:405 +0xe80
  github.com/diagridio/go-etcd-cron.(*Cron).Start.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:342 +0x4c

Goroutine 205 (running) created at:
  github.com/diagridio/go-etcd-cron.(*Cron).run()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:405 +0xe80
  github.com/diagridio/go-etcd-cron.(*Cron).Start.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:342 +0x4c
==================
==================
WARNING: DATA RACE
Write at 0x00c0007ce668 by goroutine 206:
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).tryAcquire()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:123 +0x73c
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).Lock()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:72 +0x40
  github.com/diagridio/go-etcd-cron.(*Cron).run.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:431 +0x530
  github.com/diagridio/go-etcd-cron.(*Cron).run.func2()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:447 +0x60

Previous write at 0x00c0007ce668 by goroutine 205:
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).tryAcquire()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:123 +0x73c
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).Lock()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:72 +0x40
  github.com/diagridio/go-etcd-cron.(*Cron).run.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:431 +0x530
  github.com/diagridio/go-etcd-cron.(*Cron).run.func2()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:447 +0x60

Goroutine 206 (running) created at:
  github.com/diagridio/go-etcd-cron.(*Cron).run()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:405 +0xe80
  github.com/diagridio/go-etcd-cron.(*Cron).Start.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:342 +0x4c

Goroutine 205 (finished) created at:
  github.com/diagridio/go-etcd-cron.(*Cron).run()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:405 +0xe80
  github.com/diagridio/go-etcd-cron.(*Cron).Start.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:342 +0x4c
==================
==================
WARNING: DATA RACE
Write at 0x00c0007ce670 by goroutine 206:
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).Lock()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:79 +0x16c
  github.com/diagridio/go-etcd-cron.(*Cron).run.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:431 +0x530
  github.com/diagridio/go-etcd-cron.(*Cron).run.func2()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:447 +0x60

Previous write at 0x00c0007ce670 by goroutine 205:
  go.etcd.io/etcd/client/v3/concurrency.(*Mutex).Lock()
      /home/josh/go/pkg/mod/go.etcd.io/etcd/client/v3@v3.5.12/concurrency/mutex.go:79 +0x16c
  github.com/diagridio/go-etcd-cron.(*Cron).run.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:431 +0x530
  github.com/diagridio/go-etcd-cron.(*Cron).run.func2()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:447 +0x60

Goroutine 206 (running) created at:
  github.com/diagridio/go-etcd-cron.(*Cron).run()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:405 +0xe80
  github.com/diagridio/go-etcd-cron.(*Cron).Start.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:342 +0x4c

Goroutine 205 (finished) created at:
  github.com/diagridio/go-etcd-cron.(*Cron).run()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:405 +0xe80
  github.com/diagridio/go-etcd-cron.(*Cron).Start.func1()
      /home/josh/go/src/github.com/diagridio/go-etcd-cron/cron.go:342 +0x4c
==================
    testing.go:1465: race detected during execution of test
--- FAIL: TestDelayedAdd (12.00s)

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
@artursouza artursouza merged commit 04fed7e into diagridio:master Mar 13, 2024
1 check passed
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.

3 participants