Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix bugs of nil-ptr #22

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require (
k8s.io/component-base v0.29.0 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/kubectl v0.29.0
k8s.io/kubectl v0.29.0 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
12 changes: 4 additions & 8 deletions internal/controller/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controller
import (
"context"
"fmt"

stackv1alpha1 "github.com/zncdata-labs/spark-k8s-operator/api/v1alpha1"
"github.com/zncdata-labs/spark-k8s-operator/internal/common"
corev1 "k8s.io/api/core/v1"
Expand All @@ -25,8 +26,7 @@ func NewConfigMap(
mergedCfg *stackv1alpha1.RoleGroupSpec,
) *ConfigMapReconciler {
return &ConfigMapReconciler{
ConfigurationStyleReconciler: *common.NewConfigurationStyleReconciler[*stackv1alpha1.SparkHistoryServer,
*stackv1alpha1.RoleGroupSpec](
ConfigurationStyleReconciler: *common.NewConfigurationStyleReconciler(
scheme,
instance,
client,
Expand Down Expand Up @@ -79,15 +79,11 @@ func (c *ConfigMapReconciler) makeSparkConfigData(ctx context.Context) (*string,
}
//make event log data
if eventLogCfg := c.makeEventLogConfig(); eventLogCfg != nil {
if eventLogCfg != nil {
cfgContent += *eventLogCfg
}
cfgContent += *eventLogCfg
}
// make history data
if historyCfg := c.makeHistoryConfig(); historyCfg != nil {
if historyCfg != nil {
cfgContent += *historyCfg
}
cfgContent += *historyCfg
}
return &cfgContent, nil
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/depoloyment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"

stackv1alpha1 "github.com/zncdata-labs/spark-k8s-operator/api/v1alpha1"
"github.com/zncdata-labs/spark-k8s-operator/internal/common"
appsv1 "k8s.io/api/apps/v1"
Expand All @@ -27,8 +28,7 @@ func NewDeployment(

) *DeploymentReconciler {
return &DeploymentReconciler{
DeploymentStyleReconciler: *common.NewDeploymentStyleReconciler[*stackv1alpha1.SparkHistoryServer,
*stackv1alpha1.RoleGroupSpec](
DeploymentStyleReconciler: *common.NewDeploymentStyleReconciler(
scheme,
instance,
client,
Expand Down
10 changes: 6 additions & 4 deletions internal/controller/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"

stackv1alpha1 "github.com/zncdata-labs/spark-k8s-operator/api/v1alpha1"
"github.com/zncdata-labs/spark-k8s-operator/internal/common"
v1 "k8s.io/api/networking/v1"
Expand All @@ -23,8 +24,7 @@ func NewIngress(
mergedCfg *stackv1alpha1.RoleGroupSpec,
) *IngressReconciler {
return &IngressReconciler{
GeneralResourceStyleReconciler: *common.NewGeneraResourceStyleReconciler[*stackv1alpha1.SparkHistoryServer,
*stackv1alpha1.RoleGroupSpec](
GeneralResourceStyleReconciler: *common.NewGeneraResourceStyleReconciler(
scheme,
instance,
client,
Expand Down Expand Up @@ -77,8 +77,10 @@ func (i *IngressReconciler) Build(_ context.Context) (client.Object, error) {
func (i *IngressReconciler) getIngressSpec() *stackv1alpha1.IngressSpec {
spec := i.Instance.Spec.ClusterConfig.Ingress
if spec == nil {
spec.Host = "spark-history-server.example.com"
spec.Enabled = true
spec = &stackv1alpha1.IngressSpec{
Host: "spark-history-server.example.com",
Enabled: true,
}
}
return spec
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"

stackv1alpha1 "github.com/zncdata-labs/spark-k8s-operator/api/v1alpha1"
"github.com/zncdata-labs/spark-k8s-operator/internal/common"
corev1 "k8s.io/api/core/v1"
Expand All @@ -25,8 +26,7 @@ func NewPvc(
mergedCfg *stackv1alpha1.RoleGroupSpec,
) *PvcReconciler {
return &PvcReconciler{
GeneralResourceStyleReconciler: *common.NewGeneraResourceStyleReconciler[*stackv1alpha1.SparkHistoryServer,
*stackv1alpha1.RoleGroupSpec](
GeneralResourceStyleReconciler: *common.NewGeneraResourceStyleReconciler(
scheme,
instance,
client,
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"

stackv1alpha1 "github.com/zncdata-labs/spark-k8s-operator/api/v1alpha1"
"github.com/zncdata-labs/spark-k8s-operator/internal/common"
corev1 "k8s.io/api/core/v1"
Expand All @@ -25,8 +26,7 @@ func NewSecret(

) *SecretReconciler {
return &SecretReconciler{
ConfigurationStyleReconciler: *common.NewConfigurationStyleReconciler[*stackv1alpha1.SparkHistoryServer,
*stackv1alpha1.RoleGroupSpec](
ConfigurationStyleReconciler: *common.NewConfigurationStyleReconciler(
scheme,
instance,
client,
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"

stackv1alpha1 "github.com/zncdata-labs/spark-k8s-operator/api/v1alpha1"
"github.com/zncdata-labs/spark-k8s-operator/internal/common"
corev1 "k8s.io/api/core/v1"
Expand All @@ -25,8 +26,7 @@ func NewService(

) *ServiceReconciler {
return &ServiceReconciler{
GeneralResourceStyleReconciler: *common.NewGeneraResourceStyleReconciler[*stackv1alpha1.SparkHistoryServer,
*stackv1alpha1.RoleGroupSpec](
GeneralResourceStyleReconciler: *common.NewGeneraResourceStyleReconciler(
scheme,
instance,
client,
Expand Down
6 changes: 4 additions & 2 deletions internal/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ func createIngName(instanceName string, groupName string) string {
func getServiceSpec(instance *stackv1alpha1.SparkHistoryServer) *stackv1alpha1.ListenerSpec {
spec := instance.Spec.ClusterConfig.Listener
if spec == nil {
spec.Type = "ClusterIP"
spec.Port = 9083
spec = &stackv1alpha1.ListenerSpec{
Type: "ClusterIP",
Port: 9083,
}
}
return spec
}
Loading