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

event sink crud operation api #9155

Merged
merged 2 commits into from
Oct 23, 2020
Merged

event sink crud operation api #9155

merged 2 commits into from
Oct 23, 2020

Conversation

drewbailey
Copy link
Contributor

@drewbailey drewbailey commented Oct 22, 2020

CRUD operations and plumbing 🛠️ for managing event stream sinks

nomad/fsm.go Show resolved Hide resolved
nomad/structs/event.go Outdated Show resolved Hide resolved
@@ -0,0 +1,155 @@
package structs
Copy link
Member

Choose a reason for hiding this comment

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

Good call on moving these out to their own file 👍

@@ -97,6 +97,8 @@ const (
ScalingEventRegisterRequestType
CSIVolumeClaimBatchRequestType
CSIPluginDeleteRequestType
EventSinkUpsertRequestType
EventSinkDeleteRequestType
Copy link
Member

@schmichael schmichael Oct 23, 2020

Choose a reason for hiding this comment

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

Oof I caused a merge conflict with this and raftutil msgtypes in #9135

Sorry!

state store methods and restore

upsert sink test

get sink

delete sink

event sink list and tests

go generate new msg types

validate sink on upsert
@@ -17,6 +17,103 @@ import (
"golang.org/x/sync/errgroup"
)

func (s *HTTPServer) EventSinksRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method != http.MethodGet {
return nil, CodedError(405, ErrInvalidMethod)
Copy link
Member

Choose a reason for hiding this comment

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

nit: there's https://golang.org/pkg/net/http/#pkg-constants we can use instead of raw numbers, e.g. http.StatusMethodNotAllowed

return nil, CodedError(405, ErrInvalidMethod)
}

args := structs.EventSinkListRequest{}
Copy link
Member

Choose a reason for hiding this comment

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

hyper nit: using := here, but var below for instantiating default value structs

@@ -22,6 +23,95 @@ type testEvent struct {
ID string
}

func TestHTTP_EventSinkList(t *testing.T) {
t.Parallel()
Copy link
Member

Choose a reason for hiding this comment

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

this test is parallel but the others are not, can they all be?


// Ensure we never set the index to zero, otherwise a blocking query cannot be used.
// We floor the index at one, since realistically the first write must have a higher index.
if index == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

could be even more sure with index <= 0


func (j *EventJson) Copy() *EventJson {
n := new(EventJson)
*n = *j
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to do anything, the only field is Data and we need to overwrite it with a deep copy anyway

mErr.Errors = append(mErr.Errors, fmt.Errorf("Sink ID contains a space"))
} else if strings.Contains(e.ID, "\000") {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Sink ID contains a null character"))
}
Copy link
Member

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 this lenient? Seems like \t would slip though this for example. Could we not use a relatively plain regex like we do for namespace?

Copy link
Contributor Author

@drewbailey drewbailey Oct 23, 2020

Choose a reason for hiding this comment

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

¯_(ツ)_/¯ I was following Job, namespace seems too constrictive 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

\t doesn't seem great either though, I don't see why we'd want to not allow dash or underscore, not sure if there's precedent for anything less rigorous than namespaces

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants