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 misusage of k8s namespace as the pulsar namespace in FunctionDetails #259

Merged
merged 5 commits into from
Aug 18, 2021
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
5 changes: 3 additions & 2 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ const (
AtmostOnce ProcessGuarantee = "atmost_once"
EffectivelyOnce ProcessGuarantee = "effectively_once"

DefaultTenant string = "public"
DefaultCluster string = "kubernetes"
DefaultTenant string = "public"
DefaultNamespace string = "default"
DefaultCluster string = "kubernetes"
)

func validResourceRequirement(requirements corev1.ResourceRequirements) bool {
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/function_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type FunctionSpec struct {
Name string `json:"name,omitempty"`
ClassName string `json:"className,omitempty"`
Tenant string `json:"tenant,omitempty"`
Namespace string `json:"namespace,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`

Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/function_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func (r *Function) Default() {
r.Spec.Tenant = DefaultTenant
}

if r.Spec.Namespace == "" {
r.Spec.Namespace = DefaultNamespace
}

if r.Spec.MaxPendingAsyncRequests == nil {
maxPending := int32(1000)
r.Spec.MaxPendingAsyncRequests = &maxPending
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/sink_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type SinkSpec struct {
ClassName string `json:"className,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
Tenant string `json:"tenant,omitempty"`
Namespace string `json:"namespace,omitempty"`
SinkType string `json:"sinkType,omitempty"` // refer to `--sink-type` as builtin connector
Replicas *int32 `json:"replicas,omitempty"`

Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/sink_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func (r *Sink) Default() {
r.Spec.Tenant = DefaultTenant
}

if r.Spec.Namespace == "" {
r.Spec.Namespace = DefaultNamespace
}

if r.Spec.Resources.Requests != nil {
if r.Spec.Resources.Requests.Cpu() == nil {
r.Spec.Resources.Requests.Cpu().Set(int64(1))
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/source_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type SourceSpec struct {
Name string `json:"name,omitempty"`
ClassName string `json:"className,omitempty"`
Tenant string `json:"tenant,omitempty"`
Namespace string `json:"namespace,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
SourceType string `json:"sourceType,omitempty"` // refer to `--source-type` as builtin connector
Replicas *int32 `json:"replicas,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/source_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func (r *Source) Default() {
r.Spec.Tenant = DefaultTenant
}

if r.Spec.Namespace == "" {
r.Spec.Namespace = DefaultNamespace
}

if r.Spec.Resources.Requests != nil {
if r.Spec.Resources.Requests.Cpu() == nil {
r.Spec.Resources.Requests.Cpu().Set(int64(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ spec:
- type
type: object
type: array
builtinAutoscaler:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -3145,6 +3149,10 @@ spec:
- type
type: object
type: array
builtinAutoscaler:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -4944,6 +4952,8 @@ spec:
type: string
clusterName:
type: string
forwardSourceMessageProperty:
type: boolean
golang:
properties:
go:
Expand Down Expand Up @@ -5543,6 +5553,10 @@ spec:
- type
type: object
type: array
builtinAutoscaler:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ spec:
- type
type: object
type: array
builtinAutoscaler:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ spec:
- type
type: object
type: array
builtinAutoscaler:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ spec:
type: string
clusterName:
type: string
forwardSourceMessageProperty:
type: boolean
golang:
properties:
go:
Expand Down Expand Up @@ -635,6 +637,10 @@ spec:
- type
type: object
type: array
builtinAutoscaler:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down Expand Up @@ -2631,6 +2633,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
negativeAckRedeliveryDelayMs:
format: int32
type: integer
Expand Down Expand Up @@ -4979,6 +4983,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/compute.functionmesh.io_functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/compute.functionmesh.io_sinks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
negativeAckRedeliveryDelayMs:
format: int32
type: integer
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/compute.functionmesh.io_sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down
8 changes: 4 additions & 4 deletions controllers/spec/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func convertFunctionDetails(function *v1alpha1.Function) *proto.FunctionDetails

return &proto.FunctionDetails{
Tenant: function.Spec.Tenant,
Namespace: function.Namespace,
Namespace: function.Spec.Namespace,
Name: function.Spec.Name,
ClassName: function.Spec.ClassName,
LogTopic: function.Spec.LogTopic,
Expand Down Expand Up @@ -67,7 +67,7 @@ func convertGoFunctionConfs(function *v1alpha1.Function) *GoFunctionConf {
Port: int(GRPCPort.ContainerPort),
ClusterName: function.Spec.ClusterName,
Tenant: function.Spec.Tenant,
NameSpace: function.Namespace,
NameSpace: function.Spec.Namespace,
Name: function.Spec.Name,
LogTopic: function.Spec.LogTopic,
ProcessingGuarantees: int32(convertProcessingGuarantee(function.Spec.ProcessingGuarantee)),
Expand Down Expand Up @@ -204,7 +204,7 @@ func generateFunctionOutputSpec(function *v1alpha1.Function) *proto.SinkSpec {
func convertSourceDetails(source *v1alpha1.Source) *proto.FunctionDetails {
return &proto.FunctionDetails{
Tenant: source.Spec.Tenant,
Namespace: source.Namespace,
Namespace: source.Spec.Namespace,
Name: source.Name,
ClassName: "org.apache.pulsar.functions.api.utils.IdentityFunction",
ProcessingGuarantees: convertProcessingGuarantee(source.Spec.ProcessingGuarantee),
Expand Down Expand Up @@ -262,7 +262,7 @@ func generateSourceOutputSpec(source *v1alpha1.Source) *proto.SinkSpec {
func convertSinkDetails(sink *v1alpha1.Sink) *proto.FunctionDetails {
return &proto.FunctionDetails{
Tenant: sink.Spec.Tenant,
Namespace: sink.Namespace,
Namespace: sink.Spec.Namespace,
Name: sink.Name,
ClassName: "org.apache.pulsar.functions.api.utils.IdentityFunction",
ProcessingGuarantees: convertProcessingGuarantee(sink.Spec.ProcessingGuarantee),
Expand Down
12 changes: 12 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down Expand Up @@ -2629,6 +2631,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
negativeAckRedeliveryDelayMs:
format: int32
type: integer
Expand Down Expand Up @@ -4977,6 +4981,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down Expand Up @@ -7540,6 +7546,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down Expand Up @@ -10084,6 +10092,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
negativeAckRedeliveryDelayMs:
format: int32
type: integer
Expand Down Expand Up @@ -12496,6 +12506,8 @@ spec:
type: integer
name:
type: string
namespace:
type: string
output:
properties:
customSchemaSinks:
Expand Down