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

Adding pagination for installation list result using skip and limit option #2136

Closed

Conversation

joshuabezaleel
Copy link
Contributor

What does this change

User that use the Porter CLI can use --skip and --limit flag for paginating their list output.

What issue does it fix

Closes #2051

Notes for the reviewer

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

carolynvs and others added 30 commits November 18, 2021 10:38
I accidentally tried to use a fallthrough, which go doesn't support. I
have fixed GetBuilder and added a unit test to validate that it is
creating a build driver for all cases.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Replace / with - in branch names, so that release/v1 resolves to https://release-v1.porter.sh

Signed-off-by: Carolyn Van Slyck <[email protected]>
* Use distroless base image

Use a distroless base image for our porter docker images. This
has less of an attack surface because it only ships
the essentials to run porter, not the extra stuff that usually comes
with a linux distribution.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Apply suggestions from code review

Signed-off-by: Carolyn Van Slyck <[email protected]>

Co-authored-by: Nathaniel "Church" Hatfield <[email protected]>

* Move agent's run.sh into Go

Since the nonroot distroless image doesn't have a shell, we can't use
run.sh to copy the porter config files into PORTER_HOME at container
start. I have implemented that in Go (sorry it's a lot vs what good ole
cp did for us under the hood).

One trick is that when /porter-config is mounted into the container by
k8s, it uses symlinks like this:

/porter-config
  ..data/porter.config
  porter.config -> ..data/porter.config

So it's not a straightforward as you'd think at first glance.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Apply suggestions from code review

