Skip to content

Instantly share code, notes, and snippets.

View logicalhan's full-sized avatar

Han Kang logicalhan

View GitHub Profile
type FeatureSpec struct {
// Default is the default enablement state for the feature
Default bool
// LockToDefault indicates that the feature is locked to its default and cannot be changed
LockToDefault bool
// PreRelease indicates the current maturity level of the feature
PreRelease prerelease
// Version indicates the version from which this configuration is valid.
Version semver.Version
}
@logicalhan
logicalhan / featuregate-v2.go
Created November 4, 2023 01:11
version two of feature-gate prototype
type FeatureHistory struct {
Changes map[K8sVersion][]HistoryEvent
reverseMapping map[HistoryEvent]semver.Version
built bool
}
type FeatureSpec struct {
// Default is the default enablement state for the feature
Default bool
// LockToDefault indicates that the feature is locked to its default and cannot be changed
@logicalhan
logicalhan / featuregate-v1.go
Created November 4, 2023 01:09
version one of feature-gate prototype
type FeatureSpec struct {
// Default is the default enablement state for the feature
Default bool
// DefaultEnabledVersion is the Kubernetes version that this feature is default enabled.
DefaultEnabledVersion *string
// LockToDefault indicates that the feature is locked to its default and cannot be changed
LockToDefault bool
// LockToDefaultVersion indicates from which version the feature is locked to its default and cannot be changed
LockToDefaultVersion *string
// PreRelease indicates the current maturity level of the feature
@logicalhan
logicalhan / gist:e3a3c98024f0bdc998614295cf5d90aa
Created July 31, 2023 01:26
starting etcd w/ sqlite.diff
diff --git a/server/etcdmain/config.go b/server/etcdmain/config.go
index e31d1c7cf..e1605c646 100644
--- a/server/etcdmain/config.go
+++ b/server/etcdmain/config.go
@@ -255,6 +255,7 @@ func newConfig() *config {
fs.StringVar(&cfg.ec.ExperimentalDistributedTracingServiceName, "experimental-distributed-tracing-service-name", embed.ExperimentalDistributedTracingServiceName, "Configures service name for distributed tracing to be used to define service name for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag). 'etcd' is the default service name. Use the same service name for all instances of etcd.")
fs.StringVar(&cfg.ec.ExperimentalDistributedTracingServiceInstanceID, "experimental-distributed-tracing-instance-id", "", "Configures service instance ID for distributed tracing to be used to define service instance ID key for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag). There is no default value set. This ID must be unique per
[
{
"Header": {
"cluster_id": 4512387775551232000,
"member_id": 17498184932148824000,
"revision": 31,
"raft_term": 2
},
"Events": [
{
@logicalhan
logicalhan / deprecated-metric-instantation.go
Last active April 1, 2019 23:59
Metric instantiation with deprecated version
var RegisteredWatchers = kubemetrics.NewGaugeVec(
kubemetrics.GaugeOpts{
Name: "apiserver_registered_watchers",
Help: "Number of currently registered watchers for a given resources",
DeprecatedVersion: "1.15"
},
[]string{"group", "version", "kind"},
)
---
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.external.metrics.k8s.io
spec:
insecureSkipTLSVerify: true
group: external.metrics.k8s.io
groupPriorityMinimum: 100
versionPriority: 100
@logicalhan
logicalhan / fenwick_tree.py
Created October 18, 2016 04:31
binary indexed tree
class FenwickTree(object):
def __init__(self, arr):
self._one_based_indexed_arr = [0] + arr
self._bit = [0] * (len(arr)+2)
self._len = len(self._one_based_indexed_arr)
for i in range(1, len(self._one_based_indexed_arr)):
index = i
val = self._one_based_indexed_arr[i]
while index < self._len:
self._bit[index] += val
@logicalhan
logicalhan / tarjan.py
Last active September 14, 2016 06:20
tarjan's strongly connected componen
class Tarjan(object):
def __init__(self, edges):
tmp_vs = []
self.edges = edges
vertice_dict = {}
for edge in edges:
if edge[0] not in vertice_dict.keys():
vertice_dict[edge[0]] = {"id": edge[0]}
if edge[1] not in vertice_dict.keys():
vertice_dict[edge[1]] = {"id": edge[1]}
@logicalhan
logicalhan / saas_class_meta.rb
Created August 26, 2012 08:12
attr_accessor_with_history
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s
history_method_name = attr_name + "_history"
attr_reader attr_name
attr_reader history_method_name
class_eval(%Q(
def #{attr_name}=(#{attr_name})
@#{attr_name} = #{attr_name}
if @#{history_method_name}