Commit Graph
1940 Commits
Author SHA1 Message Date
Jim 2b3e50ebdd fix (listing): return all resources from listing requests (#3278) 2023-06-05 12:53:59 -04:00
Michael Gaffney 8159ddb08e feat(db): Add function to update billing snapshot table
This adds the `update_sessions_pending_daily_snapshot` SQL function
which updates the `sessions_pending_daily_snapshot` table by inserting
values for any days missing from the table.

This also adds a check constraint to the
`sessions_pending_daily_snapshot` table along with a `comment on table`.

This also removes the hcp daily billing views since they are no longer
needed.

Ref: ace2def49d
2023-06-05 12:48:15 -04:00
Michael Gaffney 41bdfb4406 fix(db): Fix time zone consistency issues in monthly billing views
The hcp monthly billing views build a range of buckets using the
`generate_series` and the `now()` functions along with relative offsets
like `+ 1 month`. The calculated start and end times for these views can
vary depending on the time zone setting of the PostgreSQL server.

This adds 3 table functions that call their respective views with the
time zone set to UTC. Calling these functions instead of their
underlying views directly prevents the returned values from varying when
the server's time zone is not set to UTC.

This also drops support for PostgreSQL 11. The included tests use the
`date_trunc(field, source [, time_zone ])` function added in PostgreSQL
12.

Fixes: 41b1b5b4b7
2023-06-05 12:48:15 -04:00
Michael Gaffney 47ddd2e40a fix(db): Fix generated series to yield consistent results
The hcp billing `_all` views built a range of buckets using the
`generate_series` function using the minimum value of the
`session_pending_time` column from the `wh_session_accumulating_fact`
table as the start time and `now()` as the end time. It then truncated
values in the series using the `date_trunc` function. This allowed the
generated series of buckets returned to vary and could result in one
additional bucket being included in the series depending on the current
time and the start time.

As an illustrative example, the `hourly_all` query used:

    select date_trunc('hour',time)
      from generate_series(
             (select min(session_pending_time) -- start time
                from wh_session_accumulating_fact),
              now(),
              '1 hour'::interval
           ) as time;

Substituting the start time with a hard coded value to show the issue:

    -- Show current time, where the minutes portion is 55
    select now();
                  now
    -------------------------------
     2023-05-22 14:55:40.567605+00
    (1 row)

    -- generate series with start time's minutes portion at 57
    select date_trunc('hour',time)
      from generate_series(
              '2023-05-22 01:57:00'::timestamptz,
              now(),
              '1 hour'::interval
           ) as time;

           date_trunc
    ------------------------
     2023-05-22 01:00:00+00
     2023-05-22 02:00:00+00
     2023-05-22 03:00:00+00
     2023-05-22 04:00:00+00
     2023-05-22 05:00:00+00
     2023-05-22 06:00:00+00
     2023-05-22 07:00:00+00
     2023-05-22 08:00:00+00
     2023-05-22 09:00:00+00
     2023-05-22 10:00:00+00
     2023-05-22 11:00:00+00
     2023-05-22 12:00:00+00
     2023-05-22 13:00:00+00
    (13 rows)

    -- Wait a few minutes
    select now();
                 now
    ------------------------------
     2023-05-22 14:58:48.75287+00
    (1 row)

    -- Now run again and get an extra result, even though still
    -- within the same hour
    select date_trunc('hour',time)
      from generate_series(
              '2023-05-22 01:57:00'::timestamptz,
              now(),
              '1 hour'::interval
           ) as time;

           date_trunc
    ------------------------
     2023-05-22 01:00:00+00
     2023-05-22 02:00:00+00
     2023-05-22 03:00:00+00
     2023-05-22 04:00:00+00
     2023-05-22 05:00:00+00
     2023-05-22 06:00:00+00
     2023-05-22 07:00:00+00
     2023-05-22 08:00:00+00
     2023-05-22 09:00:00+00
     2023-05-22 10:00:00+00
     2023-05-22 11:00:00+00
     2023-05-22 12:00:00+00
     2023-05-22 13:00:00+00
     2023-05-22 14:00:00+00
    (14 rows)

To fix this, we call the `generate_series` function truncating the start
time argument to the bucket size:

    -- Hourly
    select bucket
      from generate_series(
              date_trunc('hour', select min(session_pending_time)
                                   from wh_session_accumulating_fact)),
              now(),
              '1 hour'::interval
           ) as bucket;

    -- Monthly
    select bucket
      from generate_series(
              date_trunc('month', select min(session_pending_time)
                                    from wh_session_accumulating_fact)),
              now(),
              '1 month'::interval
           ) as bucket;

