Skip to content

Commit

Permalink
fix: init service config
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito committed Jan 25, 2024
1 parent bd44fc9 commit 875b117
Show file tree
Hide file tree
Showing 45 changed files with 128 additions and 45 deletions.
5 changes: 4 additions & 1 deletion pkg/manager/component/ansibleserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type ansibleManager struct {
Expand Down Expand Up @@ -61,7 +62,9 @@ func (m *ansibleManager) getPhaseControl(man controller.ComponentManager, zone s
}

func (m *ansibleManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewAnsibleServer().GetConfig(oc, cfg)
opt, err := component.NewAnsibleServer().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/apigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type apiGatewayManager struct {
Expand Down Expand Up @@ -63,7 +64,9 @@ func (m *apiGatewayManager) getPhaseControl(man controller.ComponentManager, zon
}

func (m *apiGatewayManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewApiGateway().GetConfig(oc, cfg)
opt, err := component.NewApiGateway().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/apimap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type apiMapManager struct {
Expand Down Expand Up @@ -55,7 +56,9 @@ func (m *apiMapManager) getPhaseControl(man controller.ComponentManager, zone st
}

func (m *apiMapManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewAPIMap().GetConfig(oc, cfg)
opt, err := component.NewAPIMap().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, errors.Wrap(err, "apimap: SetOptionsDefault")
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/cloudid.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type cloudidManager struct {
Expand Down Expand Up @@ -60,7 +61,9 @@ func (m *cloudidManager) getPhaseControl(man controller.ComponentManager, zone s
}

func (m *cloudidManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewCloudId().GetConfig(oc, cfg)
opt, err := component.NewCloudId().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/cloudmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type cloudmonManager struct {
Expand Down Expand Up @@ -64,7 +65,9 @@ func (m *cloudmonManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1a
}

func (m *cloudmonManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewCloudmon().GetConfig(oc, cfg)
opt, err := component.NewCloudmon().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/esxi.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type esxiManager struct {
Expand Down Expand Up @@ -58,7 +59,9 @@ func (m *esxiManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha
}

func (m *esxiManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
optObj, err := component.NewEsxiAgent().GetConfig(oc, cfg)
optObj, err := component.NewEsxiAgent().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/glance.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

var s3ConfigSynced bool
Expand Down Expand Up @@ -86,7 +87,9 @@ func (m *glanceManager) getService(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.O
}

func (m *glanceManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
optObj, err := component.NewGlance().GetConfig(oc, cfg)
optObj, err := component.NewGlance().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type influxdbManager struct {
Expand Down Expand Up @@ -65,7 +66,9 @@ func (m *influxdbManager) getPVC(oc *v1alpha1.OnecloudCluster, zone string) (*co
}

func (m *influxdbManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
content, err := component.NewInfluxdb().GetConfig(oc, cfg)
content, err := component.NewInfluxdb().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/keystone.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type keystoneManager struct {
Expand Down Expand Up @@ -81,7 +82,9 @@ func (m *keystoneManager) getService(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1
}

func (m *keystoneManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewKeystone().GetConfig(oc, cfg)
opt, err := component.NewKeystone().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/kubeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type kubeManager struct {
Expand Down Expand Up @@ -66,7 +67,9 @@ func (m *kubeManager) getPhaseControl(man controller.ComponentManager, zone stri
}

func (m *kubeManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewKubeserver().GetConfig(oc, cfg)
opt, err := component.NewKubeserver().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type loggerManager struct {
Expand Down Expand Up @@ -66,7 +67,9 @@ func (m *loggerManager) getPhaseControl(man controller.ComponentManager, zone st
}

func (m *loggerManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewLogger().GetConfig(oc, cfg)
opt, err := component.NewLogger().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type monitorManager struct {
Expand Down Expand Up @@ -65,7 +66,9 @@ func (m *monitorManager) getPhaseControl(man controller.ComponentManager, zone s
}

func (m *monitorManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewMonitor().GetConfig(oc, cfg)
opt, err := component.NewMonitor().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type notifyManager struct {
Expand Down Expand Up @@ -67,7 +68,9 @@ func (m *notifyManager) getPhaseControl(man controller.ComponentManager, zone st
}

func (m *notifyManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewNotify().GetConfig(oc, cfg)
opt, err := component.NewNotify().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, errors.Wrap(err, "set notify option")
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type regionManager struct {
Expand Down Expand Up @@ -68,7 +69,9 @@ func (m *regionManager) getPhaseControl(man controller.ComponentManager, zone st
}

func (m *regionManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewRegion().GetConfig(oc, cfg)
opt, err := component.NewRegion().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/scheduledtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type scheduledtaskManager struct {
Expand Down Expand Up @@ -44,7 +45,9 @@ func (m *scheduledtaskManager) getService(oc *v1alpha1.OnecloudCluster, cfg *v1a
}

func (m *scheduledtaskManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewScheduledTask().GetConfig(oc, cfg)
opt, err := component.NewScheduledTask().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type schedulerManager struct {
Expand Down Expand Up @@ -56,7 +57,9 @@ func (m *schedulerManager) getPhaseControl(man controller.ComponentManager, zone
}

func (m *schedulerManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewScheduler().GetConfig(oc, cfg)
opt, err := component.NewScheduler().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, errors.Wrap(err, "scheduler: SetOptionsDefault")
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/manager/component/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"context"
"encoding/json"
"fmt"
"path"
"reflect"

"github.com/pkg/errors"
apps "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1beta1"
Expand All @@ -29,8 +32,6 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/klog"
"path"
"reflect"

"yunion.io/x/onecloud-operator/pkg/apis/constants"
"yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1"
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type webManager struct {
Expand Down Expand Up @@ -273,7 +274,9 @@ func (m *webManager) updateIngress(oc *v1alpha1.OnecloudCluster, oldIng *unstruc
}

func (m *webManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
content, err := component.NewWeb().GetConfig(oc, cfg)
content, err := component.NewWeb().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/webconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type webconsoleManager struct {
Expand Down Expand Up @@ -67,7 +68,9 @@ func (m *webconsoleManager) getPhaseControl(man controller.ComponentManager, zon
}

func (m *webconsoleManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewWebconsole().GetConfig(oc, cfg)
opt, err := component.NewWebconsole().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/manager/component/yunionconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"yunion.io/x/onecloud-operator/pkg/controller"
"yunion.io/x/onecloud-operator/pkg/manager"
"yunion.io/x/onecloud-operator/pkg/service-init/component"
"yunion.io/x/onecloud-operator/pkg/util/onecloud"
)

type yunoinconfManager struct {
Expand Down Expand Up @@ -61,7 +62,9 @@ func (m *yunoinconfManager) getPhaseControl(man controller.ComponentManager, zon
}

func (m *yunoinconfManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, zone string) (*corev1.ConfigMap, bool, error) {
opt, err := component.NewYunionconf().GetConfig(oc, cfg)
opt, err := component.NewYunionconf().GetConfig(oc, cfg, func(service string, opts map[string]interface{}) {
onecloud.InitServiceConfig(service, oc.Spec.Region, opts)
})
if err != nil {
return nil, false, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/service-init/component/ansibleserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (r ansibleServer) BuildClusterConfigCloudUser(clsCfg *v1alpha1.OnecloudClus
return nil
}

func (r ansibleServer) GetConfig(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (interface{}, error) {
func (r ansibleServer) GetConfig(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, initServiceConfig func(service string, opts map[string]interface{})) (interface{}, error) {
opt := &options.Options
if err := option.SetOptionsDefault(opt, constants.ServiceTypeAnsibleServer); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/service-init/component/apigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (a apiGateway) BuildClusterConfigCloudUser(clsCfg *v1alpha1.OnecloudCluster
return nil
}

func (a apiGateway) GetConfig(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (interface{}, error) {
func (a apiGateway) GetConfig(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig, initServiceConfig func(service string, opts map[string]interface{})) (interface{}, error) {
opt := &ApiOptions{}
if err := option.SetOptionsDefault(opt, "apigateway"); err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 875b117

Please sign in to comment.