Skip to content

Commit 5ab79dd

Browse files
lllamnypaobort
andauthored
wip: controller flow (#276)
Signed-off-by: Artem Bortnikov <[email protected]> Co-authored-by: Artem Bortnikov <[email protected]>
1 parent 3d8b85c commit 5ab79dd

File tree

6 files changed

+435
-19
lines changed

6 files changed

+435
-19
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/spf13/pflag v1.0.5
1313
github.com/spf13/viper v1.19.0
1414
go.etcd.io/etcd/client/v3 v3.5.14
15+
golang.org/x/sync v0.7.0
1516
k8s.io/api v0.30.2
1617
k8s.io/apimachinery v0.30.2
1718
k8s.io/client-go v0.30.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
190190
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
191191
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
192192
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
193+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
194+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
193195
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
194196
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
195197
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

internal/controller/etcdcluster_controller.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,29 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
102102
if client.IgnoreNotFound(err) != nil {
103103
return ctrl.Result{}, fmt.Errorf("couldn't get statefulset: %w", err)
104104
}
105-
state.stsExists = state.statefulSet.UID != ""
105+
// state.stsExists = state.statefulSet.UID != ""
106106

107107
// fetch endpoints
108108
clusterClient, singleClients, err := factory.NewEtcdClientSet(ctx, state.instance, r.Client)
109109
if err != nil {
110110
return ctrl.Result{}, err
111111
}
112-
state.endpointsFound = clusterClient != nil && singleClients != nil
112+
// state.endpointsFound = clusterClient != nil && singleClients != nil
113113

114-
if clusterClient != nil {
115-
state.endpoints = clusterClient.Endpoints()
116-
}
114+
// if clusterClient != nil {
115+
// state.endpoints = clusterClient.Endpoints()
116+
// }
117+
state.clusterClient = clusterClient
118+
state.singleClients = singleClients
117119

118120
// fetch PVCs
119121
state.pvcs, err = factory.PVCs(ctx, state.instance, r.Client)
120122
if err != nil {
121123
return ctrl.Result{}, err
122124
}
123125

124-
if !state.endpointsFound {
125-
if !state.stsExists {
126+
if !state.endpointsFound() {
127+
if !state.statefulSetExists() {
126128
return r.createClusterFromScratch(ctx, state) // TODO: needs implementing
127129
}
128130

0 commit comments

Comments
 (0)