Skip to content

Commit

Permalink
Issue 666: Expose new port to segment store services (#667)
Browse files Browse the repository at this point in the history
* Issue 666: Expose new port to segment store services

Signed-off-by: anisha.kj <[email protected]>

* Updating bookkeeper crd to fix end to end tests

Signed-off-by: anisha.kj <[email protected]>

* Debugging e2e failure

Signed-off-by: anisha.kj <[email protected]>

* updated kubernetes version

Signed-off-by: anisha.kj <[email protected]>

* Debugging e2e tests failure

Signed-off-by: anisha.kj <[email protected]>

* Fixing compilation errors

Signed-off-by: anisha.kj <[email protected]>

* Fixing compilation errors

Signed-off-by: anisha.kj <[email protected]>

* Fixing compilation errors

Signed-off-by: anisha.kj <[email protected]>

* Fixing compilation errors

Signed-off-by: anisha.kj <[email protected]>

* Updating crd to fix e2e issue

Signed-off-by: anisha.kj <[email protected]>

* Adding back cluster deletion

Signed-off-by: anisha.kj <[email protected]>

* Addressing review comments

Signed-off-by: anisha.kj <[email protected]>

* Addressing review comments

Signed-off-by: anisha.kj <[email protected]>

---------

Signed-off-by: anisha.kj <[email protected]>
  • Loading branch information
anishakj authored Aug 14, 2023
1 parent aac1646 commit eaf431a
Show file tree
Hide file tree
Showing 5 changed files with 893 additions and 167 deletions.
17 changes: 17 additions & 0 deletions controllers/pravega_segmentstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ func MakeSegmentstoreConfigMap(p *api.PravegaCluster) *corev1.ConfigMap {
p.Spec.Pravega.Options["pravegaservice.service.listener.port"] = "12345"
}

if _, ok := p.Spec.Pravega.Options["pravegaservice.admin.listener.port"]; !ok {
p.Spec.Pravega.Options["pravegaservice.admin.listener.port"] = "9999"
}

javaOpts = util.OverrideDefaultJVMOptions(javaOpts, p.Spec.Pravega.SegmentStoreJVMOptions)

for name, value := range p.Spec.Pravega.Options {
Expand Down Expand Up @@ -519,6 +523,7 @@ func configureInfluxDBSecret(podSpec *corev1.PodSpec, p *api.PravegaCluster) {

func MakeSegmentStoreHeadlessService(p *api.PravegaCluster) *corev1.Service {
serviceport, _ := strconv.Atoi(p.Spec.Pravega.Options["pravegaservice.service.listener.port"])
adminPort, _ := strconv.Atoi(p.Spec.Pravega.Options["pravegaservice.admin.listener.port"])
return &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
Expand All @@ -536,6 +541,11 @@ func MakeSegmentStoreHeadlessService(p *api.PravegaCluster) *corev1.Service {
Port: int32(serviceport),
Protocol: "TCP",
},
{
Name: "cli",
Port: int32(adminPort),
Protocol: "TCP",
},
},
Selector: p.LabelsForSegmentStore(),
ClusterIP: corev1.ClusterIPNone,
Expand Down Expand Up @@ -582,6 +592,7 @@ func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service {
serviceType := getSSServiceType(p)
services := make([]*corev1.Service, p.Spec.Pravega.SegmentStoreReplicas)
serviceport, _ := strconv.Atoi(p.Spec.Pravega.Options["pravegaservice.service.listener.port"])
adminPort, _ := strconv.Atoi(p.Spec.Pravega.Options["pravegaservice.admin.listener.port"])
for i := int32(0); i < p.Spec.Pravega.SegmentStoreReplicas; i++ {
ssPodName := p.ServiceNameForSegmentStore(i)
annotationMap := p.Spec.Pravega.SegmentStoreServiceAnnotations
Expand Down Expand Up @@ -610,6 +621,12 @@ func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service {
Protocol: "TCP",
TargetPort: intstr.FromInt(serviceport),
},
{
Name: "cli",
Port: int32(adminPort),
Protocol: "TCP",
TargetPort: intstr.FromInt(adminPort),
},
},
ExternalTrafficPolicy: corev1.ServiceExternalTrafficPolicyTypeLocal,
Selector: map[string]string{
Expand Down
30 changes: 26 additions & 4 deletions controllers/pravegacluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,24 @@ func (r *PravegaClusterReconciler) reconcileSegmentStoreService(p *pravegav1beta
}
}
} else {

updateService := false
if currentService.Spec.Ports[0].Port != headlessService.Spec.Ports[0].Port {
currentService.Spec.Ports[0].Port = headlessService.Spec.Ports[0].Port
currentService.Spec.Ports[0].TargetPort = headlessService.Spec.Ports[0].TargetPort
updateService = true
}
if len(currentService.Spec.Ports) == 1 {
currentService.Spec.Ports = append(currentService.Spec.Ports, headlessService.Spec.Ports[1])
updateService = true
} else if currentService.Spec.Ports[1].Port != headlessService.Spec.Ports[1].Port {
currentService.Spec.Ports[1].Port = headlessService.Spec.Ports[1].Port
currentService.Spec.Ports[1].TargetPort = headlessService.Spec.Ports[1].TargetPort
updateService = true
}
if updateService {
err = r.Client.Update(context.TODO(), currentService)
if err != nil {
return fmt.Errorf("failed to update headless service port (%s): %v", currentService.Name, err)
return fmt.Errorf("failed to update headless service ports (%s): %v", currentService.Name, err)
}
}
}
Expand All @@ -450,15 +461,26 @@ func (r *PravegaClusterReconciler) reconcileSegmentStoreService(p *pravegav1beta
}
}
} else {
updateService := false
if service.Spec.Ports[0].Port != currentservice.Spec.Ports[0].Port {
currentservice.Spec.Ports[0].Port = service.Spec.Ports[0].Port
currentservice.Spec.Ports[0].TargetPort = service.Spec.Ports[0].TargetPort
updateService = true
}
if len(currentservice.Spec.Ports) == 1 {
currentservice.Spec.Ports = append(currentservice.Spec.Ports, service.Spec.Ports[1])
updateService = true
} else if service.Spec.Ports[1].Port != currentservice.Spec.Ports[1].Port {
currentservice.Spec.Ports[1].Port = service.Spec.Ports[1].Port
currentservice.Spec.Ports[1].TargetPort = service.Spec.Ports[1].TargetPort
updateService = true
}
if updateService {
err = r.Client.Update(context.TODO(), currentservice)
if err != nil {
return fmt.Errorf("failed to update external service port (%s): %v", currentservice.Name, err)
return fmt.Errorf("failed to update external service ports (%s): %v", currentservice.Name, err)
}
}

eq := reflect.DeepEqual(currentservice.Annotations["external-dns.alpha.kubernetes.io/hostname"], service.Annotations["external-dns.alpha.kubernetes.io/hostname"])
if !eq {
err := r.Client.Delete(context.TODO(), currentservice)
Expand Down
72 changes: 40 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ go 1.20
require (
github.com/hashicorp/go-version v1.2.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.17.0
github.com/operator-framework/operator-lib v0.7.0
github.com/pravega/bookkeeper-operator v0.1.8
github.com/pravega/zookeeper-operator v0.2.14
github.com/onsi/gomega v1.19.0
github.com/operator-framework/operator-lib v0.11.0
github.com/pravega/bookkeeper-operator v0.1.9
github.com/pravega/zookeeper-operator v0.2.15
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414
github.com/sirupsen/logrus v1.8.1
k8s.io/api v0.23.5
k8s.io/apimachinery v0.23.5
k8s.io/client-go v0.23.5
sigs.k8s.io/controller-runtime v0.11.0
k8s.io/api v0.24.1
k8s.io/apimachinery v0.24.1
k8s.io/client-go v0.24.1
sigs.k8s.io/controller-runtime v0.12.1
)

require (
Expand All @@ -26,55 +26,63 @@ require (
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/emicklei/go-restful v2.16.0+incompatible // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/zapr v1.2.0 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.11.1 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.28.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiextensions-apiserver v0.23.0 // indirect
k8s.io/component-base v0.23.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.1 // indirect
k8s.io/component-base v0.24.1 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220413171646-5e7f5fdc6da6 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit eaf431a

Please sign in to comment.