Giter Club home page Giter Club logo

scs-build-client's People

Contributors

arangogutierrez avatar dependabot-preview[bot] avatar dependabot[bot] avatar dtrudg avatar emmeff avatar mikegray avatar tfrisch06 avatar tri-adam avatar vlesich-sylabs avatar wobito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scs-build-client's Issues

Improve SubmitBuild

SubmitBuild() currently has a libraryRef and libraryURL parameter. This is confusing for a couple of reasons:

  1. It should be possible to submit a build without specifying a libraryRef or libraryURL. This is arguably the common case in Singularity today. The builder will use its configured Library URL, and auto-generate a path.
  2. I think we should combine these into a single libraryURI parameter, since it should be possible to specify both with a single URI (library://host:port/path:tag).

We can satisfy both of these cases with the same function, but just make it clear which params are optional, and what happens in the case they are not supplied (the Build Service will dictate)?

Failure while attaching attestations to image

The publish-release job failed to run against version v0.7.0 (ref).

The failure was during the Attach attestations to image step:

Generating ephemeral keys...
Retrieving signed certificate...
error opening browser: exec: "xdg-open": executable file not found in $PATH
Go to the following link in a browser:

	 https://oauth2.sigstore.dev/auth/auth?access_type=online&client_id=sigstore&code_challenge=6zCdBdUBBPIFAqQr-H5jwTAzO8Zqnm6Mo3t_5RCYNbU&code_challenge_method=S256&nonce=29G8jQl786Ox6hrXn9zGXtoyYfX&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=openid+email&state=29G8jWQA9kJOiz6JqyfD7Ze6nPX
Enter verification code: 2022/05/16 19:09:56 error during command execution: getting key from Fulcio: retrieving cert: oauth2: cannot fetch token: 400 Bad Request
Response: {"error":"invalid_request","error_description":"Required param: code."}

Exited with code exit status 1

Data Race in Unit Test

Seeing an occasional data race reported during testing. This appears to be related to the mockService, so it's possibly an issue with the unit tests themselves.

One recent example can be found here. Dump from that run:

==================
WARNING: DATA RACE
Write at 0x00c0001244c8 by goroutine 30:
  github.com/sylabs/scs-build-client/client_test.TestOutput.func1()
      /root/project/client/output_test.go:93 +0x1e4
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /usr/local/go/src/testing/testing.go:1306 +0x47

Previous read at 0x00c0001244c8 by goroutine 41:
  github.com/sylabs/scs-build-client/client_test.(*mockService).ServeWebsocket()
      /root/project/client/mock_test.go:142 +0x2f6
  github.com/sylabs/scs-build-client/client_test.(*mockService).ServeWebsocket-fm()
      /root/project/client/mock_test.go:128 +0x57
  net/http.HandlerFunc.ServeHTTP()
      /usr/local/go/src/net/http/server.go:2047 +0x4d
  net/http.(*ServeMux).ServeHTTP()
      /usr/local/go/src/net/http/server.go:2425 +0xc5
  net/http.serverHandler.ServeHTTP()
      /usr/local/go/src/net/http/server.go:2879 +0x89a
  net/http.(*conn).serve()
      /usr/local/go/src/net/http/server.go:1930 +0x12e4
  net/http.(*Server).Serve·dwrap·87()
      /usr/local/go/src/net/http/server.go:3034 +0x58

Goroutine 30 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1306 +0x726
  github.com/sylabs/scs-build-client/client_test.TestOutput()
      /root/project/client/output_test.go:82 +0x7f2
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /usr/local/go/src/testing/testing.go:1306 +0x47

Goroutine 41 (finished) created at:
  net/http.(*Server).Serve()
      /usr/local/go/src/net/http/server.go:3034 +0x847
  net/http/httptest.(*Server).goServe.func1()
      /usr/local/go/src/net/http/httptest/server.go:308 +0xc4
==================
some_outputsome_output--- FAIL: TestOutput (0.01s)
    --- FAIL: TestOutput/OutputReaderFailure (0.00s)
        testing.go:1152: race detected during execution of test
    testing.go:1152: race detected during execution of test
FAIL
coverage: 82.8% of statements
FAIL	github.com/sylabs/scs-build-client/client	0.044s
FAIL

Exited with code exit status 1

Verify Go 1.13 Compatibility

Update CI to verify this module is (and continues to be) compatible with Go v1.13. The cache_go_mod step should be unnecessary, with the default module proxy serving a similar purpose.

Remove Logger

The github.com/sylabs/scs-build-client/client package exposes a log.Logger. In all but one case, it is logging things that the package user already has visibility into. For that reason, I think it might be best to simplify the package by removing the logging.

Incorrect error message when using malformed library ref

[tfrisch@wedge ~]$ scs-build build –-sign docker://alpine:3 library://user/default/alpine:3
Application init error: unsupported library ref scheme docker
Error: application init error: unsupported library ref scheme docker

The actual error is with the "library://" library ref, not with the docker URI

Publish Container

We should generate an scs-build container and publish it when a release is cut.

Future Proofing

We should take some time to examine the API for opportunities to reduce the exported API surface, and/or make future extensions possible without breaking API compatibility, such as using functional options and accessors, where appropriate.

Simplify GetOutput

GetOutput currently accepts an type OutputReader interface, which the caller must implement:

// OutputReader interface is used to read the websocket output from the stream
type OutputReader interface {
// Read is called when a websocket message is received
Read(messageType int, p []byte) (int, error)
}

The messageType int here is problematic, because it requires the caller to understand implementation details. In particular, the caller needs to understand the possible messageType values, and how to handle them. In practice, these are defined as "text" and "binary" in RFC 6455. All implementations that I could find handle text messages, and discard binary ones.

With all that in mind, I propose we change the signature from this:

func (c *Client) GetOutput(ctx context.Context, buildID string, or OutputReader) error

To this:

func (c *Client) GetOutput(ctx context.Context, buildID string, w io.Writer) error

This way, the caller doesn't need to worry about any of the web socket implementation details under the hood, and can pass any io.Writer such as os.Stdout, simplifying usage.

Unauthorized errors reported as "HTTP status 401"

When attempting to perform a build using an expired auth token, the reported error message isn't clear to the end user:

Error: error uploading build context: error getting build context files: def file parse error: build server error (HTTP status 401)

This should be a more user friendly message indicating the token is invalid.

Validate URL Scheme

NewClient() does not currently validate the URL scheme. If a Config.BaseURL value is passed that does not contain http or https, commands that rely on Client.BaseURL will fail. To make this a little more user friendly, I propose we validate the URL scheme in NewClient().

Reduce Coupling to Definition Struct?

I'm a little concerned about our use of Definition rather than taking a raw definition file. This structure closely mimics an internal data structure in Singularity, and that data structure is evolving over time. As a practical example of how this might get messy, multi-stage builds (sylabs/singularity#2518) has significantly changed this structure.

BaseURL Path Handling Bug

When a Client is created with a path component (ex. https://example.com/path), the path component ends up being ignored when building up request URLs.

The problem originates in (*Client).newRequest, which calls (*url.URL).ResolveReference to construct a request URI to BaseURL/path. When the path parameter begins with a /, it is treated as an absolute path and thus any path component of the BaseURL is ignored.

Push Failure for Certain Ref Formats

When building and pushing directly to Library refs with certain formats, the build succeeds but the image is not pushed, and an error is displayed:

$ docker run -e SYLABS_AUTH_TOKEN="${SYLABS_AUTH_TOKEN}" \
    sylabsio/scs-build build docker://alpine library://cloud.sylabs.io/sylabs-adam/a/c
Building for amd64...
...
FATAL:   Unable to push image to library: malformed image path: /sylabs-adam/a/c

It looks to me as if this is failing for any ref format other than library:path:tags. Will need to trace through to see if this is a problem in this module, or in the ref parsing code.

Attestation workflow fails for tagged releases

Error from CircleCI:

Command "packages" is deprecated, use `syft scan` instead
Using payload from: sbom.cdx.json
Error: signing sylabsio/scs-build:0.9.5-amd64: signing: getting fetching default hash function: getting public key: operation error KMS: GetPublicKey, failed to sign request: failed to retrieve credentials: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, http response error StatusCode: 404, request to EC2 IMDS failed
main.go:62: error during command execution: signing sylabsio/scs-build:0.9.5-amd64: signing: getting fetching default hash function: getting public key: operation error KMS: GetPublicKey, failed to sign request: failed to retrieve credentials: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, http response error StatusCode: 404, request to EC2 IMDS failed

Exited with code exit status 1

Improve StreamOutput

A couple of suggestions:

  1. We should remove wsURL string as a parameter and always use c.BaseURL as the URL. In practice, these must always be the same URL, and keeping this level of flexibility will likely cause more confusion that it's worth.
  2. At the moment, StreamOutput() prints messages of type TextMessage to os.Stdout, and for each message of type websocket.BinaryMessage it outputs "Ignoring binary message" to os.Stdout. This behaviour could be problematic for clients, who might wish the text output to go somewhere other than os.Stdout, and/or handle websocket.BinaryMessage messages.

What about if we define an OutputReader interface with a Read(messageType int, p []byte) (n int, error) method? We could then change the function prototype to be:

func (c *Client) StreamOutput(ctx context.Context, or OutputReader) error

Docker container image does not contain /tmp

Which results in error as follows when attempting to build def file containing %files section:

Building for amd64...
Error: failed to build amd64: open /tmp/scs-build-context-502634966: no such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.