Skip to content

Commit b1641fe

Browse files
committed
refactor: all components can be compiled successfully
1 parent f6c8ba2 commit b1641fe

File tree

34 files changed

+482
-140
lines changed

34 files changed

+482
-140
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<a href="https://konglingfei.com/"><img align="right" src="./docs/images/onex-orange.svg" alt="onex" title="onex" width="150"></a>
1010

1111
<div align="left">一个专为 Go + 云原生学习而生的企业级 Go 项目</div>
12+
13+
<br/>
14+
15+
> OneX 技术栈项目之一,更多精彩项目见:[OneX 技术栈全景介绍](https://github.com/onexstack/community)
16+
1217
<br/>
1318

1419
[![GoDoc](https://godoc.org/github.com/onexstack/onex?status.svg)](https://godoc.org/github.com/onexstack/onex)

cmd/onex-apiserver/app/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Config struct {
2020
Options options.CompletedOptions
2121

2222
Aggregator *aggregatorapiserver.Config
23-
ControlPlane *controlplane.Config
23+
KubeAPIs *controlplane.Config
2424
ApiExtensions *apiextensionsapiserver.Config
2525

2626
ExtraConfig
@@ -32,7 +32,7 @@ type completedConfig struct {
3232
Options options.CompletedOptions
3333

3434
Aggregator aggregatorapiserver.CompletedConfig
35-
ControlPlane controlplane.CompletedConfig
35+
KubeAPIs controlplane.CompletedConfig
3636
ApiExtensions apiextensionsapiserver.CompletedConfig
3737

3838
ExtraConfig
@@ -48,7 +48,7 @@ func (c *Config) Complete() (CompletedConfig, error) {
4848
Options: c.Options,
4949

5050
Aggregator: c.Aggregator.Complete(),
51-
ControlPlane: c.ControlPlane.Complete(),
51+
KubeAPIs: c.KubeAPIs.Complete(),
5252
ApiExtensions: c.ApiExtensions.Complete(),
5353

5454
ExtraConfig: c.ExtraConfig,
@@ -65,7 +65,7 @@ func NewConfig(opts options.CompletedOptions) (*Config, error) {
6565
if err != nil {
6666
return nil, err
6767
}
68-
c.ControlPlane = controlPlane
68+
c.KubeAPIs = controlPlane
6969

7070
apiExtensions, err := apiserver.CreateAPIExtensionsConfig(
7171
controlPlane.GenericConfig.Config,

cmd/onex-apiserver/app/server.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ import (
5555
"github.com/onexstack/onexstack/pkg/version"
5656
)
5757

58-
const appName = "onex-apiserver"
59-
6058
func init() {
6159
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
6260
}
@@ -143,7 +141,7 @@ func NewAPIServerCommand(serverRunOptions ...Option) *cobra.Command {
143141
}
144142

145143
cmd := &cobra.Command{
146-
Use: appName,
144+
Use: "onex-apiserver",
147145
Short: "Launch a onex API server",
148146
Long: `The OneX API server validates and configures data
149147
for the api objects which include miners, minersets, configmaps, and
@@ -240,14 +238,14 @@ func Run(ctx context.Context, opts options.CompletedOptions) error {
240238

241239
// CreateServerChain creates the apiservers connected via delegation.
242240
func CreateServerChain(config CompletedConfig) (*aggregatorapiserver.APIAggregator, error) {
243-
notFoundHandler := notfoundhandler.New(config.ControlPlane.GenericConfig.Serializer, genericapifilters.NoMuxAndDiscoveryIncompleteKey)
241+
notFoundHandler := notfoundhandler.New(config.KubeAPIs.GenericConfig.Serializer, genericapifilters.NoMuxAndDiscoveryIncompleteKey)
244242
apiExtensionsServer, err := config.ApiExtensions.New(genericapiserver.NewEmptyDelegateWithCustomHandler(notFoundHandler))
245243
if err != nil {
246244
return nil, err
247245
}
248246
crdAPIEnabled := config.ApiExtensions.GenericConfig.MergedResourceConfig.ResourceEnabled(apiextensionsv1.SchemeGroupVersion.WithResource("customresourcedefinitions"))
249247

250-
onexAPIServer, err := config.ControlPlane.New(apiExtensionsServer.GenericAPIServer)
248+
onexAPIServer, err := config.KubeAPIs.New(apiExtensionsServer.GenericAPIServer)
251249
if err != nil {
252250
return nil, err
253251
}

cmd/onex-controller-manager/app/controllermanager.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ import (
6666
"github.com/onexstack/onex/internal/pkg/util/ratelimiter"
6767
"github.com/onexstack/onex/internal/webhooks"
6868
v1beta1 "github.com/onexstack/onex/pkg/apis/apps/v1beta1"
69-
"github.com/onexstack/onexstack/pkg/db"
7069
"github.com/onexstack/onex/pkg/record"
70+
"github.com/onexstack/onexstack/pkg/db"
7171
"github.com/onexstack/onexstack/pkg/version"
7272
)
7373

74-
const appName = "onex-controller-manager"
75-
7674
var scheme = runtime.NewScheme()
7775

7876
func init() {
@@ -102,7 +100,7 @@ func NewControllerManagerCommand() *cobra.Command {
102100
}
103101

104102
cmd := &cobra.Command{
105-
Use: appName,
103+
Use: "onex-controller-manager",
106104
Long: `The onex controller manager is a daemon that embeds
107105
the core control loops. In applications of robotics and
108106
automation, a control loop is a non-terminating loop that regulates the state of
@@ -117,7 +115,7 @@ current state towards the desired state.`,
117115
return nil
118116
},
119117
RunE: func(cmd *cobra.Command, args []string) error {
120-
version.PrintAndExitIfRequested(appName)
118+
version.PrintAndExitIfRequested()
121119

122120
// Activate logging as soon as possible, after that
123121
// show flags with the final logging configuration.

cmd/onex-controller-manager/app/core.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,12 @@ func startGarbageCollectorController(ctx context.Context, cctx ControllerContext
163163

164164
// Start the garbage collector.
165165
workers := int(cctx.Config.ComponentConfig.GarbageCollectorController.ConcurrentGCSyncs)
166-
go garbageCollector.Run(ctx, workers)
166+
const syncPeriod = 30 * time.Second
167+
go garbageCollector.Run(ctx, workers, syncPeriod)
167168

168169
// Periodically refresh the RESTMapper with new discovery information and sync
169170
// the garbage collector.
170-
go garbageCollector.Sync(ctx, discoveryClient, 30*time.Second)
171+
go garbageCollector.Sync(ctx, discoveryClient, syncPeriod)
171172

172173
return true, nil
173174
}

cmd/onex-miner-controller/app/controller.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ import (
3939
"github.com/onexstack/onex/internal/pkg/util/ratelimiter"
4040
"github.com/onexstack/onex/pkg/apis/apps/v1beta1"
4141
"github.com/onexstack/onex/pkg/apis/apps/v1beta1/index"
42-
"github.com/onexstack/onexstack/pkg/db"
4342
"github.com/onexstack/onex/pkg/record"
43+
"github.com/onexstack/onexstack/pkg/db"
4444
"github.com/onexstack/onexstack/pkg/version"
4545
)
4646

47-
const appName = "onex-miner-controller"
48-
4947
func init() {
5048
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
5149
utilruntime.Must(features.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
@@ -60,7 +58,7 @@ func NewControllerCommand() *cobra.Command {
6058
}
6159

6260
cmd := &cobra.Command{
63-
Use: appName,
61+
Use: "onex-miner-controller",
6462
Long: `The cloud miner controller is a daemon that embeds
6563
the core control loops. In applications of robotics and
6664
automation, a control loop is a non-terminating loop that regulates the state of
@@ -75,7 +73,7 @@ current state towards the desired state.`,
7573
return nil
7674
},
7775
RunE: func(cmd *cobra.Command, args []string) error {
78-
version.PrintAndExitIfRequested(appName)
76+
version.PrintAndExitIfRequested()
7977

8078
// Activate logging as soon as possible, after that
8179
// show flags with the final logging configuration.

cmd/onex-minerset-controller/app/controller.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ import (
4040
"github.com/onexstack/onexstack/pkg/version"
4141
)
4242

43-
const appName = "onex-minerset-controller"
44-
4543
func init() {
4644
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
4745
utilruntime.Must(features.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
@@ -56,7 +54,7 @@ func NewControllerCommand() *cobra.Command {
5654
}
5755

5856
cmd := &cobra.Command{
59-
Use: appName,
57+
Use: "onex-minerset-controller",
6058
Long: `The minerset controller is a daemon that embeds
6159
the core control loops. In applications of robotics and
6260
automation, a control loop is a non-terminating loop that regulates the state of
@@ -71,7 +69,7 @@ current state towards the desired state.`,
7169
return nil
7270
},
7371
RunE: func(cmd *cobra.Command, args []string) error {
74-
version.PrintAndExitIfRequested(appName)
72+
version.PrintAndExitIfRequested()
7573

7674
// Activate logging as soon as possible, after that
7775
// show flags with the final logging configuration.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ require (
6868
gorm.io/gorm v1.25.12
6969
k8s.io/api v0.32.1
7070
k8s.io/apiextensions-apiserver v0.32.1
71-
k8s.io/apimachinery v0.32.1
71+
k8s.io/apimachinery v0.32.2
7272
k8s.io/apiserver v0.32.1
7373
k8s.io/cli-runtime v0.32.1
74-
k8s.io/client-go v0.32.1
74+
k8s.io/client-go v0.32.2
7575
k8s.io/code-generator v0.32.1
76-
k8s.io/component-base v0.32.1
76+
k8s.io/component-base v0.32.2
7777
k8s.io/controller-manager v0.32.1
7878
k8s.io/klog/v2 v2.130.1
7979
k8s.io/kube-aggregator v0.0.0

internal/controller/resourceclean/cleaner_chain.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ import (
2222
type Chain struct {
2323
mu sync.Mutex
2424
client client.Client
25-
ds store.IStore
25+
store store.IStore
2626
}
2727

2828
func (c *Chain) Name() string {
2929
return "chain"
3030
}
3131

32-
func (c *Chain) Initialize(client client.Client, ds store.IStore) {
32+
func (c *Chain) Initialize(client client.Client, store store.IStore) {
3333
c.client = client
34-
c.ds = ds
34+
c.store = store
3535
}
3636

3737
func (c *Chain) Delete(ctx context.Context) error {
3838
c.mu.Lock()
3939
defer c.mu.Unlock()
4040

4141
klog.V(4).InfoS("Cleanup chains from chain table")
42-
_, chains, err := c.ds.Chains().List(ctx, nil)
42+
_, chains, err := c.store.Chain().List(ctx, nil)
4343
if err != nil {
4444
klog.ErrorS(err, "Failed to list chains")
4545
return err
@@ -51,7 +51,7 @@ func (c *Chain) Delete(ctx context.Context) error {
5151
key := client.ObjectKey{Namespace: chain.Namespace, Name: chain.Name}
5252
if err := c.client.Get(ctx, key, &ch); err != nil {
5353
if apierrors.IsNotFound(err) {
54-
if derr := c.ds.Chains().Delete(ctx, where.F("namespace", chain.Namespace, "name", chain.Name)); derr != nil {
54+
if derr := c.store.Chain().Delete(ctx, where.F("namespace", chain.Namespace, "name", chain.Name)); derr != nil {
5555
klog.V(1).InfoS("Failed to delete chain", "chain", klog.KRef(chain.Namespace, chain.Name), "err", derr)
5656
continue
5757
}

internal/controller/resourceclean/cleaner_miner.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ import (
2222
type Miner struct {
2323
mu sync.Mutex
2424
client client.Client
25-
ds store.IStore
25+
store store.IStore
2626
}
2727

2828
func (c *Miner) Name() string {
2929
return "miner"
3030
}
3131

32-
func (c *Miner) Initialize(client client.Client, ds store.IStore) {
32+
func (c *Miner) Initialize(client client.Client, store store.IStore) {
3333
c.client = client
34-
c.ds = ds
34+
c.store = store
3535
}
3636

3737
func (c *Miner) Delete(ctx context.Context) error {
3838
c.mu.Lock()
3939
defer c.mu.Unlock()
4040

4141
klog.V(4).InfoS("Cleanup miners from miner table")
42-
_, miners, err := c.ds.Miners().List(ctx, nil)
42+
_, miners, err := c.store.Miner().List(ctx, nil)
4343
if err != nil {
4444
klog.ErrorS(err, "Failed to list miners")
4545
return err
@@ -51,7 +51,7 @@ func (c *Miner) Delete(ctx context.Context) error {
5151
key := client.ObjectKey{Namespace: miner.Namespace, Name: miner.Name}
5252
if err := c.client.Get(ctx, key, &m); err != nil {
5353
if apierrors.IsNotFound(err) {
54-
if derr := c.ds.Miners().Delete(ctx, where.F("namespace", miner.Namespace, "name", miner.Name)); derr != nil {
54+
if derr := c.store.Miner().Delete(ctx, where.F("namespace", miner.Namespace, "name", miner.Name)); derr != nil {
5555
klog.V(1).InfoS("Failed to delete miner", "miner", klog.KRef(miner.Namespace, miner.Name), "err", derr)
5656
continue
5757
}

0 commit comments

Comments
 (0)