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

Bump the version of knative/pkg to something much more recent. #985

Merged
merged 1 commit into from
Jun 17, 2019
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
24 changes: 16 additions & 8 deletions Gopkg.lock

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

14 changes: 12 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,23 @@ required = [

[[override]]
name = "github.com/knative/pkg"
# HEAD as of 2019-04-09 💖
revision = "28cfa161499b88cc5a71cfb7cf8a59fc34bff3d3"
# HEAD as of 2019-06-14 💖
revision = "68737b1b4e03d9a888e89ee2a44714a56eefd539"

[[override]]
name = "go.uber.org/zap"
revision = "67bc79d13d155c02fd008f721863ff8cc5f30659"

[[override]]
name = "contrib.go.opencensus.io/exporter/stackdriver"
# HEAD as of 2019-02-11
# Needed because this includes a fix to support Stackdriver built-in metrics
revision = "c06c82c832edca4eaf7b0241bd655560a1be0346"

[[override]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.12.6"

[prune]
go-tests = true
unused-packages = true
Expand Down
11 changes: 7 additions & 4 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import (
"log"
"time"

"github.com/knative/pkg/logging"

tklogging "github.com/tektoncd/pipeline/pkg/logging"
corev1 "k8s.io/api/core/v1"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/clientcmd"

"github.com/tektoncd/pipeline/pkg/logging"

sharedclientset "github.com/knative/pkg/client/clientset/versioned"
"github.com/knative/pkg/controller"
"github.com/tektoncd/pipeline/pkg/reconciler"
Expand All @@ -45,6 +46,8 @@ import (
const (
threadsPerController = 2
resyncPeriod = 10 * time.Hour
// ControllerLogKey is the name of the logger for the controller cmd
ControllerLogKey = "controller"
)

var (
Expand All @@ -63,7 +66,7 @@ func main() {
if err != nil {
log.Fatalf("Error parsing logging configuration: %v", err)
}
logger, atomicLevel := logging.NewLoggerFromConfig(loggingConfig, logging.ControllerLogKey)
logger, atomicLevel := logging.NewLoggerFromConfig(loggingConfig, ControllerLogKey)
defer logger.Sync()

logger.Info("Starting the Pipeline Controller")
Expand Down Expand Up @@ -144,7 +147,7 @@ func main() {
timeoutHandler.CheckTimeouts(kubeClient, pipelineClient)

// Watch the logging config map and dynamically update logging levels.
configMapWatcher.Watch(logging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, logging.ControllerLogKey))
configMapWatcher.Watch(tklogging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, ControllerLogKey))

kubeInformerFactory.Start(stopCh)
pipelineInformerFactory.Start(stopCh)
Expand Down
11 changes: 8 additions & 3 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
"flag"
"log"

"github.com/knative/pkg/logging"
tklogging "github.com/tektoncd/pipeline/pkg/logging"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"

"go.uber.org/zap"
Expand All @@ -28,13 +31,15 @@ import (
"github.com/knative/pkg/logging/logkey"
"github.com/knative/pkg/signals"
"github.com/knative/pkg/webhook"
"github.com/tektoncd/pipeline/pkg/logging"
"github.com/tektoncd/pipeline/pkg/system"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)

// WebhookLogKey is the name of the logger for the webhook cmd
const WebhookLogKey = "webhook"

func main() {
flag.Parse()
cm, err := configmap.Load("/etc/config-logging")
Expand All @@ -45,7 +50,7 @@ func main() {
if err != nil {
log.Fatalf("Error parsing logging configuration: %v", err)
}
logger, atomicLevel := logging.NewLoggerFromConfig(config, logging.WebhookLogKey)
logger, atomicLevel := logging.NewLoggerFromConfig(config, WebhookLogKey)
defer logger.Sync()
logger = logger.With(zap.String(logkey.ControllerType, "webhook"))

Expand All @@ -65,7 +70,7 @@ func main() {
}
// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.GetNamespace())
configMapWatcher.Watch(logging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, logging.WebhookLogKey))
configMapWatcher.Watch(tklogging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, WebhookLogKey))
if err = configMapWatcher.Start(stopCh); err != nil {
logger.Fatalf("failed to start configuration manager: %v", err)
}
Expand Down
23 changes: 0 additions & 23 deletions pkg/logging/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,15 @@ package logging

import (
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"

"github.com/knative/pkg/logging"
)

const (
// ConfigName is the name of the ConfigMap that the logging config will be stored in
ConfigName = "config-logging"
// ControllerLogKey is the name of the logger for the controller cmd
ControllerLogKey = "controller"
// WebhookLogKey is the name of the logger for the webhook cmd
WebhookLogKey = "webhook"
)

var components = []string{ControllerLogKey, WebhookLogKey}

// NewLogger creates a logger with the supplied configuration.
// In addition to the logger, it returns AtomicLevel that can
// be used to change the logging level at runtime.
Expand All @@ -48,19 +41,3 @@ func NewLogger(configJSON string, levelOverride string) (*zap.SugaredLogger, zap
func NewLoggerFromConfig(config *logging.Config, name string) (*zap.SugaredLogger, zap.AtomicLevel) {
return logging.NewLoggerFromConfig(config, name)
}

// NewConfigFromMap creates a LoggingConfig from the supplied map
func NewConfigFromMap(data map[string]string) (*logging.Config, error) {
return logging.NewConfigFromMap(data, components...)
}

// NewConfigFromConfigMap creates a LoggingConfig from the supplied ConfigMap
func NewConfigFromConfigMap(configMap *corev1.ConfigMap) (*logging.Config, error) {
return logging.NewConfigFromConfigMap(configMap, components...)
}

// UpdateLevelFromConfigMap returns a helper func that can be used to update the logging level
// when a config map is updated
func UpdateLevelFromConfigMap(logger *zap.SugaredLogger, atomicLevel zap.AtomicLevel, levelKey string) func(configMap *corev1.ConfigMap) {
return logging.UpdateLevelFromConfigMap(logger, atomicLevel, levelKey, components...)
}
2 changes: 1 addition & 1 deletion pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func NewController(
timeoutHandler: timeoutHandler,
}

impl := controller.NewImpl(r, r.Logger, pipelineRunControllerName, reconciler.MustNewStatsReporter(pipelineRunControllerName, r.Logger))
impl := controller.NewImpl(r, r.Logger, pipelineRunControllerName)

r.Logger.Info("Setting up event handlers")
pipelineRunInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/v1alpha1/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func NewController(
resourceLister: resourceInformer.Lister(),
timeoutHandler: timeoutHandler,
}
impl := controller.NewImpl(c, c.Logger, taskRunControllerName, reconciler.MustNewStatsReporter(taskRunControllerName, c.Logger))
impl := controller.NewImpl(c, c.Logger, taskRunControllerName)

c.Logger.Info("Setting up event handlers")
taskRunInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
Expand Down
Loading