API: Event stream use full name instead of Eval/Alloc (#9509)
* use full name for events use evaluation and allocation instead of short name * update api event stream package and shortnames * update docs * make sync; fix typo * backwards compat not from 1.0.0-beta event stream api changes * use api types instead of string * rm backwards compat note that only changed between prereleases * remove backwards incompat that only existed in prereleases
This commit is contained in:
parent
b167db10c3
commit
17de8ebcb1
|
@ -41,7 +41,6 @@ IMPROVEMENTS:
|
|||
* jobspec: Added support for `headers` option in `artifact` stanza [[GH-9306](https://github.com/hashicorp/nomad/issues/9306)]
|
||||
|
||||
__BACKWARDS INCOMPATIBILITIES:__
|
||||
* core: `nomad event sink` beta cli commands and API endpoints have been removed. [[GH-9470](https://github.com/hashicorp/nomad/issues/9470)]
|
||||
* core: null characters are prohibited in region, datacenter, job name/ID, task group name, and task name [[GH-9020](https://github.com/hashicorp/nomad/issues/9020)]
|
||||
* csi: registering a CSI volume with a `block-device` attachment mode and `mount_options` now returns a validation error, instead of silently dropping the `mount_options`. [[GH-9044](https://github.com/hashicorp/nomad/issues/9044)]
|
||||
* driver/docker: Tasks are now issued SIGTERM instead of SIGINT when stopping [[GH-8932](https://github.com/hashicorp/nomad/issues/8932)]
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
const (
|
||||
TopicDeployment Topic = "Deployment"
|
||||
TopicEval Topic = "Eval"
|
||||
TopicAlloc Topic = "Alloc"
|
||||
TopicEvaluation Topic = "Evaluation"
|
||||
TopicAllocation Topic = "Allocation"
|
||||
TopicJob Topic = "Job"
|
||||
TopicNode Topic = "Node"
|
||||
TopicAll Topic = "*"
|
||||
|
@ -92,9 +92,9 @@ func (e *Event) Node() (*Node, error) {
|
|||
}
|
||||
|
||||
type eventPayload struct {
|
||||
Allocation *Allocation `mapstructure:"Alloc"`
|
||||
Allocation *Allocation `mapstructure:"Allocation"`
|
||||
Deployment *Deployment `mapstructure:"Deployment"`
|
||||
Evaluation *Evaluation `mapstructure:"Eval"`
|
||||
Evaluation *Evaluation `mapstructure:"Evaluation"`
|
||||
Job *Job `mapstructure:"Job"`
|
||||
Node *Node `mapstructure:"Node"`
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestEvent_Stream(t *testing.T) {
|
|||
events := c.EventStream()
|
||||
q := &QueryOptions{}
|
||||
topics := map[Topic][]string{
|
||||
"Eval": {"*"},
|
||||
TopicEvaluation: {"*"},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -42,7 +42,7 @@ func TestEvent_Stream(t *testing.T) {
|
|||
require.Fail(t, err.Error())
|
||||
}
|
||||
require.Equal(t, len(event.Events), 1)
|
||||
require.Equal(t, "Eval", string(event.Events[0].Topic))
|
||||
require.Equal(t, "Evaluation", string(event.Events[0].Topic))
|
||||
case <-time.After(5 * time.Second):
|
||||
require.Fail(t, "failed waiting for event stream event")
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func TestEvent_Stream_Err_InvalidQueryParam(t *testing.T) {
|
|||
events := c.EventStream()
|
||||
q := &QueryOptions{}
|
||||
topics := map[Topic][]string{
|
||||
"Eval": {"::*"},
|
||||
TopicEvaluation: {"::*"},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -94,7 +94,7 @@ func TestEvent_Stream_CloseCtx(t *testing.T) {
|
|||
events := c.EventStream()
|
||||
q := &QueryOptions{}
|
||||
topics := map[Topic][]string{
|
||||
"Eval": {"*"},
|
||||
TopicEvaluation: {"*"},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -133,7 +133,7 @@ func TestEventStream_PayloadValue(t *testing.T) {
|
|||
events := c.EventStream()
|
||||
q := &QueryOptions{}
|
||||
topics := map[Topic][]string{
|
||||
"Node": {"*"},
|
||||
TopicNode: {"*"},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -161,13 +161,14 @@ func TestEventStream_PayloadValueHelpers(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
topic Topic
|
||||
desc string
|
||||
event Event
|
||||
input []byte
|
||||
err string
|
||||
expectFn func(t *testing.T, event Event)
|
||||
}{
|
||||
{
|
||||
desc: "deployment",
|
||||
input: []byte(`{"Topic": "Deployment", "Payload": {"Deployment":{"ID":"some-id","JobID":"some-job-id", "TaskGroups": {"tg1": {"RequireProgressBy": "2020-11-05T11:52:54.370774000-05:00"}}}}}`),
|
||||
expectFn: func(t *testing.T, event Event) {
|
||||
eventTime, err := time.Parse(time.RFC3339, "2020-11-05T11:52:54.370774000-05:00")
|
||||
|
@ -189,9 +190,10 @@ func TestEventStream_PayloadValueHelpers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
input: []byte(`{"Topic": "Eval", "Payload": {"Eval":{"ID":"some-id","Namespace":"some-namespace-id"}}}`),
|
||||
desc: "evaluation",
|
||||
input: []byte(`{"Topic": "Evaluation", "Payload": {"Evaluation":{"ID":"some-id","Namespace":"some-namespace-id"}}}`),
|
||||
expectFn: func(t *testing.T, event Event) {
|
||||
require.Equal(t, TopicEval, event.Topic)
|
||||
require.Equal(t, TopicEvaluation, event.Topic)
|
||||
eval, err := event.Evaluation()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -202,9 +204,10 @@ func TestEventStream_PayloadValueHelpers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
input: []byte(`{"Topic": "Alloc", "Payload": {"Alloc":{"ID":"some-id","Namespace":"some-namespace-id"}}}`),
|
||||
desc: "allocation",
|
||||
input: []byte(`{"Topic": "Allocation", "Payload": {"Allocation":{"ID":"some-id","Namespace":"some-namespace-id"}}}`),
|
||||
expectFn: func(t *testing.T, event Event) {
|
||||
require.Equal(t, TopicAlloc, event.Topic)
|
||||
require.Equal(t, TopicAllocation, event.Topic)
|
||||
a, err := event.Allocation()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &Allocation{
|
||||
|
@ -226,6 +229,7 @@ func TestEventStream_PayloadValueHelpers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
desc: "node",
|
||||
input: []byte(`{"Topic": "Node", "Payload": {"Node":{"ID":"some-id","Datacenter":"some-dc-id"}}}`),
|
||||
expectFn: func(t *testing.T, event Event) {
|
||||
require.Equal(t, TopicNode, event.Topic)
|
||||
|
@ -240,7 +244,7 @@ func TestEventStream_PayloadValueHelpers(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(string(tc.topic), func(t *testing.T) {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
var out Event
|
||||
err := json.Unmarshal(tc.input, &out)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -59,7 +59,7 @@ func (tc *EventsTest) TestDeploymentEvents(f *framework.F) {
|
|||
defer cancel()
|
||||
|
||||
topics := map[api.Topic][]string{
|
||||
"Deployment": {jobID},
|
||||
api.TopicDeployment: {jobID},
|
||||
}
|
||||
|
||||
var deployEvents []api.Event
|
||||
|
@ -127,7 +127,7 @@ func (tc *EventsTest) TestBlockedEvalEvents(f *framework.F) {
|
|||
defer cancel()
|
||||
|
||||
topics := map[api.Topic][]string{
|
||||
"Eval": {"*"},
|
||||
api.TopicEvaluation: {"*"},
|
||||
}
|
||||
|
||||
var evalEvents []api.Event
|
||||
|
@ -206,7 +206,7 @@ func (tc *EventsTest) TestStartIndex(f *framework.F) {
|
|||
startIndex := *job.JobModifyIndex + 1
|
||||
|
||||
topics := map[api.Topic][]string{
|
||||
"Job": {"*"},
|
||||
api.TopicJob: {"*"},
|
||||
}
|
||||
|
||||
// starting at Job.ModifyIndex + 1, the next (and only) JobRegistered event that we see
|
||||
|
|
|
@ -336,7 +336,7 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "no token",
|
||||
Token: "",
|
||||
Topics: map[structs.Topic][]string{
|
||||
"*": {"*"},
|
||||
structs.TopicAll: {"*"},
|
||||
},
|
||||
ExpectedErr: structs.ErrPermissionDenied.Error(),
|
||||
},
|
||||
|
@ -344,7 +344,7 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "bad token",
|
||||
Token: tokenBad.SecretID,
|
||||
Topics: map[structs.Topic][]string{
|
||||
"*": {"*"},
|
||||
structs.TopicAll: {"*"},
|
||||
},
|
||||
ExpectedErr: structs.ErrPermissionDenied.Error(),
|
||||
},
|
||||
|
@ -352,10 +352,10 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "job namespace token - correct ns",
|
||||
Token: tokenNsFoo.SecretID,
|
||||
Topics: map[structs.Topic][]string{
|
||||
"Job": {"*"},
|
||||
"Eval": {"*"},
|
||||
"Alloc": {"*"},
|
||||
"Deployment": {"*"},
|
||||
structs.TopicJob: {"*"},
|
||||
structs.TopicEvaluation: {"*"},
|
||||
structs.TopicAllocation: {"*"},
|
||||
structs.TopicDeployment: {"*"},
|
||||
},
|
||||
Namespace: "foo",
|
||||
ExpectedErr: "subscription closed by server",
|
||||
|
@ -367,7 +367,7 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "job namespace token - incorrect ns",
|
||||
Token: tokenNsFoo.SecretID,
|
||||
Topics: map[structs.Topic][]string{
|
||||
"Job": {"*"}, // good
|
||||
structs.TopicJob: {"*"}, // good
|
||||
},
|
||||
Namespace: "bar", // bad
|
||||
ExpectedErr: structs.ErrPermissionDenied.Error(),
|
||||
|
@ -379,7 +379,7 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "job namespace token - request management topic",
|
||||
Token: tokenNsFoo.SecretID,
|
||||
Topics: map[structs.Topic][]string{
|
||||
"*": {"*"}, // bad
|
||||
structs.TopicAll: {"*"}, // bad
|
||||
},
|
||||
Namespace: "foo",
|
||||
ExpectedErr: structs.ErrPermissionDenied.Error(),
|
||||
|
@ -391,8 +391,8 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "job namespace token - request invalid node topic",
|
||||
Token: tokenNsFoo.SecretID,
|
||||
Topics: map[structs.Topic][]string{
|
||||
"Eval": {"*"}, // good
|
||||
"Node": {"*"}, // bad
|
||||
structs.TopicEvaluation: {"*"}, // good
|
||||
structs.TopicNode: {"*"}, // bad
|
||||
},
|
||||
Namespace: "foo",
|
||||
ExpectedErr: structs.ErrPermissionDenied.Error(),
|
||||
|
@ -404,8 +404,8 @@ func TestEventStream_ACL(t *testing.T) {
|
|||
Name: "job+node namespace token, valid",
|
||||
Token: tokenNsNode.SecretID,
|
||||
Topics: map[structs.Topic][]string{
|
||||
"Eval": {"*"}, // good
|
||||
"Node": {"*"}, // good
|
||||
structs.TopicEvaluation: {"*"}, // good
|
||||
structs.TopicNode: {"*"}, // good
|
||||
},
|
||||
Namespace: "foo",
|
||||
ExpectedErr: "subscription closed by server",
|
||||
|
|
|
@ -10,13 +10,13 @@ var MsgTypeEvents = map[structs.MessageType]string{
|
|||
structs.NodeDeregisterRequestType: structs.TypeNodeDeregistration,
|
||||
structs.UpsertNodeEventsType: structs.TypeNodeEvent,
|
||||
structs.EvalUpdateRequestType: structs.TypeEvalUpdated,
|
||||
structs.AllocClientUpdateRequestType: structs.TypeAllocUpdated,
|
||||
structs.AllocClientUpdateRequestType: structs.TypeAllocationUpdated,
|
||||
structs.JobRegisterRequestType: structs.TypeJobRegistered,
|
||||
structs.AllocUpdateRequestType: structs.TypeAllocUpdated,
|
||||
structs.AllocUpdateRequestType: structs.TypeAllocationUpdated,
|
||||
structs.NodeUpdateStatusRequestType: structs.TypeNodeEvent,
|
||||
structs.JobDeregisterRequestType: structs.TypeJobDeregistered,
|
||||
structs.JobBatchDeregisterRequestType: structs.TypeJobBatchDeregistered,
|
||||
structs.AllocUpdateDesiredTransitionRequestType: structs.TypeAllocUpdateDesiredStatus,
|
||||
structs.AllocUpdateDesiredTransitionRequestType: structs.TypeAllocationUpdateDesiredStatus,
|
||||
structs.NodeUpdateEligibilityRequestType: structs.TypeNodeDrain,
|
||||
structs.NodeUpdateDrainRequestType: structs.TypeNodeDrain,
|
||||
structs.BatchNodeUpdateDrainRequestType: structs.TypeNodeDrain,
|
||||
|
@ -122,15 +122,15 @@ func eventFromChange(change memdb.Change) (structs.Event, bool) {
|
|||
return structs.Event{}, false
|
||||
}
|
||||
return structs.Event{
|
||||
Topic: structs.TopicEval,
|
||||
Topic: structs.TopicEvaluation,
|
||||
Key: after.ID,
|
||||
FilterKeys: []string{
|
||||
after.JobID,
|
||||
after.DeploymentID,
|
||||
},
|
||||
Namespace: after.Namespace,
|
||||
Payload: &structs.EvalEvent{
|
||||
Eval: after,
|
||||
Payload: &structs.EvaluationEvent{
|
||||
Evaluation: after,
|
||||
},
|
||||
}, true
|
||||
case "allocs":
|
||||
|
@ -149,12 +149,12 @@ func eventFromChange(change memdb.Change) (structs.Event, bool) {
|
|||
alloc.Job = nil
|
||||
|
||||
return structs.Event{
|
||||
Topic: structs.TopicAlloc,
|
||||
Topic: structs.TopicAllocation,
|
||||
Key: after.ID,
|
||||
FilterKeys: filterKeys,
|
||||
Namespace: after.Namespace,
|
||||
Payload: &structs.AllocEvent{
|
||||
Alloc: alloc,
|
||||
Payload: &structs.AllocationEvent{
|
||||
Allocation: alloc,
|
||||
},
|
||||
}, true
|
||||
case "jobs":
|
||||
|
|
|
@ -238,7 +238,7 @@ func TestEventsFromChanges_DeploymentAllocHealthRequestType(t *testing.T) {
|
|||
var allocEvents []structs.Event
|
||||
var deploymentEvent []structs.Event
|
||||
for _, e := range events {
|
||||
if e.Topic == structs.TopicAlloc {
|
||||
if e.Topic == structs.TopicAllocation {
|
||||
allocEvents = append(allocEvents, e)
|
||||
} else if e.Topic == structs.TopicDeployment {
|
||||
deploymentEvent = append(deploymentEvent, e)
|
||||
|
@ -249,7 +249,7 @@ func TestEventsFromChanges_DeploymentAllocHealthRequestType(t *testing.T) {
|
|||
for _, e := range allocEvents {
|
||||
require.Equal(t, 100, int(e.Index))
|
||||
require.Equal(t, structs.TypeDeploymentAllocHealth, e.Type)
|
||||
require.Equal(t, structs.TopicAlloc, e.Topic)
|
||||
require.Equal(t, structs.TopicAllocation, e.Topic)
|
||||
}
|
||||
|
||||
require.Len(t, deploymentEvent, 1)
|
||||
|
@ -359,12 +359,12 @@ func TestEventsFromChanges_EvalUpdateRequestType(t *testing.T) {
|
|||
require.Len(t, events, 1)
|
||||
|
||||
e := events[0]
|
||||
require.Equal(t, structs.TopicEval, e.Topic)
|
||||
require.Equal(t, structs.TopicEvaluation, e.Topic)
|
||||
require.Equal(t, structs.TypeEvalUpdated, e.Type)
|
||||
require.Contains(t, e.FilterKeys, e2.JobID)
|
||||
require.Contains(t, e.FilterKeys, e2.DeploymentID)
|
||||
event := e.Payload.(*structs.EvalEvent)
|
||||
require.Equal(t, "blocked", event.Eval.Status)
|
||||
event := e.Payload.(*structs.EvaluationEvent)
|
||||
require.Equal(t, "blocked", event.Evaluation.Status)
|
||||
}
|
||||
|
||||
func TestEventsFromChanges_ApplyPlanResultsRequestType(t *testing.T) {
|
||||
|
@ -411,9 +411,9 @@ func TestEventsFromChanges_ApplyPlanResultsRequestType(t *testing.T) {
|
|||
var jobs []structs.Event
|
||||
var deploys []structs.Event
|
||||
for _, e := range events {
|
||||
if e.Topic == structs.TopicAlloc {
|
||||
if e.Topic == structs.TopicAllocation {
|
||||
allocs = append(allocs, e)
|
||||
} else if e.Topic == structs.TopicEval {
|
||||
} else if e.Topic == structs.TopicEvaluation {
|
||||
evals = append(evals, e)
|
||||
} else if e.Topic == structs.TopicJob {
|
||||
jobs = append(jobs, e)
|
||||
|
@ -562,15 +562,15 @@ func TestEventsFromChanges_AllocUpdateDesiredTransitionRequestType(t *testing.T)
|
|||
var allocs []structs.Event
|
||||
var evalEvents []structs.Event
|
||||
for _, e := range events {
|
||||
if e.Topic == structs.TopicEval {
|
||||
if e.Topic == structs.TopicEvaluation {
|
||||
evalEvents = append(evalEvents, e)
|
||||
} else if e.Topic == structs.TopicAlloc {
|
||||
} else if e.Topic == structs.TopicAllocation {
|
||||
allocs = append(allocs, e)
|
||||
} else {
|
||||
require.Fail(t, "unexpected event type")
|
||||
}
|
||||
|
||||
require.Equal(t, structs.TypeAllocUpdateDesiredStatus, e.Type)
|
||||
require.Equal(t, structs.TypeAllocationUpdateDesiredStatus, e.Type)
|
||||
}
|
||||
|
||||
require.Len(t, allocs, 1)
|
||||
|
|
|
@ -293,8 +293,8 @@ func aclAllowsSubscription(aclObj *acl.ACL, subReq *SubscribeRequest) bool {
|
|||
for topic := range subReq.Topics {
|
||||
switch topic {
|
||||
case structs.TopicDeployment,
|
||||
structs.TopicEval,
|
||||
structs.TopicAlloc,
|
||||
structs.TopicEvaluation,
|
||||
structs.TopicAllocation,
|
||||
structs.TopicJob:
|
||||
if ok := aclObj.AllowNsOp(subReq.Namespace, acl.NamespaceCapabilityReadJob); !ok {
|
||||
return false
|
||||
|
|
|
@ -224,10 +224,10 @@ func TestEventBroker_handleACLUpdates_policyupdated(t *testing.T) {
|
|||
policyAfterRules: mock.NamespacePolicy(structs.DefaultNamespace, "", []string{}),
|
||||
shouldUnsubscribe: true,
|
||||
event: structs.Event{
|
||||
Topic: structs.TopicEval,
|
||||
Topic: structs.TopicEvaluation,
|
||||
Type: structs.TypeEvalUpdated,
|
||||
Payload: structs.EvalEvent{
|
||||
Eval: &structs.Evaluation{
|
||||
Payload: structs.EvaluationEvent{
|
||||
Evaluation: &structs.Evaluation{
|
||||
ID: "some-id",
|
||||
},
|
||||
},
|
||||
|
@ -248,10 +248,10 @@ func TestEventBroker_handleACLUpdates_policyupdated(t *testing.T) {
|
|||
policyAfterRules: mock.NamespacePolicy(structs.DefaultNamespace, "", []string{}),
|
||||
shouldUnsubscribe: true,
|
||||
event: structs.Event{
|
||||
Topic: structs.TopicAlloc,
|
||||
Type: structs.TypeAllocUpdated,
|
||||
Payload: structs.AllocEvent{
|
||||
Alloc: &structs.Allocation{
|
||||
Topic: structs.TopicAllocation,
|
||||
Type: structs.TypeAllocationUpdated,
|
||||
Payload: structs.AllocationEvent{
|
||||
Allocation: &structs.Allocation{
|
||||
ID: "some-id",
|
||||
},
|
||||
},
|
||||
|
@ -320,10 +320,10 @@ func TestEventBroker_handleACLUpdates_policyupdated(t *testing.T) {
|
|||
policyAfterRules: mock.NamespacePolicy(structs.DefaultNamespace, "", []string{acl.NamespaceCapabilityReadJob}),
|
||||
shouldUnsubscribe: false,
|
||||
event: structs.Event{
|
||||
Topic: structs.TopicEval,
|
||||
Topic: structs.TopicEvaluation,
|
||||
Type: structs.TypeEvalUpdated,
|
||||
Payload: structs.EvalEvent{
|
||||
Eval: &structs.Evaluation{
|
||||
Payload: structs.EvaluationEvent{
|
||||
Evaluation: &structs.Evaluation{
|
||||
ID: "some-id",
|
||||
},
|
||||
},
|
||||
|
@ -344,10 +344,10 @@ func TestEventBroker_handleACLUpdates_policyupdated(t *testing.T) {
|
|||
policyAfterRules: mock.NamespacePolicy(structs.DefaultNamespace, "", []string{acl.NamespaceCapabilityReadJob}),
|
||||
shouldUnsubscribe: false,
|
||||
event: structs.Event{
|
||||
Topic: structs.TopicAlloc,
|
||||
Type: structs.TypeAllocUpdated,
|
||||
Payload: structs.AllocEvent{
|
||||
Alloc: &structs.Allocation{
|
||||
Topic: structs.TopicAllocation,
|
||||
Type: structs.TypeAllocationUpdated,
|
||||
Payload: structs.AllocationEvent{
|
||||
Allocation: &structs.Allocation{
|
||||
ID: "some-id",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -17,34 +17,34 @@ type Topic string
|
|||
|
||||
const (
|
||||
TopicDeployment Topic = "Deployment"
|
||||
TopicEval Topic = "Eval"
|
||||
TopicAlloc Topic = "Alloc"
|
||||
TopicEvaluation Topic = "Evaluation"
|
||||
TopicAllocation Topic = "Allococation"
|
||||
TopicJob Topic = "Job"
|
||||
TopicNode Topic = "Node"
|
||||
TopicACLPolicy Topic = "ACLToken"
|
||||
TopicACLToken Topic = "ACLPolicy"
|
||||
TopicAll Topic = "*"
|
||||
|
||||
TypeNodeRegistration = "NodeRegistration"
|
||||
TypeNodeDeregistration = "NodeDeregistration"
|
||||
TypeNodeEligibilityUpdate = "NodeEligibility"
|
||||
TypeNodeDrain = "NodeDrain"
|
||||
TypeNodeEvent = "NodeStreamEvent"
|
||||
TypeDeploymentUpdate = "DeploymentStatusUpdate"
|
||||
TypeDeploymentPromotion = "DeploymentPromotion"
|
||||
TypeDeploymentAllocHealth = "DeploymentAllocHealth"
|
||||
TypeAllocCreated = "AllocCreated"
|
||||
TypeAllocUpdated = "AllocUpdated"
|
||||
TypeAllocUpdateDesiredStatus = "AllocUpdateDesiredStatus"
|
||||
TypeEvalUpdated = "EvalUpdated"
|
||||
TypeJobRegistered = "JobRegistered"
|
||||
TypeJobDeregistered = "JobDeregistered"
|
||||
TypeJobBatchDeregistered = "JobBatchDeregistered"
|
||||
TypePlanResult = "PlanResult"
|
||||
TypeACLTokenDeleted = "ACLTokenDeleted"
|
||||
TypeACLTokenUpserted = "ACLTokenUpserted"
|
||||
TypeACLPolicyDeleted = "ACLPolicyDeleted"
|
||||
TypeACLPolicyUpserted = "ACLPolicyUpserted"
|
||||
TypeNodeRegistration = "NodeRegistration"
|
||||
TypeNodeDeregistration = "NodeDeregistration"
|
||||
TypeNodeEligibilityUpdate = "NodeEligibility"
|
||||
TypeNodeDrain = "NodeDrain"
|
||||
TypeNodeEvent = "NodeStreamEvent"
|
||||
TypeDeploymentUpdate = "DeploymentStatusUpdate"
|
||||
TypeDeploymentPromotion = "DeploymentPromotion"
|
||||
TypeDeploymentAllocHealth = "DeploymentAllocHealth"
|
||||
TypeAllocationCreated = "AllocationCreated"
|
||||
TypeAllocationUpdated = "AllocationUpdated"
|
||||
TypeAllocationUpdateDesiredStatus = "AllocationUpdateDesiredStatus"
|
||||
TypeEvalUpdated = "EvaluationUpdated"
|
||||
TypeJobRegistered = "JobRegistered"
|
||||
TypeJobDeregistered = "JobDeregistered"
|
||||
TypeJobBatchDeregistered = "JobBatchDeregistered"
|
||||
TypePlanResult = "PlanResult"
|
||||
TypeACLTokenDeleted = "ACLTokenDeleted"
|
||||
TypeACLTokenUpserted = "ACLTokenUpserted"
|
||||
TypeACLPolicyDeleted = "ACLPolicyDeleted"
|
||||
TypeACLPolicyUpserted = "ACLPolicyUpserted"
|
||||
)
|
||||
|
||||
// Event represents a change in Nomads state.
|
||||
|
@ -97,15 +97,15 @@ type JobEvent struct {
|
|||
Job *Job
|
||||
}
|
||||
|
||||
// EvalEvent holds a newly updated Eval.
|
||||
type EvalEvent struct {
|
||||
Eval *Evaluation
|
||||
// EvaluationEvent holds a newly updated Eval.
|
||||
type EvaluationEvent struct {
|
||||
Evaluation *Evaluation
|
||||
}
|
||||
|
||||
// AllocEvent holds a newly updated Allocation. The
|
||||
// AllocationEvent holds a newly updated Allocation. The
|
||||
// Allocs embedded Job has been removed to reduce size.
|
||||
type AllocEvent struct {
|
||||
Alloc *Allocation
|
||||
type AllocationEvent struct {
|
||||
Allocation *Allocation
|
||||
}
|
||||
|
||||
// DeploymentEvent holds a newly updated Deployment.
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
const (
|
||||
TopicDeployment Topic = "Deployment"
|
||||
TopicEval Topic = "Eval"
|
||||
TopicAlloc Topic = "Alloc"
|
||||
TopicEvaluation Topic = "Evaluation"
|
||||
TopicAllocation Topic = "Allocation"
|
||||
TopicJob Topic = "Job"
|
||||
TopicNode Topic = "Node"
|
||||
TopicAll Topic = "*"
|
||||
|
@ -92,9 +92,9 @@ func (e *Event) Node() (*Node, error) {
|
|||
}
|
||||
|
||||
type eventPayload struct {
|
||||
Allocation *Allocation `mapstructure:"Alloc"`
|
||||
Allocation *Allocation `mapstructure:"Allocation"`
|
||||
Deployment *Deployment `mapstructure:"Deployment"`
|
||||
Evaluation *Evaluation `mapstructure:"Eval"`
|
||||
Evaluation *Evaluation `mapstructure:"Evaluation"`
|
||||
Job *Job `mapstructure:"Job"`
|
||||
Node *Node `mapstructure:"Node"`
|
||||
}
|
||||
|
|
|
@ -29,10 +29,12 @@ the nature of this endpoint individual topics require specific policies.
|
|||
| Topic | ACL Required |
|
||||
| ------------ | -------------------- |
|
||||
| `*` | `management` |
|
||||
| `ACLToken` | `management` |
|
||||
| `ACLPolicy` | `management` |
|
||||
| `Job` | `namespace:read-job` |
|
||||
| `Alloc` | `namespace:read-job` |
|
||||
| `Allocation` | `namespace:read-job` |
|
||||
| `Deployment` | `namespace:read-job` |
|
||||
| `Eval` | `namespace:read-job` |
|
||||
| `Evaluation` | `namespace:read-job` |
|
||||
| `Node` | `node:read` |
|
||||
|
||||
### Parameters
|
||||
|
@ -53,35 +55,42 @@ the nature of this endpoint individual topics require specific policies.
|
|||
|
||||
### Event Topics
|
||||
|
||||
| Topic | Output |
|
||||
| Topic | Output |
|
||||
| ------------ | ------------------------------- |
|
||||
| ACLToken | ACLToken |
|
||||
| ACLPolicy | ACLPolicy |
|
||||
| ACLPolicy | Allocation (no job information) |
|
||||
| Allocation | Allocation (no job information) |
|
||||
| Job | Job |
|
||||
| Eval | Evaluation |
|
||||
| Alloc | Allocation (no job information) |
|
||||
| Evaluation | Evaluation |
|
||||
| Deployment | Deployment |
|
||||
| Node | Node |
|
||||
| NodeDrain | Node |
|
||||
|
||||
### Event Types
|
||||
|
||||
| Type |
|
||||
| ------------------------ |
|
||||
| AllocCreated |
|
||||
| AllocUpdated |
|
||||
| AllocUpdateDesiredStatus |
|
||||
| DeploymentStatusUpdate |
|
||||
| DeploymentPromotion |
|
||||
| DeploymentAllocHealth |
|
||||
| EvalUpdated |
|
||||
| JobRegistered |
|
||||
| JobDeregistered |
|
||||
| JobBatchDeregistered |
|
||||
| NodeRegistration |
|
||||
| NodeDeregistration |
|
||||
| NodeEligibility |
|
||||
| NodeDrain |
|
||||
| NodeEvent |
|
||||
| PlanResult |
|
||||
| Type |
|
||||
| ----------------------------- |
|
||||
| ACLTokenUpserted |
|
||||
| ACLTokenDeleted |
|
||||
| ACLPolicyUpserted |
|
||||
| ACLPolicyDeleted |
|
||||
| AllocationCreated |
|
||||
| AllocationUpdated |
|
||||
| AllocationUpdateDesiredStatus |
|
||||
| DeploymentStatusUpdate |
|
||||
| DeploymentPromotion |
|
||||
| DeploymentAllocHealth |
|
||||
| EvaluationUpdated |
|
||||
| JobRegistered |
|
||||
| JobDeregistered |
|
||||
| JobBatchDeregistered |
|
||||
| NodeRegistration |
|
||||
| NodeDeregistration |
|
||||
| NodeEligibility |
|
||||
| NodeDrain |
|
||||
| NodeEvent |
|
||||
| PlanResult |
|
||||
|
||||
### Sample Request
|
||||
|
||||
|
@ -90,7 +99,7 @@ $ curl -s -v -N http://127.0.0.1:4646/v1/event/stream
|
|||
```
|
||||
|
||||
```shell-session
|
||||
$ curl -s -v -N http://127.0.0.1:4646/v1/event/stream?index=100&topic=Eval
|
||||
$ curl -s -v -N http://127.0.0.1:4646/v1/event/stream?index=100&topic=Evaluation
|
||||
```
|
||||
|
||||
```shell-session
|
||||
|
|
Loading…
Reference in New Issue