Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d38ca4c
API
grac3gao Dec 6, 2019
e95fb2f
API-2
grac3gao Dec 7, 2019
610ac33
API-3
grac3gao Dec 11, 2019
183fbf6
Controller
grac3gao Dec 17, 2019
4f9bf6e
Controller-2
grac3gao Dec 18, 2019
86be672
update-codegen
grac3gao Dec 18, 2019
9414727
Add unit test
grac3gao Dec 18, 2019
8f856dd
updating eventing
grac3gao Dec 19, 2019
3164381
Merge remote-tracking branch 'upstream/master' into propagation
grac3gao Dec 19, 2019
b8b48b0
add unit test & fix conformance test
grac3gao Dec 19, 2019
39ecc30
change after review
grac3gao Dec 20, 2019
96a3773
Merge remote-tracking branch 'upstream/master' into propagation
grac3gao Dec 20, 2019
05fe27a
update fmt.Errorf
grac3gao Dec 20, 2019
4a2f88e
code reviews/conflicts
grac3gao Jan 6, 2020
7c47668
code reviews/conflicts
grac3gao Jan 6, 2020
1d1c172
solve conflict and code modification
grac3gao Jan 15, 2020
8e80aba
update status
grac3gao Jan 15, 2020
4a4f250
update status
grac3gao Jan 16, 2020
de81277
add unit test + update perf test
grac3gao Jan 16, 2020
b370aa9
copyright year
grac3gao Jan 16, 2020
005d943
update unit test
grac3gao Jan 16, 2020
92a3f48
remove generation
grac3gao Jan 16, 2020
f0af2c4
labelSelector/status array/resourceVersion
grac3gao Jan 17, 2020
ce73965
add validation/unit test
grac3gao Jan 17, 2020
25c7167
consistency
grac3gao Jan 21, 2020
18a2832
Merge remote-tracking branch 'upstream/master' into propagation
grac3gao Jan 26, 2020
12c2f40
modification
grac3gao Jan 27, 2020
fc09fc6
modification
grac3gao Jan 27, 2020
efdda0f
Merge remote-tracking branch 'upstream/master' into propagation
grac3gao Jan 27, 2020
bf279c1
update unit test
grac3gao Jan 27, 2020
586f6f0
change api group name
grac3gao Jan 27, 2020
8ebc2c5
add symlink
grac3gao Jan 28, 2020
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: 5 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions cmd/broker/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2019 The Knative Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package broker

import (
"context"

apierrors "k8s.io/apimachinery/pkg/api/errors"
Comment thread
grac3gao-zz marked this conversation as resolved.
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

kubeclient "knative.dev/pkg/client/injection/kube/client"
"knative.dev/pkg/logging"
)

