Standardize on one spelling of "canceled" (#399)
This commit is contained in:
1 parent
35c3f5b717
commit
f25186f78a
11 files changed
+71
-69
No files matched your search
@@ -3761,7 +3761,7 @@ begin;
|
||||
'unknown',
|
||||
'timed out',
|
||||
'closed by end-user',
|
||||
'cancelled',
|
||||
'canceled',
|
||||
'network error',
|
||||
'system error'
|
||||
)
|
||||
@@ -3773,7 +3773,7 @@ begin;
|
||||
('unknown'),
|
||||
('timed out'),
|
||||
('closed by end-user'),
|
||||
('cancelled'),
|
||||
('canceled'),
|
||||
('network error'),
|
||||
('system error');
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ begin;
|
||||
'unknown',
|
||||
'timed out',
|
||||
'closed by end-user',
|
||||
'cancelled',
|
||||
'canceled',
|
||||
'network error',
|
||||
'system error'
|
||||
)
|
||||
@@ -70,7 +70,7 @@ begin;
|
||||
('unknown'),
|
||||
('timed out'),
|
||||
('closed by end-user'),
|
||||
('cancelled'),
|
||||
('canceled'),
|
||||
('network error'),
|
||||
('system error');
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ const (
|
||||
SESSIONSTATUS_SESSIONSTATUS_UNSPECIFIED SESSIONSTATUS = 0
|
||||
SESSIONSTATUS_SESSIONSTATUS_PENDING SESSIONSTATUS = 1
|
||||
SESSIONSTATUS_SESSIONSTATUS_ACTIVE SESSIONSTATUS = 2
|
||||
SESSIONSTATUS_SESSIONSTATUS_CANCELLING SESSIONSTATUS = 3
|
||||
SESSIONSTATUS_SESSIONSTATUS_CANCELING SESSIONSTATUS = 3
|
||||
SESSIONSTATUS_SESSIONSTATUS_TERMINATED SESSIONSTATUS = 4
|
||||
)
|
||||
|
||||
@@ -99,14 +99,14 @@ var (
|
||||
0: "SESSIONSTATUS_UNSPECIFIED",
|
||||
1: "SESSIONSTATUS_PENDING",
|
||||
2: "SESSIONSTATUS_ACTIVE",
|
||||
3: "SESSIONSTATUS_CANCELLING",
|
||||
3: "SESSIONSTATUS_CANCELING",
|
||||
4: "SESSIONSTATUS_TERMINATED",
|
||||
}
|
||||
SESSIONSTATUS_value = map[string]int32{
|
||||
"SESSIONSTATUS_UNSPECIFIED": 0,
|
||||
"SESSIONSTATUS_PENDING": 1,
|
||||
"SESSIONSTATUS_ACTIVE": 2,
|
||||
"SESSIONSTATUS_CANCELLING": 3,
|
||||
"SESSIONSTATUS_CANCELING": 3,
|
||||
"SESSIONSTATUS_TERMINATED": 4,
|
||||
}
|
||||
)
|
||||
@@ -594,10 +594,11 @@ type StatusResponse struct {
|
||||
// Active controllers. This can be used (eventually) for connection
|
||||
// management.
|
||||
Controllers []*servers.Server `protobuf:"bytes,10,rep,name=controllers,proto3" json:"controllers,omitempty"`
|
||||
// List of jobs and the expected state changes. For example, this will include jobs witch
|
||||
// change type of cancelled for jobs which are active on a worker but should be cancelled.
|
||||
// This could also contain a request to start a job such as a worker -> worker proxy for
|
||||
// establishing a session through an enclave.
|
||||
// List of jobs and the expected state changes. For example, this will
|
||||
// include jobs witch change type of canceled for jobs which are active on a
|
||||
// worker but should be canceled. This could also contain a request to start a
|
||||
// job such as a worker -> worker proxy for establishing a session through an
|
||||
// enclave.
|
||||
JobsRequests []*JobChangeRequest `protobuf:"bytes,20,rep,name=jobs_requests,json=jobsRequests,proto3" json:"jobs_requests,omitempty"`
|
||||
}
|
||||
|
||||
@@ -733,39 +734,39 @@ var file_controller_servers_services_v1_server_coordination_service_proto_rawDes
|
||||
0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53,
|
||||
0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x1b, 0x0a, 0x17,
|
||||
0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53,
|
||||
0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x9f, 0x01, 0x0a, 0x0d, 0x53, 0x45,
|
||||
0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x9e, 0x01, 0x0a, 0x0d, 0x53, 0x45,
|
||||
0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x12, 0x1d, 0x0a, 0x19, 0x53,
|
||||
0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53,
|
||||
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x45,
|
||||
0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x45, 0x4e, 0x44,
|
||||
0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e,
|
||||
0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x12,
|
||||
0x1c, 0x0a, 0x18, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53,
|
||||
0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x12, 0x1c, 0x0a,
|
||||
0x18, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x54,
|
||||
0x45, 0x52, 0x4d, 0x49, 0x4e, 0x41, 0x54, 0x45, 0x44, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x07, 0x4a,
|
||||
0x4f, 0x42, 0x54, 0x59, 0x50, 0x45, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x4f, 0x42, 0x54, 0x59, 0x50,
|
||||
0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12,
|
||||
0x13, 0x0a, 0x0f, 0x4a, 0x4f, 0x42, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49,
|
||||
0x4f, 0x4e, 0x10, 0x01, 0x2a, 0x45, 0x0a, 0x0a, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x54, 0x59,
|
||||
0x50, 0x45, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x54, 0x59, 0x50, 0x45,
|
||||
0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b,
|
||||
0x0a, 0x17, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x50, 0x44,
|
||||
0x41, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x10, 0x01, 0x32, 0x86, 0x01, 0x0a, 0x19,
|
||||
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x69, 0x0a, 0x06, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
|
||||
0x1b, 0x0a, 0x17, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53,
|
||||
0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18,
|
||||
0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x54, 0x45,
|
||||
0x52, 0x4d, 0x49, 0x4e, 0x41, 0x54, 0x45, 0x44, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x07, 0x4a, 0x4f,
|
||||
0x42, 0x54, 0x59, 0x50, 0x45, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x4f, 0x42, 0x54, 0x59, 0x50, 0x45,
|
||||
0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13,
|
||||
0x0a, 0x0f, 0x4a, 0x4f, 0x42, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f,
|
||||
0x4e, 0x10, 0x01, 0x2a, 0x45, 0x0a, 0x0a, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x54, 0x59, 0x50,
|
||||
0x45, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x54, 0x59, 0x50, 0x45, 0x5f,
|
||||
0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a,
|
||||
0x17, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41,
|
||||
0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x10, 0x01, 0x32, 0x86, 0x01, 0x0a, 0x19, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x69, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x00, 0x42, 0x51, 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75,
|
||||
0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67,
|
||||
0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x22, 0x00, 0x42, 0x51, 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e,
|
||||
0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65,
|
||||
0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
+6
-5
@@ -30,7 +30,7 @@ enum SESSIONSTATUS {
|
||||
SESSIONSTATUS_UNSPECIFIED = 0;
|
||||
SESSIONSTATUS_PENDING = 1;
|
||||
SESSIONSTATUS_ACTIVE = 2;
|
||||
SESSIONSTATUS_CANCELLING = 3;
|
||||
SESSIONSTATUS_CANCELING = 3;
|
||||
SESSIONSTATUS_TERMINATED = 4;
|
||||
}
|
||||
|
||||
@@ -84,9 +84,10 @@ message StatusResponse {
|
||||
// management.
|
||||
repeated servers.v1.Server controllers = 10;
|
||||
|
||||
// List of jobs and the expected state changes. For example, this will include jobs witch
|
||||
// change type of cancelled for jobs which are active on a worker but should be cancelled.
|
||||
// This could also contain a request to start a job such as a worker -> worker proxy for
|
||||
// establishing a session through an enclave.
|
||||
// List of jobs and the expected state changes. For example, this will
|
||||
// include jobs witch change type of canceled for jobs which are active on a
|
||||
// worker but should be canceled. This could also contain a request to start a
|
||||
// job such as a worker -> worker proxy for establishing a session through an
|
||||
// enclave.
|
||||
repeated JobChangeRequest jobs_requests = 20;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func TestCancel(t *testing.T) {
|
||||
CreatedTime: sess.CreateTime.GetTimestamp(),
|
||||
ExpirationTime: sess.ExpirationTime.GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: p.GetPublicId(), Type: scope.Project.String()},
|
||||
Status: session.StatusCancelling.String(),
|
||||
Status: session.StatusCanceling.String(),
|
||||
}
|
||||
|
||||
version := wireSess.GetVersion()
|
||||
@@ -350,13 +350,13 @@ func TestCancel(t *testing.T) {
|
||||
}
|
||||
tc.res.GetItem().Version = got.GetItem().Version
|
||||
|
||||
// Compare the new cancelling state and then remove it for the rest of the proto comparison
|
||||
// Compare the new canceling state and then remove it for the rest of the proto comparison
|
||||
assert.True(got.GetItem().GetUpdatedTime().AsTime().After(got.GetItem().GetCreatedTime().AsTime()))
|
||||
assert.Len(got.GetItem().GetStates(), 2)
|
||||
|
||||
wantState := []*pb.SessionState{
|
||||
{
|
||||
Status: session.StatusCancelling.String(),
|
||||
Status: session.StatusCanceling.String(),
|
||||
StartTime: got.GetItem().GetUpdatedTime(),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -72,14 +72,14 @@ func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusReques
|
||||
|
||||
for _, jobStatus := range req.GetJobs() {
|
||||
switch jobStatus.Job.GetType() {
|
||||
// Check for session cancellation
|
||||
// Check for session cancelation
|
||||
case pbs.JOBTYPE_JOBTYPE_SESSION:
|
||||
si := jobStatus.GetJob().GetSessionInfo()
|
||||
if si == nil {
|
||||
return nil, status.Error(codes.Internal, "Error getting session info at status time")
|
||||
}
|
||||
switch si.Status {
|
||||
case pbs.SESSIONSTATUS_SESSIONSTATUS_CANCELLING,
|
||||
case pbs.SESSIONSTATUS_SESSIONSTATUS_CANCELING,
|
||||
pbs.SESSIONSTATUS_SESSIONSTATUS_TERMINATED:
|
||||
// No need to see about canceling anything
|
||||
continue
|
||||
@@ -102,7 +102,7 @@ func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusReques
|
||||
currState := sessionInfo.States[0].Status
|
||||
if currState.ProtoVal() != si.Status {
|
||||
switch currState {
|
||||
case session.StatusCancelling,
|
||||
case session.StatusCanceling,
|
||||
session.StatusTerminated:
|
||||
// If we're here the job is pending or active so we do want
|
||||
// to actually send a change request
|
||||
|
||||
@@ -138,7 +138,7 @@ func (w *Worker) startStatusTicking(cancelCtx context.Context) {
|
||||
si := value.(*sessionInfo)
|
||||
si.Lock()
|
||||
if time.Until(si.lookupSessionResponse.Expiration.AsTime()) < 0 ||
|
||||
si.status == pbs.SESSIONSTATUS_SESSIONSTATUS_CANCELLING {
|
||||
si.status == pbs.SESSIONSTATUS_SESSIONSTATUS_CANCELING {
|
||||
var toClose int
|
||||
for k, v := range si.connInfoMap {
|
||||
if v.closeTime.IsZero() {
|
||||
|
||||
@@ -13,7 +13,7 @@ const (
|
||||
UnknownReason ClosedReason = "unknown"
|
||||
ConnectionTimedOut ClosedReason = "timed out"
|
||||
ConnectionClosedByUser ClosedReason = "closed by end-user"
|
||||
ConnectionCancelled ClosedReason = "cancelled"
|
||||
ConnectionCanceled ClosedReason = "canceled"
|
||||
ConnectionNetworkError ClosedReason = "network error"
|
||||
ConnectionSystemError ClosedReason = "system error"
|
||||
)
|
||||
@@ -30,8 +30,8 @@ func convertToClosedReason(s string) (ClosedReason, error) {
|
||||
return ConnectionTimedOut, nil
|
||||
case ConnectionClosedByUser.String():
|
||||
return ConnectionClosedByUser, nil
|
||||
case ConnectionCancelled.String():
|
||||
return ConnectionCancelled, nil
|
||||
case ConnectionCanceled.String():
|
||||
return ConnectionCanceled, nil
|
||||
case ConnectionNetworkError.String():
|
||||
return ConnectionNetworkError, nil
|
||||
case ConnectionSystemError.String():
|
||||
|
||||
@@ -260,10 +260,10 @@ func (r *Repository) DeleteSession(ctx context.Context, publicId string, opt ...
|
||||
return rowsDeleted, nil
|
||||
}
|
||||
|
||||
// CancelSession sets a session's state to "cancelling" in the repo. It's
|
||||
// called when the user cancels a session and the controller wants to update the
|
||||
// session state to "cancelling" for the given reason, so the workers can get
|
||||
// the "cancelling signal" during their next status heartbeat. CancelSession is
|
||||
// CancelSession sets a session's state to "canceling" in the repo. It's called
|
||||
// when the user cancels a session and the controller wants to update the
|
||||
// session state to "canceling" for the given reason, so the workers can get the
|
||||
// "canceling signal" during their next status heartbeat. CancelSession is
|
||||
// idempotent.
|
||||
func (r *Repository) CancelSession(ctx context.Context, sessionId string, sessionVersion uint32) (*Session, error) {
|
||||
if sessionId == "" {
|
||||
@@ -272,7 +272,7 @@ func (r *Repository) CancelSession(ctx context.Context, sessionId string, sessio
|
||||
if sessionVersion == 0 {
|
||||
return nil, fmt.Errorf("cancel session: missing session version: %w", db.ErrInvalidParameter)
|
||||
}
|
||||
s, ss, err := r.updateState(ctx, sessionId, sessionVersion, StatusCancelling)
|
||||
s, ss, err := r.updateState(ctx, sessionId, sessionVersion, StatusCanceling)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cancel session: %w", err)
|
||||
}
|
||||
@@ -531,7 +531,7 @@ func (r *Repository) CloseConnections(ctx context.Context, closeWith []CloseWith
|
||||
// authenticating the session. The session must be in a "pending" state to be
|
||||
// activated. States are ordered by start time descending. Returns an
|
||||
// ErrSessionNotPending error if a connection cannot be made because the session
|
||||
// was cancelled or terminated.
|
||||
// was canceled or terminated.
|
||||
func (r *Repository) ActivateSession(ctx context.Context, sessionId string, sessionVersion uint32, serverId, serverType string, tofuToken []byte) (*Session, []*State, error) {
|
||||
if sessionId == "" {
|
||||
return nil, nil, fmt.Errorf("activate session: missing session id: %w", db.ErrInvalidParameter)
|
||||
|
||||
@@ -308,9 +308,9 @@ func TestRepository_updateState(t *testing.T) {
|
||||
wantIsError error
|
||||
}{
|
||||
{
|
||||
name: "cancelling",
|
||||
name: "canceling",
|
||||
session: TestDefaultSession(t, conn, wrapper, iamRepo),
|
||||
newStatus: StatusCancelling,
|
||||
newStatus: StatusCanceling,
|
||||
wantStateCnt: 2,
|
||||
wantErr: false,
|
||||
},
|
||||
@@ -328,7 +328,7 @@ func TestRepository_updateState(t *testing.T) {
|
||||
{
|
||||
name: "bad-version",
|
||||
session: TestDefaultSession(t, conn, wrapper, iamRepo),
|
||||
newStatus: StatusCancelling,
|
||||
newStatus: StatusCanceling,
|
||||
overrideSessionVersion: func() *uint32 {
|
||||
v := uint32(22)
|
||||
return &v
|
||||
@@ -338,7 +338,7 @@ func TestRepository_updateState(t *testing.T) {
|
||||
{
|
||||
name: "empty-version",
|
||||
session: TestDefaultSession(t, conn, wrapper, iamRepo),
|
||||
newStatus: StatusCancelling,
|
||||
newStatus: StatusCanceling,
|
||||
overrideSessionVersion: func() *uint32 {
|
||||
v := uint32(0)
|
||||
return &v
|
||||
@@ -349,7 +349,7 @@ func TestRepository_updateState(t *testing.T) {
|
||||
{
|
||||
name: "bad-sessionId",
|
||||
session: TestDefaultSession(t, conn, wrapper, iamRepo),
|
||||
newStatus: StatusCancelling,
|
||||
newStatus: StatusCanceling,
|
||||
overrideSessionId: func() *string {
|
||||
s := "s_thisIsNotValid"
|
||||
return &s
|
||||
@@ -359,7 +359,7 @@ func TestRepository_updateState(t *testing.T) {
|
||||
{
|
||||
name: "empty-session",
|
||||
session: TestDefaultSession(t, conn, wrapper, iamRepo),
|
||||
newStatus: StatusCancelling,
|
||||
newStatus: StatusCanceling,
|
||||
overrideSessionId: func() *string {
|
||||
s := ""
|
||||
return &s
|
||||
@@ -864,7 +864,7 @@ func TestRepository_CancelSession(t *testing.T) {
|
||||
require.NoError(err)
|
||||
require.NotNil(s)
|
||||
require.NotNil(s.States)
|
||||
assert.Equal(StatusCancelling, s.States[0].Status)
|
||||
assert.Equal(StatusCanceling, s.States[0].Status)
|
||||
|
||||
stateCnt := len(s.States)
|
||||
origStartTime := s.States[0].StartTime
|
||||
@@ -874,7 +874,7 @@ func TestRepository_CancelSession(t *testing.T) {
|
||||
require.NotNil(s2)
|
||||
require.NotNil(s2.States)
|
||||
assert.Equal(stateCnt, len(s2.States))
|
||||
assert.Equal(StatusCancelling, s.States[0].Status)
|
||||
assert.Equal(StatusCanceling, s.States[0].Status)
|
||||
assert.Equal(origStartTime, s2.States[0].StartTime)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type Status string
|
||||
const (
|
||||
StatusPending Status = "pending"
|
||||
StatusActive Status = "active"
|
||||
StatusCancelling Status = "canceling"
|
||||
StatusCanceling Status = "canceling"
|
||||
StatusTerminated Status = "terminated"
|
||||
)
|
||||
|
||||
@@ -37,8 +37,8 @@ func (s Status) ProtoVal() workerpbs.SESSIONSTATUS {
|
||||
return workerpbs.SESSIONSTATUS_SESSIONSTATUS_PENDING
|
||||
case StatusActive:
|
||||
return workerpbs.SESSIONSTATUS_SESSIONSTATUS_ACTIVE
|
||||
case StatusCancelling:
|
||||
return workerpbs.SESSIONSTATUS_SESSIONSTATUS_CANCELLING
|
||||
case StatusCanceling:
|
||||
return workerpbs.SESSIONSTATUS_SESSIONSTATUS_CANCELING
|
||||
case StatusTerminated:
|
||||
return workerpbs.SESSIONSTATUS_SESSIONSTATUS_TERMINATED
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user