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

Revert "Bug 1732579: Best-effort loading" #71

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -17,8 +17,5 @@ bin
# Ignore sqlite
*.db

# Ignore vscode
.vscode

# Igore apprclient meta
pkg/apprclient/openapi/git_push.sh
15 changes: 5 additions & 10 deletions cmd/appregistry-server/main.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import (
health "github.com/operator-framework/operator-registry/pkg/api/grpc_health_v1"
"github.com/operator-framework/operator-registry/pkg/appregistry"
"github.com/operator-framework/operator-registry/pkg/lib/log"
"github.com/operator-framework/operator-registry/pkg/registry"
"github.com/operator-framework/operator-registry/pkg/server"
)

@@ -57,7 +56,7 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {
}
err = log.AddDefaultWriterHooks(terminationLogPath)
if err != nil {
logrus.WithError(err).Warn("unable to set termination log path")
return err
}
kubeconfig, err := cmd.Flags().GetString("kubeconfig")
if err != nil {
@@ -90,21 +89,17 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {

loader, err := appregistry.NewLoader(kubeconfig, dbName, downloadPath, logger)
if err != nil {
logger.Fatalf("error initializing: %s", err)
logger.Fatalf("error initializing - %v", err)
}

store, err := loader.Load(sources, packages)
if err != nil {
logger.WithError(err).Warn("error loading app registry manifests")
}
if store == nil {
logger.Warn("using empty querier")
store = registry.NewEmptyQuerier()
logger.Fatalf("error loading manifest from remote registry - %v", err)
}

lis, err := net.Listen("tcp", ":"+port)
if err != nil {
logger.Fatalf("failed to listen: %s", err)
logger.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()

@@ -114,7 +109,7 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {

logger.Info("serving registry")
if err := s.Serve(lis); err != nil {
logger.Fatalf("failed to serve: %s", err)
logger.Fatalf("failed to serve: %v", err)
}

return nil
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ require (
github.com/mattn/go-sqlite3 v1.10.0
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190125151539-1e295784b30a
github.com/otiai10/copy v1.0.1
github.com/sirupsen/logrus v1.2.0
github.com/spf13/cobra v0.0.3
github.com/stretchr/testify v1.2.2
@@ -21,7 +20,6 @@ require (
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/tools v0.0.0-20181207222222-4c874b978acb // indirect
google.golang.org/grpc v1.17.0
gopkg.in/yaml.v2 v2.2.1
k8s.io/api v0.0.0-20190118113203-912cbe2bfef3
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc
k8s.io/apimachinery v0.0.0-20190118094746-1525e4dadd2d
6 changes: 1 addition & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
bitbucket.org/ww/goautoneg v0.0.0-20120707110453-75cd24fc2f2c/go.mod h1:1vhO7Mn/FZMgOgDVGLy5X1mE6rq1HbkBdkF/yj8zkcg=
bou.ke/monkey v1.0.1/go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@@ -145,9 +144,6 @@ github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190125151539-1
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190125151539-1e295784b30a/go.mod h1:vq6TTFvg6ti1Bn6ACsZneZTmjTsURgDD6tQtVDbEgsU=
github.com/operator-framework/operator-registry v1.0.1/go.mod h1:1xEdZjjUg2hPEd52LG3YQ0jtwiwEGdm98S1TH5P4RAA=
github.com/operator-framework/operator-registry v1.0.4/go.mod h1:hve6YwcjM2nGVlscLtNsp9sIIBkNZo6jlJgzWw7vP9s=
github.com/otiai10/copy v1.0.1 h1:gtBjD8aq4nychvRZ2CyJvFWAw0aja+VHazDdruZKGZA=
github.com/otiai10/copy v1.0.1/go.mod h1:8bMCJrAqOtN/d9oyh5HR7HhLQMvcGMpGdwRDYsfOCHc=
github.com/otiai10/mint v1.2.3/go.mod h1:YnfyPNhBvnY8bW4SGQHCs/aAFhkgySlMZbrF5U0bOVw=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/petar/GoLLRB v0.0.0-20130427215148-53be0d36a84c/go.mod h1:HUpKUBZnpzkdx0kD/+Yfuft+uD3zHGtXF/XJB14TUr4=
@@ -254,7 +250,7 @@ k8s.io/apimachinery v0.0.0-20190118094746-1525e4dadd2d/go.mod h1:ccL7Eh7zubPUSh9
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170 h1:CqI85nZvPaV+7JFono0nAOGOx2brocqefcOhDPVhHKI=
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
k8s.io/client-go v0.0.0-20180718001006-59698c7d9724/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
k8s.io/client-go v8.0.0+incompatible h1:tTI4hRmb1DRMl4fG6Vclfdi6nTM82oIrTT7HfitmxC4=
k8s.io/client-go v8.0.0+incompatible h1:2pUaSg2x6iEHr8cia6zmWhoCXG1EDG9TCx9s//Aq7HY=
k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8=
k8s.io/gengo v0.0.0-20181106084056-51747d6e00da/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
50 changes: 26 additions & 24 deletions pkg/appregistry/appregistry.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import (
"fmt"

"github.com/sirupsen/logrus"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
@@ -45,31 +44,31 @@ func NewLoader(kubeconfig string, dbName string, downloadPath string, logger *lo
kubeClient: *kubeClient,
},
downloadPath: downloadPath,
decoder: decoder,
loader: loader,
decoder: decoder,
loader: loader,
}, nil
}

type AppregistryLoader struct {
logger *logrus.Entry
input *inputParser
downloader *downloader
logger *logrus.Entry
input *inputParser
downloader *downloader
downloadPath string
decoder *manifestDecoder
loader *dbLoader
decoder *manifestDecoder
loader *dbLoader
}

func (a *AppregistryLoader) Load(csvSources []string, csvPackages string) (registry.Query, error) {
func (a *AppregistryLoader) Load(csvSources []string, csvPackages string) (store registry.Query, err error) {
a.logger.Infof("operator source(s) specified are - %s", csvSources)
a.logger.Infof("package(s) specified are - %s", csvPackages)

var errs []error
input, err := a.input.Parse(csvSources, csvPackages)
if err != nil {
errs = append(errs, fmt.Errorf("error parsing input: %s", err))
a.logger.Errorf("the following error(s) occurred while parsing input - %v", err)

if input == nil || !input.IsGoodToProceed() {
a.logger.Info("can't proceed, bailing out")
return nil, utilerrors.NewAggregate(errs)
return
}
}

@@ -79,7 +78,12 @@ func (a *AppregistryLoader) Load(csvSources []string, csvPackages string) (regis

rawManifests, err := a.downloader.Download(input)
if err != nil {
errs = append(errs, fmt.Errorf("error downloading manifests: %s", err))
a.logger.Errorf("The following error occurred while downloading - %v", err)

if len(rawManifests) == 0 {
a.logger.Info("No package manifest downloaded")
return
}
}

a.logger.Infof("download complete - %d repositories have been downloaded", len(rawManifests))
@@ -88,24 +92,22 @@ func (a *AppregistryLoader) Load(csvSources []string, csvPackages string) (regis
// flattened single file yaml and nested operator bundle(s).
result, err := a.decoder.Decode(rawManifests, a.downloadPath)
if err != nil {
errs = append(errs, fmt.Errorf("error decoding manifest: %s", err))
}
if result.IsEmpty() {
a.logger.Info("No operator manifest decoded")
a.logger.Errorf("The following error occurred while decoding manifest - %v", err)

if result.IsEmpty() {
a.logger.Info("No operator manifest decoded")
return
}
}

a.logger.Infof("decoded %d flattened and %d nested operator manifest(s)", result.FlattenedCount, result.NestedCount)

if err = a.loader.LoadBundleDirectoryToSQLite(a.downloadPath); err != nil {
errs = append(errs, fmt.Errorf("error loading operator manifests: %s", err))
}

store, err := a.loader.GetStore()
if err != nil {
errs = append(errs, err)
return
}

return store, utilerrors.NewAggregate(errs)
store, err = a.loader.GetStore()
return
}

func NewKubeClient(kubeconfig string, logger *logrus.Entry) (clientset *kubernetes.Clientset, err error) {
6 changes: 3 additions & 3 deletions pkg/registry/bundle.go
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ type Bundle struct {
}

func NewBundle(name, pkgName, channelName string, objs ...*unstructured.Unstructured) *Bundle {
bundle := &Bundle{Name: name, Package: pkgName, Channel: channelName, cacheStale: false}
bundle := &Bundle{Name: name, Package:pkgName, Channel:channelName, cacheStale: false}
for _, o := range objs {
bundle.Add(o)
}
@@ -94,7 +94,7 @@ func (b *Bundle) ProvidedAPIs() (map[APIKey]struct{}, error) {
provided[APIKey{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Spec.Names.Kind, Plural: crd.Spec.Names.Plural}] = struct{}{}
}
if crd.Spec.Version != "" {
provided[APIKey{Group: crd.Spec.Group, Version: crd.Spec.Version, Kind: crd.Spec.Names.Kind, Plural: crd.Spec.Names.Plural}] = struct{}{}
provided[APIKey{Group: crd.Spec.Group, Version: crd.Spec.Version, Kind: crd.Spec.Names.Kind, Plural:crd.Spec.Names.Plural}] = struct{}{}
}
}

@@ -121,7 +121,7 @@ func (b *Bundle) RequiredAPIs() (map[APIKey]struct{}, error) {
if err != nil {
return nil, err
}
for _, api := range requiredCRDs {
for _, api := range requiredCRDs{
parts := strings.SplitN(api.Name, ".", 2)
if len(parts) < 2 {
return nil, fmt.Errorf("couldn't parse plural.group from crd name: %s", api.Name)
55 changes: 0 additions & 55 deletions pkg/registry/empty.go

This file was deleted.

14 changes: 6 additions & 8 deletions pkg/registry/types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package registry

import (
"fmt"
)
import "fmt"

// APIKey stores GroupVersionKind for use as map keys
type APIKey struct {
@@ -28,15 +26,15 @@ type DefinitionKey struct {
// channels under a single package.
type PackageManifest struct {
// PackageName is the name of the overall package, ala `etcd`.
PackageName string `json:"packageName" yaml:"packageName"`
PackageName string `json:"packageName"`

// Channels are the declared channels for the package, ala `stable` or `alpha`.
Channels []PackageChannel `json:"channels" yaml:"channels"`
Channels []PackageChannel `json:"channels"`

// DefaultChannelName is, if specified, the name of the default channel for the package. The
// default channel will be installed if no other channel is explicitly given. If the package
// has a single channel, then that channel is implicitly the default.
DefaultChannelName string `json:"defaultChannel" yaml:"defaultChannel"`
DefaultChannelName string `json:"defaultChannel"`
}

// GetDefaultChannel gets the default channel or returns the only one if there's only one. returns empty string if it
@@ -55,11 +53,11 @@ func (m PackageManifest) GetDefaultChannel() string {
// package.
type PackageChannel struct {
// Name is the name of the channel, e.g. `alpha` or `stable`
Name string `json:"name" yaml:"name"`
Name string `json:"name"`

// CurrentCSVName defines a reference to the CSV holding the version of this package currently
// for the channel.
CurrentCSVName string `json:"currentCSV" yaml:"currentCSV"`
CurrentCSVName string `json:"currentCSV"`
}

// IsDefaultChannel returns true if the PackageChennel is the default for the PackageManifest
Loading