Skip to content

Commit

Permalink
fix: remove duplicated code after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Jul 27, 2023
1 parent 6440af0 commit c769d5b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 106 deletions.
20 changes: 0 additions & 20 deletions nomad/structs/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,26 +411,6 @@ func (vd VariableDecrypted) ValidateForLock() error {
return vd.Lock.Validate()
}

// A new variable can be crated just to support a lock, it doesn't require to hold
// any items and it will validate the lock.
func (vd VariableDecrypted) ValidateForLock() error {
var mErr multierror.Error
if vd.Namespace == AllNamespacesSentinel {
mErr.Errors = append(mErr.Errors, errWildCardNamespace)
return &mErr
}

if vd.Items.Size() > maxVariableSize {
return errQuotaExhausted
}

if err := ValidatePath(vd.Path); err != nil {
return err
}

return vd.Lock.Validate()
}

func ValidatePath(path string) error {
if len(path) == 0 {
return fmt.Errorf("variable requires path")
Expand Down
86 changes: 0 additions & 86 deletions nomad/variables_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,89 +1311,3 @@ func TestVariablesEndpoint_Apply_LockAcquireUpsertAndRelease(t *testing.T) {
})

}

/* func TestVariablesEndpoint_Apply_ACL1(t *testing.T) {
ci.Parallel(t)
srv, rootToken, shutdown := TestACLServer(t, func(c *Config) {
c.NumSchedulers = 0 // Prevent automatic dequeue
})
defer shutdown()
testutil.WaitForLeader(t, srv.RPC)
codec := rpcClient(t, srv)
state := srv.fsm.State()
pol := mock.NamespacePolicyWithVariables(
structs.DefaultNamespace, "", []string{"list-jobs"},
map[string][]string{
"dropbox/*": {"write"},
})
writeToken := mock.CreatePolicyAndToken(t, state, 1003, "test-invalid", pol)
mockVar := mock.Variable()
sv1.ModifyIndex = 0
var latest = &structs.VariableDecrypted{
Items: map[string]string{},
VariableMetadata: structs.VariableMetadata{
Path: "testPath",
},
} // TODO: removeeee
fmt.Println(rootToken, svHold, writeToken)
t.Run("lock-acquire/management token/new", func(t *testing.T) {
must.NotNil(t, svHold)
sv := svHold
sv.Items["upsert"] = "read"
sv.VariableMetadata.Lock = &structs.VariableLock{
TTL: 24 * time.Hour,
LockDelay: 15 * time.Second,
}
applyReq := structs.VariablesApplyRequest{
Op: structs.VarOpLockAcquire,
Var: sv,
WriteRequest: structs.WriteRequest{
Region: "global",
AuthToken: rootToken.SecretID,
},
}
must.Nil(t, srv.lockTTLTimer.Get(applyReq.Var.VariableMetadata.Lock.ID))
applyResp := new(structs.VariablesApplyResponse)
err := msgpackrpc.CallWithCodec(codec, structs.VariablesApplyRPCMethod, &applyReq, &applyResp)
must.NoError(t, err)
must.Eq(t, structs.VarOpResultOk, applyResp.Result)
must.NonZero(t, len(applyResp.Output.VariableMetadata.Lock.ID))
must.NotNil(t, srv.lockTTLTimer.Get(applyResp.Output.VariableMetadata.Lock.ID))
svHold = applyResp.Output
})
t.Run("lock-release/management token/new", func(t *testing.T) {
must.NotNil(t, svHold)
sv := svHold
applyReq := structs.VariablesApplyRequest{
Op: structs.VarOpLockRelease,
Var: sv,
WriteRequest: structs.WriteRequest{
Region: "global",
AuthToken: rootToken.SecretID,
},
}
must.NotNil(t, srv.lockTTLTimer.Get(applyReq.Var.VariableMetadata.Lock.ID))
applyResp := new(structs.VariablesApplyResponse)
err := msgpackrpc.CallWithCodec(codec, structs.VariablesApplyRPCMethod, &applyReq, &applyResp)
must.NoError(t, err)
must.Eq(t, structs.VarOpResultOk, applyResp.Result)
must.Nil(t, applyResp.Output.VariableMetadata.Lock)
must.Nil(t, srv.lockTTLTimer.Get(sv.VariableMetadata.LockID()))
})
}
*/

0 comments on commit c769d5b

Please sign in to comment.