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

Bug 1779990: fix(packageserver): cache packagemanifests #1150

Merged
merged 3 commits into from
Dec 9, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,5 @@ __pycache__/
/apiserver.local.config
e2e.namespace
minikube.kubeconfig
apiserver.crt
apiserver.key

This file was deleted.

This file was deleted.

49 changes: 8 additions & 41 deletions cmd/package-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,25 @@ package main
import (
"flag"
"os"
"time"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/component-base/logs"

"github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/server"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/signals"
"github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/server"
)

const (
defaultWakeupInterval = 5 * time.Minute
)

// config flags defined globally so that they appear on the test binary as well
var (
ctx = signals.Context()
options = server.NewPackageServerOptions(os.Stdout, os.Stderr)
cmd = &cobra.Command{
Short: "Launch a package-server",
Long: "Launch a package-server",
RunE: func(c *cobra.Command, args []string) error {
if err := options.Run(ctx); err != nil {
return err
}
return nil
},
}
)

func init() {
flags := cmd.Flags()

flags.DurationVar(&options.WakeupInterval, "interval", options.WakeupInterval, "Interval at which to re-sync CatalogSources")
flags.StringVar(&options.GlobalNamespace, "global-namespace", options.GlobalNamespace, "Name of the namespace where the global CatalogSources are located")
flags.StringSliceVar(&options.WatchedNamespaces, "watched-namespaces", options.WatchedNamespaces, "List of namespaces the package-server will watch watch for CatalogSources")
flags.StringVar(&options.Kubeconfig, "kubeconfig", options.Kubeconfig, "The path to the kubeconfig used to connect to the Kubernetes API server and the Kubelets (defaults to in-cluster config)")
flags.BoolVar(&options.Debug, "debug", options.Debug, "use debug log level")

options.SecureServing.AddFlags(flags)
options.Authentication.AddFlags(flags)
options.Authorization.AddFlags(flags)
options.Features.AddFlags(flags)

flags.AddGoFlagSet(flag.CommandLine)
flags.Parse(flag.Args())
}

Comment on lines -16 to -53
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to clean all this up while I'm here.

func main() {
logs.InitLogs()
defer logs.FlushLogs()

ctx := signals.Context()
options := server.NewPackageServerOptions(os.Stdout, os.Stderr)
cmd := server.NewCommandStartPackageServer(ctx, options)
cmd.Flags().AddGoFlagSet(flag.CommandLine)
if err := cmd.Flags().Parse(flag.Args()); err != nil {
log.Fatal(err)
}
if err := cmd.Execute(); err != nil {
log.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/fsnotify/fsnotify v1.4.7
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/spec v0.19.2
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
github.com/golang/mock v1.3.1
github.com/google/btree v1.0.0 // indirect
Expand All @@ -34,6 +33,7 @@ require (
github.com/stretchr/testify v1.4.0
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
gonum.org/v1/gonum v0.0.0-20190710053202-4340aa3071a0 // indirect
google.golang.org/grpc v1.23.0
Expand All @@ -44,6 +44,7 @@ require (
k8s.io/client-go v8.0.0+incompatible
k8s.io/code-generator v0.0.0
k8s.io/component-base v0.0.0
k8s.io/klog v0.4.0
Copy link
Member Author

@njhale njhale Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OLM codepaths using glog were brought into the packageserver dependency tree transitively. This was causing flag registration conflicts with klog, so I swapped all references from glog to klog.

k8s.io/kube-aggregator v0.0.0
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf
k8s.io/kubernetes v1.16.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
4 changes: 2 additions & 2 deletions pkg/lib/event/event.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package event

import (
"github.com/golang/glog"
v1 "k8s.io/api/core/v1"
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/tools/record"
"k8s.io/klog"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme"
)
Expand All @@ -15,7 +15,7 @@ const component string = "operator-lifecycle-manager"
// used to post Events to different object's lifecycles.
func NewRecorder(event typedcorev1.EventInterface) (record.EventRecorder, error) {
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartLogging(klog.Infof)
eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: event})
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: component})

Expand Down
4 changes: 2 additions & 2 deletions pkg/lib/operatorclient/apiservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package operatorclient
import (
"fmt"

"github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
)

Expand All @@ -26,7 +26,7 @@ func (c *Client) DeleteAPIService(name string, options *metav1.DeleteOptions) er

// UpdateAPIService will update the given APIService resource.
func (c *Client) UpdateAPIService(apiService *apiregistrationv1.APIService) (*apiregistrationv1.APIService, error) {
glog.V(4).Infof("[UPDATE APIService]: %s", apiService.GetName())
klog.V(4).Infof("[UPDATE APIService]: %s", apiService.GetName())
oldAPIService, err := c.GetAPIService(apiService.GetName())
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/lib/operatorclient/clusterrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package operatorclient
import (
"fmt"

"github.com/golang/glog"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog"
)

// CreateClusterRole creates the ClusterRole.
Expand All @@ -26,7 +26,7 @@ func (c *Client) DeleteClusterRole(name string, options *metav1.DeleteOptions) e

// UpdateClusterRole will update the given ClusterRole.
func (c *Client) UpdateClusterRole(crb *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error) {
glog.V(4).Infof("[UPDATE Role]: %s", crb.GetName())
klog.V(4).Infof("[UPDATE Role]: %s", crb.GetName())
oldCrb, err := c.GetClusterRole(crb.GetName())
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/lib/operatorclient/clusterrolebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package operatorclient
import (
"fmt"

"github.com/golang/glog"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog"
)

// CreateRoleBinding creates the roleBinding.
Expand All @@ -26,7 +26,7 @@ func (c *Client) DeleteClusterRoleBinding(name string, options *metav1.DeleteOpt

// UpdateRoleBinding will update the given RoleBinding resource.
func (c *Client) UpdateClusterRoleBinding(crb *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error) {
glog.V(4).Infof("[UPDATE RoleBinding]: %s", crb.GetName())
klog.V(4).Infof("[UPDATE RoleBinding]: %s", crb.GetName())
oldCrb, err := c.GetClusterRoleBinding(crb.GetName())
if err != nil {
return nil, err
Expand Down
Loading