Skip to content

Commit 58f1cda

Browse files
oskarszoongalt-tr
andauthored
Add Teranode's new pruner service (#25)
* Add pruner service * Switch peer to single container pattern * Add boilerplate * Update tests for pruner * Fix generation --------- Co-authored-by: Dylan <64976002+galt-tr@users.noreply.github.com> Co-authored-by: Dylan Murray <dylan@britevue.com>
1 parent 93858ff commit 58f1cda

32 files changed

Lines changed: 53737 additions & 46872 deletions

api/v1alpha1/cluster_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ type ValidatorConfig struct {
112112
Spec *ValidatorSpec `json:"spec"`
113113
}
114114

115+
// PrunerConfig defines the pruner configuration
116+
type PrunerConfig struct {
117+
Enabled bool `json:"enabled"`
118+
Spec *PrunerSpec `json:"spec"`
119+
}
120+
115121
// ClusterSpec defines the desired state of Cluster
116122
type ClusterSpec struct {
117123
AlertSystem AlertSystemConfig `json:"alertSystem"`
@@ -129,6 +135,7 @@ type ClusterSpec struct {
129135
SubtreeValidator SubtreeValidatorConfig `json:"subtreeValidator"`
130136
UtxoPersister UtxoPersisterConfig `json:"utxoPersister"`
131137
Validator ValidatorConfig `json:"validator"`
138+
Pruner PrunerConfig `json:"pruner"`
132139

133140
ConfigMapName string `json:"configMapName"`
134141
Env []corev1.EnvVar `json:"env,omitempty"`

api/v1alpha1/pruner_types.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// PrunerSpec defines the desired state of Pruner
24+
type PrunerSpec struct {
25+
DeploymentOverrides *DeploymentOverrides `json:"deploymentOverrides,omitempty"`
26+
}
27+
28+
// PrunerStatus defines the observed state of Pruner
29+
type PrunerStatus struct {
30+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
31+
// Important: Run "make" to regenerate code after modifying this file
32+
Conditions []metav1.Condition `json:"conditions,omitempty"`
33+
}
34+
35+
//+kubebuilder:object:root=true
36+
//+kubebuilder:subresource:status
37+
38+
// Pruner is the Schema for the pruners API
39+
type Pruner struct {
40+
metav1.TypeMeta `json:",inline"`
41+
metav1.ObjectMeta `json:"metadata,omitempty"`
42+
43+
Spec PrunerSpec `json:"spec,omitempty"`
44+
Status PrunerStatus `json:"status,omitempty"`
45+
}
46+
47+
func (p *Pruner) DeploymentOverrides() *DeploymentOverrides {
48+
return p.Spec.DeploymentOverrides
49+
}
50+
51+
func (p *Pruner) Metadata() metav1.ObjectMeta {
52+
return p.ObjectMeta
53+
}
54+
55+
//+kubebuilder:object:root=true
56+
57+
// PrunerList contains a list of Pruner
58+
type PrunerList struct {
59+
metav1.TypeMeta `json:",inline"`
60+
metav1.ListMeta `json:"metadata,omitempty"`
61+
62+
Items []Pruner `json:"items"`
63+
}
64+
65+
func init() {
66+
SchemeBuilder.Register(&Pruner{}, &PrunerList{})
67+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 142 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ func main() {
260260
setupLog.Error(err, "unable to create controller", "controller", "AlertSystem")
261261
os.Exit(1)
262262
}
263+
if err = (&controller.PrunerReconciler{
264+
Client: mgr.GetClient(),
265+
Scheme: mgr.GetScheme(),
266+
}).SetupWithManager(mgr); err != nil {
267+
setupLog.Error(err, CreateControllerError, "controller", "Pruner")
268+
os.Exit(1)
269+
}
263270
//+kubebuilder:scaffold:builder
264271

265272
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

0 commit comments

Comments
 (0)