Signed-off-by: Carolyn Van Slyck <[email protected]>
Co-authored-by: Vaughn Dice <[email protected]>
Co-authored-by: Nathaniel "Church" Hatfield <[email protected]>
Co-authored-by: Vaughn Dice <[email protected]>
* Fix Pushing Bundles that have a relocationMap (getporter#1815)
* chore: add avinashupadhya99 to Contributors.md
* docs: remove accidental packr word from contribution guide
* Improve error message when cnab-to-oci fixes up a bundle
* docs: fix command in contrib tutorial
* docs: update parameters doc with allowable types (getporter#1792)

Signed-off-by: Carolyn Van Slyck <[email protected]>
Log to a file in ~/.porter/logs/CORRELLATION_ID.json and in colored human readable
output to stderr. When stderr is not a TTY, color is omitted (which is
what we need for piping to a file or running on headless CI servers).

Tracing has been enabled using open-telemetry and can be configured with
the standard OTEL environment variables.

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specify-protocol

This is just a stub of the final tracing and log switch over, that lays
down a framework for converting the rest and instrumenting more
commands. For now we start a trace for the command executed.

Signed-off-by: Carolyn Van Slyck <[email protected]>
This binds the --driver flag for porter install|invoke|upgrade|uninstall
to the PORTER_RUNTIME_DRIVER environment variable used by the operator.

I had already done this for PORTER_BUILD_DRIVER, but missed adding
similar configuration bindings for runtime.

So in the config file, the user can set rutime-driver and build-driver.
The environment variables are named: PORTER_RUNTIME_DRIVER and
PORTER_BUILD_DRIVER. The flag though on any command is just --driver for
simplicity, e.g. porter install --driver kubernetes.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Makes it easier for people to know which version of the docs they are on (v0.38 or v1.0.0) and switch between the two. Long term, a better strategy for versioning the docs site would be great but this is a small change that we can do right now.

Signed-off-by: Carolyn Van Slyck <[email protected]>
* sync go mod

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Allow mixins to ignore a failed command

Add the HasErrorHandling interface to the shared pkg/exec/builder
package used by all the mixins. When implemented, a mixin can examine a
failed command and optionaly handle it.

The exec mixin now supports ignoring failed commands, which demonstrates
how to use builder.IgnoreErrorHandler struct to use the same error
handling behavior.

Closes getporter#592

Signed-off-by: Carolyn Van Slyck <[email protected]>
The mage/mixins package contains common magefile targets that all mixins
use: build, test, publish, etc. This minimizes the amount of custom
logic in our magefiles and should make it easier to manage the magefile
in all the mixins going forward.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Signed-off-by: Mahendra Bishnoi <[email protected]>
…t-registry

Change default registry to localhost:5000
Use the system porter that was installed by the EnsurePorter target.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Allow someone to just publish binaries or also publish a mixin feed.

Signed-off-by: Carolyn Van Slyck <[email protected]>
…ot exist (getporter#1828)

* Porter triggers autobuild when detecting that invocation image does not exist

Signed-off-by: joshuabezaleel <[email protected]>

* 1. Change function name from IsInvocationImagExists to IsImageCached along with some explanation comment.
2. Use invocationImage directly as an input to list images
3. Wrap error from Docker SDK and remove error wrap on stamp.go
4. Fix wording to "local image cache" from "host registry"

Signed-off-by: joshuabezaleel <[email protected]>
The integration tests accidentally were passing nil for the context
after I added context.Context as a parameter to some Porter commands in getporter#1831.
This passes in context.Background to fix the nil pointer exceptions that
was causing.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Print out where we are publishing and explain what to do if you use
different repository names.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Pass context from integration tests
…tions

Add package for mixins magefile targets
First check if we have a local copy of porter and use that to generate a
mixin feed. Otherwise assume that porter is installed in the GOPATH.

Signed-off-by: Carolyn Van Slyck <[email protected]>
Use porter from the bin or the PATH
This PR adds missing double quotes for Telemetry struct tag so it can be
properly set if present.

Signed-off-by: Yingrong Zhao <[email protected]>
carolynvs and others added 19 commits May 27, 2022 15:16
When we are converting a porter.yaml to a bundle.json we need the porter
config file so that we can check if the upcoming dependencies2 feature
flag is enabled and conditionally build out a different bundle.

Signed-off-by: Carolyn Van Slyck <[email protected]>
* Update hashicorp plugin page with temp fork

I've updated the Hashicorp plugins documentation page and am instructing
people to install our temporary fork until the upstream repo is
compatible with Porter v1.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Update docs/content/plugins/hashicorp.md

Signed-off-by: Carolyn Van Slyck <[email protected]>

Co-authored-by: Vaughn Dice <[email protected]>

Co-authored-by: Vaughn Dice <[email protected]>
Stop logging directly to stdout(!) and instead log with the current span
so that it is traced.

Signed-off-by: Carolyn Van Slyck <[email protected]>
When the plugin configuration can't be marshaled to json, do not print
the plugin config in the error message as it could contain sensitive
data.

I couldn't figure out how to test this since really we are just handling
the error from json.Marshal but there isn't really a way for bad data to
get to that point in Porter. We'd error out much earlier just reading
the config file.

Signed-off-by: Carolyn Van Slyck <[email protected]>
I found a few spots I missed when removing docker from the build-driver
options.

Signed-off-by: Carolyn Van Slyck <[email protected]>
In a few places, I must have converted from fmt.Println to log.Debugf
and forgot to use placeholders. This fixes the log lines so that they
print properly instead of like this:

  using plugin
  pulling%!(EXTRA string=mongo:4.0-xenial)
  running a mongo server in a container on port%!(EXTRA string=27018)
  waiting for the mongo service to be ready

Signed-off-by: Carolyn Van Slyck <[email protected]>
Signed-off-by: Carolyn Van Slyck <[email protected]>
When I was adding tests for the FindInstallations function, I realized that I'd made a
mistake earlier when defining the FindOptions. It had erroneously
included Group (which is only for Aggregate). In addition, our wrapper
around FindOptions wasn't exposing the Select field.

I've also updated it to use bson.D/M for consistency with the other options and ensure we are
always passing types that will work with our gRPC conversion logic that
specifically handles bson.D.

Signed-off-by: Carolyn Van Slyck <[email protected]>
…gs-exp-flag

Remove structured logs exp flag
When I was adding tests for the FindInstallations function, I realized that I'd made a
mistake earlier when defining the FindOptions. It had erroneously
included Group (which is only for Aggregate). In addition, our wrapper
around FindOptions wasn't exposing the Select field.

I've also updated it to use bson.D/M for consistency with the other options and ensure we are
always passing types that will work with our gRPC conversion logic that
specifically handles bson.D.

Signed-off-by: Carolyn Van Slyck <[email protected]>
* change dependency schema in porter

Signed-off-by: Yingrong Zhao <[email protected]>

* fix testdata

Signed-off-by: Yingrong Zhao <[email protected]>
* Fix race condition in plugin logs routine

When we run a plugin, we start a go routine that captures logs from the
plugin and forwards them to our traceLogger. I've found that there is a
race condition where:

1. We close the plugin
2. The plugin emits a message saying that its closing
3. We cancel the context for the log go routine but ctx.Done doesn't
   immediately trigger on the go routine.
4. Instead the plugin connections's close function returns before the routine
   is stopped.
5. Porter moves on and closes our logger.
6. The log go routine then tries to forward the message to the logger
   which is now closed.

I've added a wait group that ensures that the log go routine finishes
before the plugin connection returns from Close. This ensures that all
resources managed by the plugin connection are cleaned up before Close
returns.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Move when we add to the wait group

Signed-off-by: Carolyn Van Slyck <[email protected]>
@joshuabezaleel
Copy link
Contributor Author

I am sorry I think I made a new branch from the wrong branch/commit, I'll close this one and made another one 😔

@joshuabezaleel
Copy link
Contributor Author

joshuabezaleel commented Jun 6, 2022

Just realized I think it's because the target branch is main, my bad ...

@carolynvs
Copy link
Member

Just a heads up that if the problem was that when you made the PR you accidentally picked "main" instead of "release/v1", you can change that by clicking the edit button by the title of your PR and then you can change the target branch.

@joshuabezaleel
Copy link
Contributor Author

joshuabezaleel commented Jun 7, 2022

@carolynvs My bad, yesterday I thought the edit button was only able to change the title of the particular PR that's why what I did was made another PR for this branch. So sorry for the inconvenience ..

@carolynvs
Copy link
Member

It doesn't inconvenience me at all! I just wanted you to know so that you can fix it next time. 👍

@joshuabezaleel
Copy link
Contributor Author

@carolynvs will always be grateful for you and others being really eaccommodating, Carolyn. thank you so much! Looking forward to the review 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add paging options to porter list and other commands that list installation data
7 participants