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

Merge branch 'main' into feature/vote-decrypt #943

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
5844e32
new settings for one participant multiple times in the LoS (#851)
Elblinator Feb 21, 2024
0b22803
Bump github.com/gomodule/redigo from 1.8.9 to 1.9.1 (#852)
dependabot[bot] Feb 21, 2024
0084811
Update meta repository (#853)
openslides-automation[bot] Feb 22, 2024
b1e2777
Remove update-generated-files.yml (#854)
jsangmeister Feb 22, 2024
e0a5319
Bump github.com/klauspost/compress from 1.17.6 to 1.17.7 (#856)
dependabot[bot] Feb 22, 2024
2f45636
Change restricter for motion_change_recommendation (#857)
ostcar Feb 26, 2024
3a3cb3b
Bump github.com/gomodule/redigo from 1.9.1 to 1.9.2 (#858)
dependabot[bot] Feb 26, 2024
4490784
Update meta repository (#860)
openslides-automation[bot] Feb 27, 2024
9eea68a
Restricter: New restriction user/B (#859)
ostcar Feb 27, 2024
ea1a20a
Update meta repository (#863)
openslides-automation[bot] Feb 28, 2024
80c2139
Automatically create PRs for commits on staging branches (#865) (#867)
openslides-automation[bot] Feb 29, 2024
9c3a444
Update meta repository (#868)
openslides-automation[bot] Mar 1, 2024
1b99881
Update meta repository (#869)
openslides-automation[bot] Mar 1, 2024
6723dd7
Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#871)
dependabot[bot] Mar 2, 2024
68f78c4
Yaml (#849)
ostcar Mar 2, 2024
d09cc80
Fixes requests from anonymous user (#873)
ostcar Mar 4, 2024
271e525
Add Maybe-Type for non required fields (#872)
ostcar Mar 4, 2024
275f119
Update meta repository (#875)
openslides-automation[bot] Mar 4, 2024
4d420d5
Add free text submitter field (#864)
jsangmeister Mar 4, 2024
c7329c9
Update meta repository (#878)
openslides-automation[bot] Mar 4, 2024
23fefdc
Bump github.com/jackc/pgx/v5 from 5.5.3 to 5.5.4 (#880)
dependabot[bot] Mar 5, 2024
512c4d1
Bump golang.org/x/sys from 0.17.0 to 0.18.0 (#879)
dependabot[bot] Mar 5, 2024
561d4c7
Automatically close feature branch issues (#882)
jsangmeister Mar 6, 2024
d5e2210
Bump golang from 1.22.0-alpine to 1.22.1-alpine (#883)
dependabot[bot] Mar 6, 2024
3a9a19b
Update meta repository (#881)
openslides-automation[bot] Mar 6, 2024
a271168
Bump github.com/alecthomas/kong from 0.8.1 to 0.9.0 (#884)
dependabot[bot] Mar 11, 2024
a3ba805
Update meta repository (#887)
openslides-automation[bot] Mar 12, 2024
f45ce84
Bump github.com/jackc/pgx/v5 from 5.5.4 to 5.5.5 (#886)
dependabot[bot] Mar 12, 2024
b0f67e5
Update meta repository (#889)
openslides-automation[bot] Mar 14, 2024
8804946
Update meta repository (#891)
openslides-automation[bot] Mar 14, 2024
ca15965
Fix LoS projecion for interposed question (#890)
luisa-beerboom Mar 18, 2024
80b6e1c
Long polling fallback (#833)
ostcar Mar 19, 2024
2948116
Use default routes for profiling (#874)
ostcar Mar 19, 2024
4483625
Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#896)
dependabot[bot] Mar 19, 2024
ad3cce4
Update meta repository (#892)
openslides-automation[bot] Mar 20, 2024
495749f
Bump github.com/docker/docker (#897)
dependabot[bot] Mar 20, 2024
dd728f6
Run go generate for new los setting (#888)
luisa-beerboom Mar 21, 2024
0dcb567
Update meta repository (#899)
openslides-automation[bot] Mar 21, 2024
bbdebcb
Update meta repository (#901)
openslides-automation[bot] Mar 26, 2024
a9342de
Fix close-issues workflow (#902)
jsangmeister Mar 26, 2024
faff2a4
Bump golang.org/x/sys from 0.18.0 to 0.19.0 (#909)
dependabot[bot] Apr 8, 2024
35cb3cf
Update meta repository (#903)
openslides-automation[bot] Apr 8, 2024
e457a25
Bump golang.org/x/sync from 0.6.0 to 0.7.0 (#908)
dependabot[bot] Apr 8, 2024
55b8023
Fix chyron structure level not displayed (#905)
bastianjoel Apr 9, 2024
11f98f8
Fix closes-issues action (#913)
jsangmeister Apr 9, 2024
9393d24
Run go generate for backend #2348 (#911)
luisa-beerboom Apr 10, 2024
0f6c47c
Extend current speaking structure level slide (#915)
bastianjoel Apr 10, 2024
5e3d2bd
Update meta repository (#912)
openslides-automation[bot] Apr 10, 2024
a3c7c70
Update meta repository (#916)
openslides-automation[bot] Apr 16, 2024
4a66d80
Bump github.com/klauspost/compress from 1.17.7 to 1.17.8 (#914)
dependabot[bot] Apr 17, 2024
071bb4b
Bump golang from 1.22.1-alpine to 1.22.2-alpine (#906)
dependabot[bot] Apr 17, 2024
874a016
Fix workerpool (#898)
ostcar Apr 17, 2024
5ab90f2
Fix restricter on vote delegation (#920)
ostcar Apr 18, 2024
7b5d0ee
Update meta repository (#921)
openslides-automation[bot] Apr 18, 2024
ba53a47
Add yaml parser workaround for anchors (#907)
bastianjoel Apr 19, 2024
c3432f6
Update meta repository (#923)
openslides-automation[bot] Apr 23, 2024
3be009e
Update meta repository (#925)
openslides-automation[bot] Apr 26, 2024
71fdc99
Add action for cherry-picking staging changes (#926)
peb-adr Apr 26, 2024
f360fcc
Update meta repository (#927)
openslides-automation[bot] Apr 28, 2024
11de116
Split connection count metirc for longpolling (#929)
ostcar May 2, 2024
1fa40ea
Update meta repository (#931)
openslides-automation[bot] May 7, 2024
e02b112
Bump golang from 1.22.2-alpine to 1.22.3-alpine (#933)
dependabot[bot] May 9, 2024
67b55bd
pick-to-staging: Trigger on pr_target event type (#936)
peb-adr May 15, 2024
198e9de
Update meta repository (#937)
openslides-automation[bot] May 15, 2024
7793a9c
Properly sort staging/* refs to get latest branch (#938)
peb-adr May 17, 2024
26f3e28
Update meta repository (#939)
openslides-automation[bot] May 17, 2024
a59583b
Update meta repository (#940)
openslides-automation[bot] May 21, 2024
78d1c7d
Update meta repository (#942)
openslides-automation[bot] May 27, 2024
b1aef4f
Bump github.com/jackc/pgx/v5 from 5.5.5 to 5.6.0 (#941)
dependabot[bot] May 28, 2024
06e920a
Merge branch 'main' into feature/vote-decrypt
Jun 4, 2024
5a8aedd
Fixed duplicate function
Jun 4, 2024
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
66 changes: 66 additions & 0 deletions .github/workflows/pick-to-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Cherry pick staging PRs merged into main

on:
pull_request_target:
types:
- closed
branches:
- 'main'


jobs:
create-pr-for-staging:
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'staging')
name: Create PR against staging branch
runs-on: ubuntu-latest

steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 2

- name: Fetch and checkout latest staging branch
run: |
branch=$(git ls-remote --heads origin 'staging/*' | awk 'gsub(".*refs/heads/","")' | sort -V | tail -1)
git fetch origin $branch
git checkout $branch

- name: Set git credentials
run: |
git config --global user.name openslides-automation
git config --global user.email [email protected]

- name: Cherry-pick new commit
id: cherry-pick
run: |
git fetch origin
# -m 1 to also be able to cherry-pick merge commits
git cherry-pick -m 1 ${{ github.sha }} || {
echo "error=1" >> $GITHUB_OUTPUT
git add .
git cherry-pick --continue
}

- name: Generate access token
uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.AUTOMATION_APP_ID }}
private_key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }}

- name: Create or update PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.generate-token.outputs.token }}
branch: apply/commit-${{ github.sha }}
delete-branch: true
title: "[Cherry-Pick] ${{ github.event.pull_request.title }}"
body: "Triggered by commit [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n${{ steps.cherry-pick.outputs.error && 'There were conflicts during the cherry-pick. These were commited without any resolving. Please resolve them manually and push the result to this branch before merging.' || 'The cherry-pick was successful without any conflicts. You should be able to simply merge this PR.' }}"
reviewers: ${{ github.event.pull_request.user.login }}
assignees: ${{ github.event.pull_request.user.login }}
labels: picked-to-staging
milestone: 4
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.1-alpine as base
FROM golang:1.22.3-alpine as base
WORKDIR /root/

RUN apk add git
Expand Down
67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,36 +229,49 @@ The logged metric is a json dictonary like:

```json
{
"connected_users_anonymous_connections": 1,
"connected_users_average_connections": 3,
"connected_users_current": 3,
"connected_users_current_local": 3,
"connected_users_total": 3,
"connected_users_total_local": 3,
"current_connections": 8,
"current_connections_local": 8,
"datastore_cache_key_len": 343,
"datastore_cache_size": 3114,
"runtime_goroutines": 42
"connections_longpolling_connected_users_anonymous_connections": 0,
"connections_longpolling_connected_users_average_connections": 3,
"connections_longpolling_connected_users_current": 1,
"connections_longpolling_connected_users_current_local": 1,
"connections_longpolling_connected_users_total": 1,
"connections_longpolling_connected_users_total_local": 1,
"connections_longpolling_current_connections": 3,
"connections_longpolling_current_connections_local": 3,
"connections_stream_connected_users_anonymous_connections": 0,
"connections_stream_connected_users_average_connections": 6,
"connections_stream_connected_users_current": 2,
"connections_stream_connected_users_current_local": 2,
"connections_stream_connected_users_total": 3,
"connections_stream_connected_users_total_local": 3,
"connections_stream_current_connections": 13,
"connections_stream_current_connections_local": 13,
"datastore_cache_key_len": 236478,
"datastore_cache_size": 1722987,
"runtime_goroutines": 68
}
```

The values are:

* `connected_users_anonymous_connections`: Number of connections from the
anonymous users from all autoupdate instances.
* `connected_users_average_connections`: Average connection count for each user
except for anonymous user.
* `connected_users_current`: Amount of connected users that have at least one
open connection.
* `connected_users_current_local`: Amount of connected users that have at least
one open connection of this instance.
* `connected_users_total`: Amount of different users that are currently
connected or were connected since the autoupdate service was started.
* `connected_users_total_local`: Same as `connected_users_total`, but only for this
instance.
* `current_connections`: Amount of all connections.
* `current_connections_local`: Amount of all connections of this instance.
The prefix `connections_stream` are for "normal" connections.
`connections_longpolling` are for connections, that use the longpolling
fallback.



* `connections_stream_connected_users_anonymous_connections`: Number of
connections from the anonymous users from all autoupdate instances.
* `connections_stream_connected_users_average_connections`: Average connection
count for each user except for anonymous user.
* `connections_stream_connected_users_current`: Amount of connected users that
have at least one open connection.
* `connections_stream_connected_users_current_local`: Amount of connected users
that have at least one open connection of this instance.
* `connections_stream_connected_users_total`: Amount of different users that are
currently connected or were connected since the autoupdate service was
started.
* `connections_stream_connected_users_total_local`: Same as
`connected_users_total`, but only for this instance.
* `connections_stream_current_connections`: Amount of all connections.
* `connections_stream_current_connections_local`: Amount of all connections of this instance.
* `datastore_cache_key_len`: Amount of keys in the cache.
* `datastore_cache_size`: Combined size of all values in the cache.
* `runtime_goroutines`: Current goroutines used by the instance.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/goccy/go-yaml v1.11.3
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/gomodule/redigo v1.9.2
github.com/jackc/pgx/v5 v5.5.5
github.com/klauspost/compress v1.17.7
github.com/jackc/pgx/v5 v5.6.0
github.com/klauspost/compress v1.17.8
github.com/nsf/jsondiff v0.0.0-20230430225905-43f6cf3098c1
github.com/ory/dockertest/v3 v3.10.0
github.com/ostcar/topic v0.4.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
Expand Down
4 changes: 2 additions & 2 deletions internal/autoupdate/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ func (a *Autoupdate) skipWorkpool(ctx context.Context, userID int) (bool, error)
return false, fmt.Errorf("checking for admin groups: %w", err)
}

for isAdmin := range adminGroups {
if isAdmin > 0 {
for _, isAdmin := range adminGroups {
if _, ok := isAdmin.Value(); ok {
return true, nil
}
}
Expand Down
59 changes: 33 additions & 26 deletions internal/http/connection_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@ type RedisMetric interface {
Get(ctx context.Context) (map[int]int, error)
}

// connectionCount counts, how many connections a user has.
// ConnectionCount counts, how many connections a user has.
//
// It holds a local counter and saves it to redis after a connection is created
// or closed.
// It holds a local counter and saves it to redis from time to time. The
// argument `saveInterval` defines, how oftem it is saved.
//
// It also pings redis from time to time to show, that this instance is
// still running.
type connectionCount struct {
// It also pings redis from time to time to show, that this instance is still
// running.
type ConnectionCount struct {
metric RedisMetric
name string

mu sync.Mutex
connections map[int]int
}

func newConnectionCount(ctx context.Context, r *redis.Redis, saveInterval time.Duration) *connectionCount {
redisMetric := redis.NewMetric[map[int]int](r, "autoupdate_connection_count", mapIntCombiner{}, saveInterval*2, time.Now)
func newConnectionCount(ctx context.Context, r *redis.Redis, saveInterval time.Duration, name string) *ConnectionCount {
redisMetric := redis.NewMetric[map[int]int](r, name, mapIntCombiner{}, saveInterval*2, time.Now)

c := connectionCount{
c := ConnectionCount{
metric: redisMetric,
name: name,
connections: make(map[int]int),
}

Expand All @@ -60,7 +62,7 @@ func newConnectionCount(ctx context.Context, r *redis.Redis, saveInterval time.D
return &c
}

func (c *connectionCount) save(ctx context.Context) error {
func (c *ConnectionCount) save(ctx context.Context) error {
c.mu.Lock()
converted, err := json.Marshal(c.connections)
c.mu.Unlock()
Expand All @@ -75,31 +77,38 @@ func (c *connectionCount) save(ctx context.Context) error {
return nil
}

func (c *connectionCount) increment(uid int, increment int) {
func (c *ConnectionCount) increment(uid int, increment int) {
c.mu.Lock()
c.connections[uid] += increment
c.mu.Unlock()
}

func (c *connectionCount) Add(uid int) {
// Add adds one connection to the counter.
func (c *ConnectionCount) Add(uid int) {
c.increment(uid, 1)
}

func (c *connectionCount) Done(uid int) {
// Done removes one connection from the counter.
func (c *ConnectionCount) Done(uid int) {
c.increment(uid, -1)
}

func (c *connectionCount) Show(ctx context.Context) (map[int]int, error) {
// Show shoes the counter.
func (c *ConnectionCount) Show(ctx context.Context, filter func(ctx context.Context, count map[int]int) error) (map[int]int, error) {
data, err := c.metric.Get(ctx)
if err != nil {
return nil, fmt.Errorf("getting counter from redis: %w", err)
}

if err := filter(ctx, data); err != nil {
return nil, fmt.Errorf("filtering counter: %w", err)
}

return data, nil
}

// Metric is a function needed my the openslides metric system to fetch some values.
func (c *connectionCount) Metric(con metric.Container) {
func (c *ConnectionCount) Metric(con metric.Container) {
ctx := context.Background()

data, err := c.metric.Get(ctx)
Expand Down Expand Up @@ -145,17 +154,15 @@ func (c *connectionCount) Metric(con metric.Container) {
average = averageSum / averageCount
}

prefix := "connected_users"
con.Add(prefix+"_current", currentConnectedUsers)
con.Add(prefix+"_total", len(data))
con.Add(prefix+"_current_local", localCurrentUsers)
con.Add(prefix+"_total_local", totalCurrentConnections)
con.Add(prefix+"_average_connections", average)
con.Add(prefix+"_anonymous_connections", data[0])

prefix = "current_connections"
con.Add(prefix, currentConnections)
con.Add(prefix+"_local", localCurrentConnections)
con.Add(c.name+"_connected_users_current", currentConnectedUsers)
con.Add(c.name+"_connected_users_total", len(data))
con.Add(c.name+"_connected_users_current_local", localCurrentUsers)
con.Add(c.name+"_connected_users_total_local", totalCurrentConnections)
con.Add(c.name+"_connected_users_average_connections", average)
con.Add(c.name+"_connected_users_anonymous_connections", data[0])

con.Add(c.name+"_current_connections", currentConnections)
con.Add(c.name+"_current_connections_local", localCurrentConnections)
}

// mapIntCombiner tells the redis Metric, how to combine the metric values.
Expand Down
Loading
Loading