// GetLoggingConfig will get config from a specific namespace
func GetLoggingConfig(ctx context.Context, namespace, loggingConfigMapName string) (*logging.Config, error) {
loggingConfigMap, err := kubeclient.Get(ctx).CoreV1().ConfigMaps(namespace).Get(loggingConfigMapName, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return logging.NewConfigFromMap(nil)
} else if err != nil {
return nil, err
}
return logging.NewConfigFromConfigMap(loggingConfigMap)
}
34 changes: 20 additions & 14 deletions cmd/broker/filter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ import (
"go.opencensus.io/stats/view"
"go.uber.org/zap"

"knative.dev/eventing/cmd/broker"
"knative.dev/eventing/pkg/broker/filter"
cmpresources "knative.dev/eventing/pkg/reconciler/configmappropagation/resources"
namespaceresources "knative.dev/eventing/pkg/reconciler/namespace/resources"
"knative.dev/eventing/pkg/tracing"
kubeclient "knative.dev/pkg/client/injection/kube/client"
"knative.dev/pkg/configmap"
"knative.dev/pkg/controller"
"knative.dev/pkg/injection"
"knative.dev/pkg/logging"
"knative.dev/pkg/metrics"
"knative.dev/pkg/signals"
"knative.dev/pkg/system"

"knative.dev/eventing/pkg/broker/filter"
"knative.dev/eventing/pkg/tracing"
tracingconfig "knative.dev/pkg/tracing/config"

"knative.dev/pkg/injection/sharedmain"

Expand Down Expand Up @@ -77,10 +79,18 @@ func main() {
log.Fatal("Error building kubeconfig", err)
}

var env envConfig
if err := envconfig.Process("", &env); err != nil {
log.Fatal("Failed to process env var", zap.Error(err))
}

ctx, _ = injection.Default.SetupInformers(ctx, cfg)
kubeClient := kubeclient.Get(ctx)

loggingConfig, err := sharedmain.GetLoggingConfig(ctx)
loggingConfigMapName := cmpresources.MakeCopyConfigMapName(namespaceresources.DefaultConfigMapPropagationName, logging.ConfigMapName())
Comment thread
grac3gao-zz marked this conversation as resolved.
metricsConfigMapName := cmpresources.MakeCopyConfigMapName(namespaceresources.DefaultConfigMapPropagationName, metrics.ConfigMapName())

loggingConfig, err := broker.GetLoggingConfig(ctx, env.Namespace, loggingConfigMapName)
if err != nil {
log.Fatal("Error loading/parsing logging configuration:", err)
}
Expand All @@ -90,19 +100,14 @@ func main() {

logger.Info("Starting the Broker Filter")

var env envConfig
if err := envconfig.Process("", &env); err != nil {
logger.Fatal("Failed to process env var", zap.Error(err))
}

eventingClient := eventingv1alpha1.NewForConfigOrDie(cfg)
eventingFactory := eventinginformers.NewSharedInformerFactoryWithOptions(eventingClient,
controller.GetResyncPeriod(ctx),
eventinginformers.WithNamespace(env.Namespace))
triggerInformer := eventingFactory.Eventing().V1alpha1().Triggers()

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())
configMapWatcher := configmap.NewInformedWatcher(kubeClient, env.Namespace)
// Watch the observability config map and dynamically update metrics exporter.
updateFunc, err := metrics.UpdateExporterFromConfigMapWithOpts(metrics.ExporterOptions{
Component: component,
Expand All @@ -111,16 +116,17 @@ func main() {
if err != nil {
logger.Fatal("Failed to create metrics exporter update function", zap.Error(err))
}
configMapWatcher.Watch(metrics.ConfigMapName(), updateFunc)
configMapWatcher.Watch(metricsConfigMapName, updateFunc)
// TODO change the component name to broker once Stackdriver metrics are approved.
// Watch the observability config map and dynamically update request logs.
configMapWatcher.Watch(logging.ConfigMapName(), logging.UpdateLevelFromConfigMap(sl, atomicLevel, component))
configMapWatcher.Watch(loggingConfigMapName, logging.UpdateLevelFromConfigMap(sl, atomicLevel, component))

bin := tracing.BrokerFilterName(tracing.BrokerFilterNameArgs{
Namespace: env.Namespace,
BrokerName: env.Broker,
})
if err = tracing.SetupDynamicPublishing(sl, configMapWatcher, bin); err != nil {
if err = tracing.SetupDynamicPublishing(sl, configMapWatcher, bin,
cmpresources.MakeCopyConfigMapName(namespaceresources.DefaultConfigMapPropagationName, tracingconfig.ConfigName)); err != nil {
logger.Fatal("Error setting up trace publishing", zap.Error(err))
}

Expand Down
29 changes: 18 additions & 11 deletions cmd/broker/ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ import (
"go.opencensus.io/stats/view"
"go.uber.org/zap"

cmdbroker "knative.dev/eventing/cmd/broker"
"knative.dev/eventing/pkg/broker"
"knative.dev/eventing/pkg/broker/ingress"
"knative.dev/eventing/pkg/kncloudevents"
cmpresources "knative.dev/eventing/pkg/reconciler/configmappropagation/resources"
namespaceresources "knative.dev/eventing/pkg/reconciler/namespace/resources"
"knative.dev/eventing/pkg/tracing"
kubeclient "knative.dev/pkg/client/injection/kube/client"
"knative.dev/pkg/configmap"
Expand All @@ -43,8 +46,8 @@ import (
"knative.dev/pkg/logging"
"knative.dev/pkg/metrics"
"knative.dev/pkg/signals"
"knative.dev/pkg/system"
pkgtracing "knative.dev/pkg/tracing"
tracingconfig "knative.dev/pkg/tracing/config"
)

var (
Expand Down Expand Up @@ -91,13 +94,21 @@ func main() {
log.Fatal("Error building kubeconfig", err)
}

var env envConfig
if err := envconfig.Process("", &env); err != nil {
log.Fatal("Failed to process env var", zap.Error(err))
}

log.Printf("Registering %d clients", len(injection.Default.GetClients()))
log.Printf("Registering %d informer factories", len(injection.Default.GetInformerFactories()))
log.Printf("Registering %d informers", len(injection.Default.GetInformers()))

ctx, informers := injection.Default.SetupInformers(ctx, cfg)

loggingConfig, err := sharedmain.GetLoggingConfig(ctx)
loggingConfigMapName := cmpresources.MakeCopyConfigMapName(namespaceresources.DefaultConfigMapPropagationName, logging.ConfigMapName())
metricsConfigMapName := cmpresources.MakeCopyConfigMapName(namespaceresources.DefaultConfigMapPropagationName, metrics.ConfigMapName())

loggingConfig, err := cmdbroker.GetLoggingConfig(ctx, env.Namespace, loggingConfigMapName)
if err != nil {
log.Fatal("Error loading/parsing logging configuration:", err)
}
Expand All @@ -107,19 +118,14 @@ func main() {

logger.Info("Starting the Broker Ingress")

var env envConfig
if err := envconfig.Process("", &env); err != nil {
logger.Fatal("Failed to process env var", zap.Error(err))
}

channelURI := &url.URL{
Scheme: "http",
Host: env.Channel,
Path: "/",
}

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeclient.Get(ctx), system.Namespace())
configMapWatcher := configmap.NewInformedWatcher(kubeclient.Get(ctx), env.Namespace)
// Watch the observability config map and dynamically update metrics exporter.
updateFunc, err := metrics.UpdateExporterFromConfigMapWithOpts(metrics.ExporterOptions{
Component: component,
Expand All @@ -128,16 +134,17 @@ func main() {
if err != nil {
logger.Fatal("Failed to create metrics exporter update function", zap.Error(err))
}
configMapWatcher.Watch(metrics.ConfigMapName(), updateFunc)
configMapWatcher.Watch(metricsConfigMapName, updateFunc)
// TODO change the component name to broker once Stackdriver metrics are approved.
// Watch the observability config map and dynamically update request logs.
configMapWatcher.Watch(logging.ConfigMapName(), logging.UpdateLevelFromConfigMap(sl, atomicLevel, component))
configMapWatcher.Watch(loggingConfigMapName, logging.UpdateLevelFromConfigMap(sl, atomicLevel, component))

bin := tracing.BrokerIngressName(tracing.BrokerIngressNameArgs{
Namespace: env.Namespace,
BrokerName: env.Broker,
})
if err = tracing.SetupDynamicPublishing(sl, configMapWatcher, bin); err != nil {
if err = tracing.SetupDynamicPublishing(sl, configMapWatcher, bin,
cmpresources.MakeCopyConfigMapName(namespaceresources.DefaultConfigMapPropagationName, tracingconfig.ConfigName)); err != nil {
logger.Fatal("Error setting up trace publishing", zap.Error(err))
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"knative.dev/eventing/pkg/reconciler/apiserversource"
"knative.dev/eventing/pkg/reconciler/broker"
"knative.dev/eventing/pkg/reconciler/channel"
"knative.dev/eventing/pkg/reconciler/configmappropagation"
"knative.dev/eventing/pkg/reconciler/eventtype"
"knative.dev/eventing/pkg/reconciler/legacyapiserversource"
"knative.dev/eventing/pkg/reconciler/legacycontainersource"
Expand All @@ -51,6 +52,7 @@ func main() {

// Flows
parallel.NewController,
configmappropagation.NewController,
sequence.NewController,

// Sources
Expand Down
4 changes: 4 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
configsv1alpha1 "knative.dev/eventing/pkg/apis/configs/v1alpha1"
eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1"
eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1"
Expand Down Expand Up @@ -73,6 +74,9 @@ var ourTypes = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
// For group flows.knative.dev
flowsv1alpha1.SchemeGroupVersion.WithKind("Parallel"): &flowsv1alpha1.Parallel{},
flowsv1alpha1.SchemeGroupVersion.WithKind("Sequence"): &flowsv1alpha1.Sequence{},

// For group configs.knative.dev
configsv1alpha1.SchemeGroupVersion.WithKind("ConfigMapPropagation"): &configsv1alpha1.ConfigMapPropagation{},
}

func NewDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
Expand Down
1 change: 1 addition & 0 deletions config/300-configmappropagation.yaml
2 changes: 2 additions & 0 deletions config/core/configmaps/logging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ metadata:
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
knative.dev/config-propagation: original
knative.dev/config-category: eventing
data:
# Common configuration for all Knative codebase
zap-logger-config: |
Expand Down
2 changes: 2 additions & 0 deletions config/core/configmaps/observability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ metadata:
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
knative.dev/config-propagation: original
knative.dev/config-category: eventing
data:
_example: |
################################
Expand Down
2 changes: 2 additions & 0 deletions config/core/configmaps/tracing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ metadata:
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
knative.dev/config-propagation: original
knative.dev/config-category: eventing
data:
_example: |
################################
Expand Down
61 changes: 61 additions & 0 deletions config/core/resources/configmappropagation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: configmappropagations.configs.internal.knative.dev
labels:
eventing.knative.dev/release: devel
knative.dev/crd-install: "true"
spec:
group: configs.internal.knative.dev
versions:
- name: v1alpha1
served: true
storage: true
names:
kind: ConfigMapPropagation
plural: configmappropagations
singular: configmappropagation
categories:
- all
- knative
- eventing
shortNames:
- kcmp
- cmp
scope: Namespaced
subresources:
status: {}
additionalPrinterColumns:
- name: Ready
type: string
JSONPath: ".status.conditions[?(@.type==\"Ready\")].status"
- name: Reason
type: string
JSONPath: ".status.conditions[?(@.type==\"Ready\")].reason"
- name: OriginalNamespace
type: string
JSONPath: ".spec.originalNamespace"
validation:
openAPIV3Schema:
properties:
spec:
required:
- originalNamespace
properties:
originalNamespace:
type: string
description: "The namespace where original ConfigMaps exist in."
8 changes: 8 additions & 0 deletions config/core/roles/controller-clusterroles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ rules:
- "parallels/status"
verbs: *everything

# Configs resources and status we care about.
- apiGroups:
- "configs.internal.knative.dev"
resources:
- "configmappropagations"
- "configmappropagations/status"
verbs: *everything

# Messaging resources and finalizers we care about.
- apiGroups:
- "messaging.knative.dev"
Expand Down
4 changes: 2 additions & 2 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dir
# instead of the $GOPATH directly. For normal projects this can be dropped.
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \
"eventing:v1alpha1 eventing:v1beta1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 flows:v1beta1 sources:v1alpha1" \
"eventing:v1alpha1 eventing:v1beta1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 flows:v1beta1 sources:v1alpha1 configs:v1alpha1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# TODO(#2312): Remove this after v0.13.
Expand All @@ -48,7 +48,7 @@ ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \
# Knative Injection
${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \
"eventing:v1alpha1 eventing:v1beta1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 flows:v1beta1 sources:v1alpha1 duck:v1alpha1 duck:v1beta1" \
"eventing:v1alpha1 eventing:v1beta1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 flows:v1beta1 sources:v1alpha1 duck:v1alpha1 duck:v1beta1 configs:v1alpha1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# TODO(#2312): Remove this after v0.13.
Expand Down
Loading