Fixes: 41b1b5b4b7
2023-06-05 12:48:15 -04:00
Jim 5029be9999 fix: allow responses larger than the default 4194304 recv msg size (#3276) 2023-06-05 12:13:05 -04:00
Michael Gaffney 053e74f66c feat(db): Add table for census upload job status 2023-06-05 11:32:26 -04:00
Michael Gaffney 8bf80e0544 test(db): Conditionally skip monthly billing view tests
Certain tests fail when run on the first day of the month because of
edge cases in the setup of test data. This adds conditional logic to
skip those tests when run on the first day of a month.
2023-06-04 09:31:40 -04:00
Dharini Jeeva 9f5e2020ba Chore UI bump (#3271)
* ui changes

* ui changes
2023-06-02 16:18:06 -07:00
Todd 2d102a61c5 HcpbWorkers no longer must be KMS workers for LookupHcpbWorkers (#3269) 2023-06-02 13:53:37 -07:00
Jeff Mitchell 1b0330ad8e Update dev worker auth flag names (#3265)
This brings it in line with the updated names that have been settled on
in light of deprecating the old KMS method.
2023-06-02 12:47:59 -04:00
Louis Ruch 281f217dcc feat(plugins): Refactor host plugins to boundary plugins (#3262) 2023-06-02 08:04:50 -07:00
Johan Brandhorst-Satzkorn 97977f1995 update perms table for session recordings and storage buckets (#3253) 2023-06-01 12:45:27 -07:00
Cameron Perera 5a64946f9d chore: bump ui commit (#3261) 2023-06-01 11:47:48 -05:00
Cameron Perera 1cd084459d chore: bump UI commit (#3259) 2023-06-01 09:35:17 -05:00
Johan Brandhorst-Satzkorn 0c8177590f Upgrade grpc-gateway dependency (#3257)
* proto: correct classification of authz token

The target authorization token had the invalid classification
"private". Fortunately, classification is a fail-closed system,
so this won't have exposed users authorization tokens, but
we should still use the correct classification. Use "secret".

* scripts: add Go script to remove gotags comments

The new version of grpc-gateway includes our gotags
comments in the generate swagger documentation. This
script removes all mentions of these.

* Upgrade grpc-gateway dependency

Mainly we need this to fix generation of our docs side API docs,
but it also includes a nice fix for the new Download RPC, i.e. it
now contains the correct response schema (a binary stream).
2023-06-01 06:41:09 -07:00
Jim d4e537c88d chore: updgrade pgx direct deps to v5 (#3258) 2023-06-01 08:59:38 -04:00
Jim 536551dc0c fix: update go-dbw dep and refactor conversion of pgx errors (#3242) 2023-05-31 20:23:33 -04:00
Jeff Mitchell 3d5bed9ce8 Don't allow managed workers to be deleted (#3254)
This also adds checks to ensure the tag cannot be added to workers via
the API.
2023-05-31 14:23:57 -04:00
Timothy Messier 61a37ef4a4 fix(schema): Add missing endpoint column to session recording view 2023-05-31 15:53:16 +00:00
Timothy Messier f64f03ed46 fix(targets): Support authorize session request with target name (#3252)
For requests to the target authorize session endpoint we support passing
a target name instead of an id. This means that `req.GetId()` might not
be the target's public id. Since the first thing authorize session does
includes retrieving the target as part of the authorization checks, this
subtype check can leverage the public id of the target instead of using
the request.

Fixes: 6178dd516e
2023-05-31 11:25:03 -04:00
Timothy Messier c2da88d2a5 test(cmd/config): Fix test compilation error
Refs: 9ae2bdfae
2023-05-31 12:47:20 +00:00
Timothy Messier cdf18b6369 test(cli/targets): Add test case for default client port 2023-05-31 12:18:24 +00:00
Todd fb1ea92a30 Pass both the control and data context into handle 2023-05-31 12:18:24 +00:00
irenarindos 8c96d3ef9b fix(cmd): add session recording resource prefixes 2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn 3e07b2ffaf bsr: rename fields and remove project id from meta 2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn 64764e29e5 bsr: invert credential, cred store relationship
This lifts the credential sources up to the top of
the SessionMeta struct, avoiding indirection through
the credential stores.
2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn e0700570a2 bsr: add endpoint to session meta
The endpoint stores the address of the host
the egress worker proxies to.
2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn 59f78ac1f8 config: allow wasm execution under UI CSP
The wasm-unsafe-eval option is necessary for the asciinema
player on the Admin UI
2023-05-31 12:18:24 +00:00
Danielle Miu b4137a14c3 update test.sh to use loopback flag 2023-05-31 12:18:24 +00:00
Damian Debkowski e7420eb690 fix(plugin): correct spelling mistake 2023-05-31 12:18:24 +00:00
Todd 6178dd516e Let a target subtype validate the authorize session's session state 2023-05-31 12:18:23 +00:00
Timothy Messier 9f2c83f3b0 refact(bsr): Rename const to denote when interpolation is needed 2023-05-31 12:18:23 +00:00
Jim 21e4827178 fix(Upstream Msg): limit types used in tests 2023-05-31 12:18:23 +00:00
Timothy Messier b88b4cce75 feat(bsr/ssh): Add file transfer direction to channel summary
When an SSH channel is used for a file transfer, the summary will report
the detected direction of the file transfer as either an upload or
download, relative to the end client.
2023-05-31 12:18:23 +00:00
Timothy Messier 78ea1a9f3a refact(bsr): Use JSON for session meta and summary data
The session metadata is provided all at once when a new bsr is opened.
While the session recording metadata records metadata about a recording
while the recording is happening, notably it records each time a new
connection occurs.

The nested structure of the session metadata does not lend itself to the
append-only syntax of the recording meta file. In addition we do not
want to mix different kinds of metadata together. Thus the session
metadata is now written to a separate file in the BSR, and is written as
JSON which better handles the nested structure and allows for simpler
encoding/decoding.

Similarly the summary files are intended to be written to as containers
close and have been switched to JSON.
2023-05-31 12:18:23 +00:00
Jim 7dc15f1f39 fix(Upstream Msg): limit types supported in toMsgType(...) 2023-05-31 12:18:23 +00:00
Louis Ruch 203d4bb048 fix(storage): Remove client 2023-05-31 12:18:23 +00:00
Danielle Miu 1052118836 remove field masks from proto 2023-05-31 12:18:23 +00:00
Louis Ruch f0e95d7267 docs(storage): Update comments 2023-05-31 12:18:23 +00:00
Timothy Messier f53d65eacd refact(sql): Rename migrations to avoid number conflicts 2023-05-31 12:18:23 +00:00
Todd 2359d5b7a5 remove filter flags and options for session recordings 2023-05-31 12:18:23 +00:00
Todd d1a5f3a2ff Update attribute fields to be proto struct so generated api becomes map[string]any 2023-05-31 12:18:22 +00:00
irenarindos 4785f2388f chore(session recording): update cmd typo 2023-05-31 12:18:22 +00:00
Todd 4063880bbe Add credential history views 2023-05-31 12:18:22 +00:00
Louis Ruch 95398d3b65 fix(dev): Fix panic in controller-only dev mode
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0x16626b0]

goroutine 1 [running]:
github.com/hashicorp/boundary/internal/cmd/commands/dev.(*Command).Run(0xc000b90000, {0xc00003e110, 0x1, 0x1})
        github.com/hashicorp/boundary/internal/cmd/commands/dev/dev.go:484 +0x490
github.com/mitchellh/cli.(*CLI).Run(0xc0003323c0)
        github.com/mitchellh/cli@v1.1.5/cli.go:262 +0x5f8
github.com/hashicorp/boundary/internal/cmd.RunCustom({0xc00003e100?, 0x60?, 0x0?}, 0x0?)
        github.com/hashicorp/boundary/internal/cmd/main.go:189 +0xa16
github.com/hashicorp/boundary/internal/cmd.Run(...)
        github.com/hashicorp/boundary/internal/cmd/main.go:95
main.main()
        github.com/hashicorp/boundary/cmd/boundary/main.go:16 +0xc7
2023-05-31 12:18:22 +00:00
Louis Ruch 9a3006e42a feat(storage): Include type plugin in API response for buckets 2023-05-31 12:18:22 +00:00
Jim 468c58836b feat(recordings/cli): more read detail info 2023-05-31 12:18:22 +00:00
Damian Debkowski 9aa4d40d95 feat(storage): provide optional chunk size field for GetObject 2023-05-31 12:18:22 +00:00
irenarindos b57692f8fc chore(bsr): check index bounds for meta unmarshal 2023-05-31 12:18:22 +00:00
Jim d49fde2299 feat(cli/session-recordings): add download cmd 2023-05-31 12:18:22 +00:00