mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
36230daa86
rancher/kine ➡️ k3s-io/kine Part of https://github.com/rancher/k3s/issues/2189 Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.etcd.io/etcd/etcdserver/etcdserverpb"
|
|
"go.etcd.io/etcd/mvcc/mvccpb"
|
|
)
|
|
|
|
func isCompact(txn *etcdserverpb.TxnRequest) bool {
|
|
// See https://github.com/kubernetes/kubernetes/blob/442a69c3bdf6fe8e525b05887e57d89db1e2f3a5/staging/src/k8s.io/apiserver/pkg/storage/etcd3/compact.go#L72
|
|
return len(txn.Compare) == 1 &&
|
|
txn.Compare[0].Target == etcdserverpb.Compare_VERSION &&
|
|
txn.Compare[0].Result == etcdserverpb.Compare_EQUAL &&
|
|
len(txn.Success) == 1 &&
|
|
txn.Success[0].GetRequestPut() != nil &&
|
|
len(txn.Failure) == 1 &&
|
|
txn.Failure[0].GetRequestRange() != nil &&
|
|
string(txn.Compare[0].Key) == "compact_rev_key"
|
|
}
|
|
|
|
func (l *LimitedServer) compact(ctx context.Context) (*etcdserverpb.TxnResponse, error) {
|
|
// return comparison failure so that the apiserver does not bother compacting
|
|
return &etcdserverpb.TxnResponse{
|
|
Header: &etcdserverpb.ResponseHeader{},
|
|
Succeeded: false,
|
|
Responses: []*etcdserverpb.ResponseOp{
|
|
{
|
|
Response: &etcdserverpb.ResponseOp_ResponseRange{
|
|
ResponseRange: &etcdserverpb.RangeResponse{
|
|
Header: &etcdserverpb.ResponseHeader{},
|
|
Kvs: []*mvccpb.KeyValue{
|
|
&mvccpb.KeyValue{},
|
|
},
|
|
Count: 1,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}, nil
|
|
}
|