diff --git a/go.mod b/go.mod index c928feb322..93e82483f0 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/mikefarah/yq/v3 v3.0.0-20201202084205-8846255d1c37 github.com/onsi/ginkgo/v2 v2.9.5 github.com/openshift/api v3.9.0+incompatible - github.com/operator-framework/api v0.17.6 + github.com/operator-framework/api v0.17.7 github.com/operator-framework/operator-lifecycle-manager v0.0.0-00010101000000-000000000000 github.com/operator-framework/operator-registry v1.27.1 github.com/sirupsen/logrus v1.9.2 diff --git a/staging/operator-registry/.github/workflows/unit.yaml b/staging/operator-registry/.github/workflows/unit.yaml index 8ec90418b9..8dfdd5e8cb 100644 --- a/staging/operator-registry/.github/workflows/unit.yaml +++ b/staging/operator-registry/.github/workflows/unit.yaml @@ -22,5 +22,4 @@ jobs: - uses: codecov/codecov-action@v3 with: files: coverage.out - fail_ci_if_error: true functionalities: fixes diff --git a/staging/operator-registry/cmd/opm/serve/serve.go b/staging/operator-registry/cmd/opm/serve/serve.go index fc3c482ff8..6a3add607b 100644 --- a/staging/operator-registry/cmd/opm/serve/serve.go +++ b/staging/operator-registry/cmd/opm/serve/serve.go @@ -36,8 +36,9 @@ type serve struct { port string terminationLog string - debug bool - pprofAddr string + debug bool + pprofAddr string + captureProfiles bool logger *logrus.Entry } @@ -80,7 +81,8 @@ will not be reflected in the served content. cmd.Flags().BoolVar(&s.debug, "debug", false, "enable debug logging") cmd.Flags().StringVarP(&s.terminationLog, "termination-log", "t", "/dev/termination-log", "path to a container termination log file") cmd.Flags().StringVarP(&s.port, "port", "p", "50051", "port number to serve on") - cmd.Flags().StringVar(&s.pprofAddr, "pprof-addr", "", "address of startup profiling endpoint (addr:port format)") + cmd.Flags().StringVar(&s.pprofAddr, "pprof-addr", "localhost:6060", "address of startup profiling endpoint (addr:port format)") + cmd.Flags().BoolVar(&s.captureProfiles, "pprof-capture-profiles", false, "capture pprof CPU profiles") cmd.Flags().StringVar(&s.cacheDir, "cache-dir", "", "if set, sync and persist server cache directory") cmd.Flags().BoolVar(&s.cacheOnly, "cache-only", false, "sync the serve cache and exit without serving") cmd.Flags().BoolVar(&s.cacheEnforceIntegrity, "cache-enforce-integrity", false, "exit with error if cache is not present or has been invalidated. (default: true when --cache-dir is set and --cache-only is false, false otherwise), ") @@ -92,8 +94,10 @@ func (s *serve) run(ctx context.Context) error { if err := p.startEndpoint(); err != nil { return fmt.Errorf("could not start pprof endpoint: %v", err) } - if err := p.startCpuProfileCache(); err != nil { - return fmt.Errorf("could not start CPU profile: %v", err) + if s.captureProfiles { + if err := p.startCpuProfileCache(); err != nil { + return fmt.Errorf("could not start CPU profile: %v", err) + } } // Immediately set up termination log diff --git a/staging/operator-registry/docs/design/bundle-sources.md b/staging/operator-registry/docs/design/bundle-sources.md new file mode 100644 index 0000000000..3540518492 --- /dev/null +++ b/staging/operator-registry/docs/design/bundle-sources.md @@ -0,0 +1,286 @@ +# Building a file-based catalog from a plain bundle image + +> **Warning:** Operator Lifecycle Manager (OLM) v1 features and components are still experimental. Early adopters and contributors should expect breaking changes. The following procedures are not recommended for use on production clusters. + +You can build a static collection of arbitrary Kubernetes manifests in the YAML format, or *plain bundle*, and add the image to a file-based catalog (FBC). The experimental `olm.bundle.mediatype` property of the `olm.bundle` schema object differentiates a plain bundle from a regular (`registry+v1`) bundle. You must set the bundle media type property to `plain+v0` to specify a plain bundle. + +For more information, see the [Plain Bundle Specification](https://github.com/operator-framework/rukpak/blob/main/docs/bundles/plain.md) in the RukPak repository. + +To build a file-based catalog from a plain bundle image, you must complete the following steps: + +* Create a plain bundle image +* Create a file-based catalog +* Add the plain bundle image to your file-based catalog +* Build your catalog as an image +* Publish your catalog image + +## Building a plain bundle image from an image source + +Currently, the Operator Controller only supports installing plain bundles created from a plain bundle image. + +

+Prerequisites +

+ +* [`opm` CLI tool](https://github.com/operator-framework/operator-registry/releases) +* Docker or Podman +* Push access to a container registry, such as [Quay](https://quay.io) + +

+Procedure +

+ +1. Verify that your Kubernetes manifests are in a flat directory at the root of your project similar to the following example: + + ```sh + tree manifests + manifests + ├── namespace.yaml + ├── service_account.yaml + ├── cluster_role.yaml + ├── cluster_role_binding.yaml + └── deployment.yaml + ``` + + * If you are using [kustomize](https://kustomize.io) to build your manifests from templates, you must redirect the output to one or more files under the `manifests/` directory. For example: + + ```sh + kustomize build templates > manifests/manifests.yaml + ``` + + For more information, see [Building a plain bundle > Prerequisites](https://github.com/operator-framework/rukpak/blob/main/docs/bundles/plain.md#prerequisites). + +1. Create a Dockerfile at the root of your project: + + ```sh + touch plainbundle.Dockerfile + ``` + +1. Make the following changes to your Dockerfile: + + *Example Dockerfile* + + ```sh + FROM scratch + ADD manifests /manifests + ``` + + > **Note:** Use the `FROM scratch` directive to make the size of the image smaller. No other files or directories are required in the bundle image. + +1. Build an OCI-compliant image using your preferred build tool, similar to the following example. You must use an image tag that references a repository where you have push access privileges. + + *Example build command* + + ```sh + docker build -f plainbundle.Dockerfile -t \ + quay.io//: . + ``` + +1. Push the image to your remote registry: + + ```sh + docker push quay.io//: + ``` + +### Additional resources + +* [File-based catalog bundle schema](https://github.com/operator-framework/olm-docs/blob/master/content/en/docs/Reference/file-based-catalogs.md) +* [OCI image specification](https://github.com/opencontainers/image-spec#oci-image-format-specification) +* [RukPak > Building a plain bundle > Image source](https://github.com/operator-framework/rukpak/blob/main/docs/bundles/plain.md#image-source) +* [RukPak > Sources > Images > Private image registries](https://github.com/operator-framework/rukpak/blob/main/docs/sources/image.md#private-image-registries) + +## Creating a file-based catalog + +If you do not have a file-based catalog, you must perform the following steps to initialize the catalog. + +

+Prerequisites +

+ +* `opm` CLI tool +* Docker or Podman + +

+Procedure +

+ +1. Create a directory for the catalog by running the following command: + + ```sh + mkdir + ``` + +1. In the same directory level, create a Dockerfile that can build a catalog image: + + ```sh + touch Dockerfile + ``` + + * The Dockerfile must be in the same parent directory as the catalog directory that you created in the previous step: + *Example directory structure* + + ```sh + . + ├── + └── .Dockerfile + ``` + +1. Make the following changes to your Dockerfile: + + *Example Dockerfile* + + ```sh + FROM scratch + ADD /configs + ``` + + > **Note:** Use the `FROM scratch` directive to make the size of the image smaller. + +1. Populate the catalog with the package definition for your Operator by running the `opm init` command: + + ```sh + opm init \ + --output json \ + > /index.json + ``` + + This command generates an `olm.package` declarative config blob in the specified catalog configuration file. + +## Adding a plain bundle to your file-based catalog + +Currently, the `opm render` command does not support adding plain bundles to catalogs. You must manually add plain bundles to your file-based catalog, as shown in the following example. + +

+Prerequisites +

+ +* `opm` CLI tool +* A plain bundle image +* A file-based catalog +* Push access to a container registry, such as [Quay](https://quay.io) +* Docker or Podman + +

+Procedure +

+ +1. Verify that your catalog's `index.json` or `index.yaml` file is similar to the following example: + + *Example `/index.json` file* + + ```json + { + { + "schema": "olm.package", + "name": "", + } + } + ``` + +1. To create an `olm.bundle` blob, edit your `index.json` or `index.yaml` file, similar to the following example: + + *Example `/index.json` file* + + ```json + { + "schema": "olm.bundle", + "name": ".v", + "package": "", + "image": "quay.io//:", + "properties": [ + { + "type": "olm.package", + "value": { + "packageName": "", + "version": "" + } + }, + { + "type": "olm.bundle.mediatype", + "value": "plain+v0" + } + ] + } + ``` + +1. To create an `olm.channel` blob, edit your `index.json` or `index.yaml` file, similar to the following example: + + *Example `/index.json` file* + + ```json + { + "schema": "olm.channel", + "name": "", + "package": "", + "entries": [ + { + "name": ".v" + } + ] + } + ``` + + > **Note:** Please refer to [channel naming conventions](https://olm.operatorframework.io/docs/best-practices/channel-naming/) for choosing the . An example of the is `candidate-v0`. + +

+Verification +

+ +1. Open your `index.json` or `index.yaml` file and ensure it is similar to the following example: + + *Example `index.json` file* + + ```json + { + "schema": "olm.package", + "name": "example-operator", + } + { + "schema": "olm.bundle", + "name": "example-operator.v0.0.1", + "package": "example-operator", + "image": "quay.io/rashmigottipati/example-operator-bundle:v0.0.1", + "properties": [ + { + "type": "olm.package", + "value": { + "packageName": "example-operator", + "version": "v0.0.1" + } + }, + { + "type": "olm.bundle.mediatype", + "value": "plain+v0" + } + ] + } + { + "schema": "olm.channel", + "name": "preview", + "package": "example-operator", + "entries": [ + { + "name": "example-operator.v0.0.1" + } + ] + } + ``` + +## Building and publishing a file-based catalog + +

+Procedure +

+ +1. Run the following command to build your catalog as an image: + + ```sh + docker build -f .Dockerfile -t \ + quay.io//: . + ``` + +1. Run the following command to push the catalog image: + + ```sh + docker push quay.io//: + ``` diff --git a/staging/operator-registry/go.mod b/staging/operator-registry/go.mod index 9c8af7e0c8..efca010495 100644 --- a/staging/operator-registry/go.mod +++ b/staging/operator-registry/go.mod @@ -23,20 +23,20 @@ require ( github.com/onsi/gomega v1.27.7 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.0.2 - github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42 + github.com/operator-framework/api v0.17.7 github.com/otiai10/copy v1.2.0 github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.2 - github.com/spf13/cobra v1.6.0 - github.com/stretchr/testify v1.8.1 + github.com/spf13/cobra v1.7.0 + github.com/stretchr/testify v1.8.3 go.etcd.io/bbolt v1.3.6 golang.org/x/mod v0.10.0 golang.org/x/net v0.10.0 golang.org/x/sync v0.2.0 golang.org/x/sys v0.8.0 golang.org/x/text v0.9.0 - google.golang.org/grpc v1.51.0 + google.golang.org/grpc v1.54.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200709232328-d8193ee9cc3e google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v2 v2.4.0 @@ -58,7 +58,7 @@ require ( github.com/Microsoft/hcsshim v0.8.25 // indirect github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect github.com/alessio/shellescape v1.4.1 // indirect - github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect + github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bshuster-repo/logrus-logstash-hook v0.4.1 // indirect @@ -93,7 +93,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/cel-go v0.12.6 // indirect + github.com/google/cel-go v0.15.3 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect @@ -102,7 +102,7 @@ require ( github.com/gorilla/mux v1.8.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect github.com/imdario/mergo v0.3.12 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -146,12 +146,13 @@ require ( go.opentelemetry.io/otel/trace v1.10.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect golang.org/x/crypto v0.7.0 // indirect + golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect golang.org/x/oauth2 v0.5.0 // indirect golang.org/x/term v0.8.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.9.1 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect + google.golang.org/genproto v0.0.0-20230525154841-bd750badd5c6 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/staging/operator-registry/go.sum b/staging/operator-registry/go.sum index eed9c7da5c..87549f5b3b 100644 --- a/staging/operator-registry/go.sum +++ b/staging/operator-registry/go.sum @@ -64,8 +64,8 @@ github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVK github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= -github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -299,8 +299,8 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/cel-go v0.12.6 h1:kjeKudqV0OygrAqA9fX6J55S8gj+Jre2tckIm5RoG4M= -github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= +github.com/google/cel-go v0.15.3 h1:W1wIeGuEs81+lBVU+cQRg1hkRT58Q6bNxvM5yn008S8= +github.com/google/cel-go v0.15.3/go.mod h1:YzWEoI07MC/a/wj9in8GeVatqfypkldgBlwXh9bCwqY= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -388,8 +388,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1: github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= -github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -510,8 +510,8 @@ github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc= -github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42 h1:d/Pnr19TnmIq3zQ6ebewC+5jt5zqYbRkvYd37YZENQY= -github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42/go.mod h1:l/cuwtPxkVUY7fzYgdust2m9tlmb8I4pOvbsUufRb24= +github.com/operator-framework/api v0.17.7 h1:NLn+Ieg+HaPrw75KbX4efllN21ofFArQzS3q8TDbQY0= +github.com/operator-framework/api v0.17.7/go.mod h1:lnurXgadLnoZ7pufKMHkErr2BVOIZSpHtvEkHBcKvdk= github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= @@ -593,8 +593,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= -github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -619,8 +619,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -704,6 +705,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo= +golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -979,8 +982,8 @@ google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230525154841-bd750badd5c6 h1:62QuyPXKEkZpjZesyj5K5jABl6MnSnWl+vNuT5oz90E= +google.golang.org/genproto v0.0.0-20230525154841-bd750badd5c6/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1000,8 +1003,8 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200709232328-d8193ee9cc3e h1:4BwkYybqoRhPKm97iNO3ACkxj26G0hC18CaO9QXOxto= google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200709232328-d8193ee9cc3e/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/examples v0.0.0-20201130180447-c456688b1860/go.mod h1:Ly7ZA/ARzg8fnPU9TyZIxoz33sEUuWX7txiqs8lPTgE= diff --git a/staging/operator-registry/pkg/cache/json.go b/staging/operator-registry/pkg/cache/json.go index 0899a6f4f8..4327082794 100644 --- a/staging/operator-registry/pkg/cache/json.go +++ b/staging/operator-registry/pkg/cache/json.go @@ -165,13 +165,16 @@ func (q *JSON) existingDigest() (string, error) { } func (q *JSON) computeDigest(fbcFsys fs.FS) (string, error) { + // We are not sensitive to the size of this buffer, we just need it to be shared. + // For simplicity, do the same as io.Copy() would. + buf := make([]byte, 32*1024) computedHasher := fnv.New64a() - if err := fsToTar(computedHasher, fbcFsys); err != nil { + if err := fsToTar(computedHasher, fbcFsys, buf); err != nil { return "", err } if cacheFS, err := fs.Sub(os.DirFS(q.baseDir), jsonDir); err == nil { - if err := fsToTar(computedHasher, cacheFS); err != nil && !errors.Is(err, os.ErrNotExist) { + if err := fsToTar(computedHasher, cacheFS, buf); err != nil && !errors.Is(err, os.ErrNotExist) { return "", fmt.Errorf("compute hash: %v", err) } } diff --git a/staging/operator-registry/pkg/cache/tar.go b/staging/operator-registry/pkg/cache/tar.go index b368e011e9..92e83c1817 100644 --- a/staging/operator-registry/pkg/cache/tar.go +++ b/staging/operator-registry/pkg/cache/tar.go @@ -13,7 +13,12 @@ import ( // This function unsets user and group information in the tar archive so that readers // of archives produced by this function do not need to account for differences in // permissions between source and destination filesystems. -func fsToTar(w io.Writer, fsys fs.FS) error { +func fsToTar(w io.Writer, fsys fs.FS, buf []byte) error { + if buf == nil || len(buf) == 0 { + // We are not sensitive to the size of this buffer, we just need it to be shared. + // For simplicity, do the same as io.Copy() would. + buf = make([]byte, 32*1024) + } tw := tar.NewWriter(w) if err := fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error { if err != nil { @@ -52,7 +57,7 @@ func fsToTar(w io.Writer, fsys fs.FS) error { return fmt.Errorf("open file %q: %v", path, err) } defer f.Close() - if _, err := io.Copy(tw, f); err != nil { + if _, err := io.CopyBuffer(tw, f, buf); err != nil { return fmt.Errorf("write tar data for %q: %v", path, err) } return nil diff --git a/staging/operator-registry/pkg/cache/tar_test.go b/staging/operator-registry/pkg/cache/tar_test.go index fc3c68b976..d95321f934 100644 --- a/staging/operator-registry/pkg/cache/tar_test.go +++ b/staging/operator-registry/pkg/cache/tar_test.go @@ -51,7 +51,7 @@ func Test_fsToTar(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { w := bytes.Buffer{} - err := fsToTar(&w, tc.fsys()) + err := fsToTar(&w, tc.fsys(), nil) tc.expect(t, w.Bytes(), err) }) } diff --git a/vendor/github.com/operator-framework/operator-registry/cmd/opm/serve/serve.go b/vendor/github.com/operator-framework/operator-registry/cmd/opm/serve/serve.go index fc3c482ff8..6a3add607b 100644 --- a/vendor/github.com/operator-framework/operator-registry/cmd/opm/serve/serve.go +++ b/vendor/github.com/operator-framework/operator-registry/cmd/opm/serve/serve.go @@ -36,8 +36,9 @@ type serve struct { port string terminationLog string - debug bool - pprofAddr string + debug bool + pprofAddr string + captureProfiles bool logger *logrus.Entry } @@ -80,7 +81,8 @@ will not be reflected in the served content. cmd.Flags().BoolVar(&s.debug, "debug", false, "enable debug logging") cmd.Flags().StringVarP(&s.terminationLog, "termination-log", "t", "/dev/termination-log", "path to a container termination log file") cmd.Flags().StringVarP(&s.port, "port", "p", "50051", "port number to serve on") - cmd.Flags().StringVar(&s.pprofAddr, "pprof-addr", "", "address of startup profiling endpoint (addr:port format)") + cmd.Flags().StringVar(&s.pprofAddr, "pprof-addr", "localhost:6060", "address of startup profiling endpoint (addr:port format)") + cmd.Flags().BoolVar(&s.captureProfiles, "pprof-capture-profiles", false, "capture pprof CPU profiles") cmd.Flags().StringVar(&s.cacheDir, "cache-dir", "", "if set, sync and persist server cache directory") cmd.Flags().BoolVar(&s.cacheOnly, "cache-only", false, "sync the serve cache and exit without serving") cmd.Flags().BoolVar(&s.cacheEnforceIntegrity, "cache-enforce-integrity", false, "exit with error if cache is not present or has been invalidated. (default: true when --cache-dir is set and --cache-only is false, false otherwise), ") @@ -92,8 +94,10 @@ func (s *serve) run(ctx context.Context) error { if err := p.startEndpoint(); err != nil { return fmt.Errorf("could not start pprof endpoint: %v", err) } - if err := p.startCpuProfileCache(); err != nil { - return fmt.Errorf("could not start CPU profile: %v", err) + if s.captureProfiles { + if err := p.startCpuProfileCache(); err != nil { + return fmt.Errorf("could not start CPU profile: %v", err) + } } // Immediately set up termination log diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/cache/json.go b/vendor/github.com/operator-framework/operator-registry/pkg/cache/json.go index 0899a6f4f8..4327082794 100644 --- a/vendor/github.com/operator-framework/operator-registry/pkg/cache/json.go +++ b/vendor/github.com/operator-framework/operator-registry/pkg/cache/json.go @@ -165,13 +165,16 @@ func (q *JSON) existingDigest() (string, error) { } func (q *JSON) computeDigest(fbcFsys fs.FS) (string, error) { + // We are not sensitive to the size of this buffer, we just need it to be shared. + // For simplicity, do the same as io.Copy() would. + buf := make([]byte, 32*1024) computedHasher := fnv.New64a() - if err := fsToTar(computedHasher, fbcFsys); err != nil { + if err := fsToTar(computedHasher, fbcFsys, buf); err != nil { return "", err } if cacheFS, err := fs.Sub(os.DirFS(q.baseDir), jsonDir); err == nil { - if err := fsToTar(computedHasher, cacheFS); err != nil && !errors.Is(err, os.ErrNotExist) { + if err := fsToTar(computedHasher, cacheFS, buf); err != nil && !errors.Is(err, os.ErrNotExist) { return "", fmt.Errorf("compute hash: %v", err) } } diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/cache/tar.go b/vendor/github.com/operator-framework/operator-registry/pkg/cache/tar.go index b368e011e9..92e83c1817 100644 --- a/vendor/github.com/operator-framework/operator-registry/pkg/cache/tar.go +++ b/vendor/github.com/operator-framework/operator-registry/pkg/cache/tar.go @@ -13,7 +13,12 @@ import ( // This function unsets user and group information in the tar archive so that readers // of archives produced by this function do not need to account for differences in // permissions between source and destination filesystems. -func fsToTar(w io.Writer, fsys fs.FS) error { +func fsToTar(w io.Writer, fsys fs.FS, buf []byte) error { + if buf == nil || len(buf) == 0 { + // We are not sensitive to the size of this buffer, we just need it to be shared. + // For simplicity, do the same as io.Copy() would. + buf = make([]byte, 32*1024) + } tw := tar.NewWriter(w) if err := fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error { if err != nil { @@ -52,7 +57,7 @@ func fsToTar(w io.Writer, fsys fs.FS) error { return fmt.Errorf("open file %q: %v", path, err) } defer f.Close() - if _, err := io.Copy(tw, f); err != nil { + if _, err := io.CopyBuffer(tw, f, buf); err != nil { return fmt.Errorf("write tar data for %q: %v", path, err) } return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index c30b2a6706..72d4433ec3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -642,7 +642,7 @@ github.com/openshift/client-go/config/informers/externalversions/config github.com/openshift/client-go/config/informers/externalversions/config/v1 github.com/openshift/client-go/config/informers/externalversions/internalinterfaces github.com/openshift/client-go/config/listers/config/v1 -# github.com/operator-framework/api v0.17.6 => ./staging/api +# github.com/operator-framework/api v0.17.7 => ./staging/api ## explicit; go 1.19 github.com/operator-framework/api/crds github.com/operator-framework/api/pkg/constraints