Merge branch 'master' into fix/auto-execution

pull/6105/head
Jakub Bednář 2024-11-26 09:58:45 +01:00 committed by GitHub
commit fbaa580f13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 261 additions and 26 deletions

View File

@ -4,6 +4,13 @@ orbs:
aws-s3: circleci/aws-s3@2.0.0
parameters:
trigger:
type: enum
enum: [none, deploy-as-artifacts]
default: none
workflows:
version: 2
main:
@ -69,6 +76,15 @@ workflows:
tags:
only: /^[0-9]+(\.[0-9]+)*$/
trigger:
when:
equal: [ deploy-as-artifacts, << pipeline.parameters.trigger >> ]
jobs:
- build
- build-nightly:
requires:
- build
jobs:
build:
environment:
@ -123,6 +139,27 @@ jobs:
- store_artifacts:
path: ./build/
build-nightly:
environment:
DOCKER_TAG: chronograf-20240919
GO111MODULE: "ON"
machine:
image: ubuntu-2204:current
steps:
- attach_workspace:
at: /home/circleci
- run: |
./etc/scripts/docker/run.sh \
--debug \
--clean \
--package \
--platform all \
--arch all \
--nightly \
--version=${CIRCLE_SHA1:0:7}
- store_artifacts:
path: ./build/
deploy-pre-release:
environment:
DOCKER_TAG: chronograf-20240919

View File

@ -4,6 +4,7 @@
1. [#6103](https://github.com/influxdata/chronograf/pull/6103): Set active database for InfluxQL meta queries.
2. [#6105](https://github.com/influxdata/chronograf/pull/6105): Prevent dangerous InfluxQL statements from auto-execution.
3. [#6111](https://github.com/influxdata/chronograf/pull/6111): Loading Hosts page for large number of hosts.
### Other

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

View File

@ -50,4 +50,19 @@ git push --tags
* OS X
* amd64
* Windows
* amd64
* amd64
## Testing builds
The test builds are stored as artifacts on the CircleCI build page. If you want to create a test build, you can do it by triggering a pipeline on CircleCI.
During the trigger of the pipeline, you should specify the `trigger` parameter with the value `deploy-as-artifacts`:
<p align="left">
<img src="./images/testing-builds-pipeline.png"/>
</p>
The resulting artifacts will be available on the CircleCI build page for `build-nightly` Job:
<p align="left">
<img src="./images/testing-builds-result.png"/>
</p>

2
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/NYTimes/gziphandler v1.1.1
github.com/abbot/go-http-auth v0.4.0
github.com/bouk/httprouter v0.0.0-20160817010721-ee8b3818a7f5
github.com/golang-jwt/jwt/v4 v4.0.0
github.com/golang-jwt/jwt/v4 v4.5.1
github.com/google/go-cmp v0.5.5
github.com/google/go-github v17.0.0+incompatible
github.com/google/uuid v1.1.2

4
go.sum
View File

@ -259,8 +259,8 @@ github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48/go.mod h1:SlYgWuQ5
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o=
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/gddo v0.0.0-20181116215533-9bd4a3295021/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec h1:lJwO/92dFXWeXOZdoGXgptLmNLwynMSHUmU6besqtiw=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=

View File

@ -83,7 +83,7 @@ func TestAuthenticate(t *testing.T) {
{
Desc: "Test jwt with empty subject is invalid",
Secret: "secret",
Token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOi00NDY3NzQ0MDAsImV4cCI6LTQ0Njc3NDQwMCwibmJmIjotNDQ2Nzc0NDAwfQ.gxsA6_Ei3s0f2I1TAtrrb8FmGiO25OqVlktlF_ylhX4",
Token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOi00NDY3NzQ0MDAsImV4cCI6LTQ0Njc3NDM5OSwibmJmIjotNDQ2Nzc0NDAwfQ.Ik90GX1cLvTQzkFvKgBxDPIi-GZsIqFhqQlCxek9TPg",
Duration: time.Second,
Principal: oauth2.Principal{
Subject: "",
@ -104,6 +104,18 @@ func TestAuthenticate(t *testing.T) {
},
Err: errors.New("claims duration is different from auth lifespan"),
},
{
Desc: "Test expiration time is present",
Secret: "secret",
Token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIvY2hyb25vZ3JhZi92MS91c2Vycy8xIiwibmFtZSI6IkRvYyBCcm93biIsImlhdCI6LTQ0Njc3NDQwMCwiZXhwIjotNDQ2Nzc0NDAwLCJuYmYiOi00NDY3NzQ0MDB9._rZ4gOIei9PizHOABH6kLcJTA3jm8ls0YnDxtz1qeUI",
Duration: time.Second,
Principal: oauth2.Principal{
Subject: "/chronograf/v1/users/1",
ExpiresAt: history.Add(time.Second),
IssuedAt: history,
},
Err: errors.New("token is expired by 0s"),
},
}
for _, test := range tests {
j := oauth2.JWT{

View File

@ -28,7 +28,7 @@
"@parcel/transformer-sass": "^2.6.2",
"assert": "^2.0.0",
"events": "^3.3.0",
"http-proxy-middleware": "^2.0.6",
"http-proxy-middleware": "^2.0.7",
"process": "^0.11.10",
"querystring-es3": "^0.2.1",
"util": "^0.12.4"

View File

@ -49,13 +49,13 @@ export const getCpuAndLoadForHosts = async (
tempVars: Template[]
): Promise<HostsObject> => {
const query = replaceTemplate(
`SELECT mean("usage_user") FROM \":db:\".\":rp:\".\"cpu\" WHERE "cpu" = 'cpu-total' AND time > now() - 10m GROUP BY host;
`SHOW TAG VALUES WITH KEY = "host" WHERE TIME > now() - 10m;
SELECT mean("usage_user") FROM \":db:\".\":rp:\".\"cpu\" WHERE "cpu" = 'cpu-total' AND time > now() - 10m GROUP BY host;
SELECT mean("load1") FROM \":db:\".\":rp:\".\"system\" WHERE time > now() - 10m GROUP BY host;
SELECT non_negative_derivative(mean(uptime)) AS deltaUptime FROM \":db:\".\":rp:\".\"system\" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);
SELECT mean("Percent_Processor_Time") FROM \":db:\".\":rp:\".\"win_cpu\" WHERE time > now() - 10m GROUP BY host;
SELECT mean("Processor_Queue_Length") FROM \":db:\".\":rp:\".\"win_system\" WHERE time > now() - 10m GROUP BY host;
SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM \":db:\".\":rp:\".\"win_system\" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);
SHOW TAG VALUES WITH KEY = "host" WHERE TIME > now() - 10m;`,
SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM \":db:\".\":rp:\".\"win_system\" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);`,
tempVars
)
@ -65,15 +65,19 @@ export const getCpuAndLoadForHosts = async (
db: telegrafDB,
})
return parseHostsObject(data)
}
export const parseHostsObject = (data: any): HostsObject => {
const hosts: HostsObject = {}
const precision = 100
const cpuSeries = getDeep<Series[]>(data, 'results.[0].series', [])
const loadSeries = getDeep<Series[]>(data, 'results.[1].series', [])
const uptimeSeries = getDeep<Series[]>(data, 'results.[2].series', [])
const winCPUSeries = getDeep<Series[]>(data, 'results.[3].series', [])
const winLoadSeries = getDeep<Series[]>(data, 'results.[4].series', [])
const winUptimeSeries = getDeep<Series[]>(data, 'results.[5].series', [])
const allHostsSeries = getDeep<Series[]>(data, 'results.[6].series', [])
const allHostsSeries = getDeep<Series[]>(data, 'results.[0].series', [])
const cpuSeries = getDeep<Series[]>(data, 'results.[1].series', [])
const loadSeries = getDeep<Series[]>(data, 'results.[2].series', [])
const uptimeSeries = getDeep<Series[]>(data, 'results.[3].series', [])
const winCPUSeries = getDeep<Series[]>(data, 'results.[4].series', [])
const winLoadSeries = getDeep<Series[]>(data, 'results.[5].series', [])
const winUptimeSeries = getDeep<Series[]>(data, 'results.[6].series', [])
allHostsSeries.forEach(s => {
const hostnameIndex = s.columns.findIndex(col => col === 'value')

View File

@ -12,6 +12,7 @@ jest.mock('src/hosts/apis', () => require('mocks/hosts/apis'))
jest.mock('src/shared/apis/env', () => require('mocks/shared/apis/env'))
import {getCpuAndLoadForHosts} from 'src/hosts/apis'
const {parseHostsObject} = jest.requireActual('src/hosts/apis')
const setup = (override = {}) => {
const props = {
@ -64,3 +65,168 @@ describe('Hosts.Containers.HostsPage', () => {
})
})
})
describe('Parsing HostsObject', () => {
let cpu_load_hosts
beforeEach(() => {
cpu_load_hosts = {
results: [
{
statement_id: 0,
series: [
{
name: 'cpu',
columns: ['key', 'value'],
values: [['host', 'my-host1']],
},
{
name: 'db_query',
columns: ['key', 'value'],
values: [['host', 'my-host2']],
},
],
},
{
statement_id: 1,
series: [
{
name: 'cpu',
tags: {host: 'my-host1'},
columns: ['time', 'mean'],
values: [[1718874564091, 2.2943182130124]],
},
{
name: 'cpu',
tags: {host: 'my-host2'},
columns: ['time', 'mean'],
values: [[1718874564092, 4.2943182130124]],
},
],
},
{
statement_id: 2,
series: [
{
name: 'system',
tags: {host: 'my-host1'},
columns: ['time', 'mean'],
values: [[1718874564111, 1.5699999999999]],
},
{
name: 'system',
tags: {host: 'my-host2'},
columns: ['time', 'mean'],
values: [[1718874564112, 2.5699999999999]],
},
],
},
{
statement_id: 3,
series: [
{
name: 'system',
tags: {host: 'my-host1'},
columns: ['time', 'deltaUptime'],
values: [
[1718874540001, 753231],
[1718874600001, 60],
[1718874660001, 60],
[1718874720001, 60],
[1718874780001, 60],
[1718874840001, 60],
[1718874900001, 60],
[1718874960001, 60],
[1718875020001, 60],
[1718875080001, 60],
[1718875140001, 60],
],
},
{
name: 'system',
tags: {host: 'my-host2'},
columns: ['time', 'deltaUptime'],
values: [
[2718874540002, 753232],
[2718874600002, 60],
[2718874660002, 60],
[2718874720002, 60],
[2718874780002, 60],
[2718874840002, 60],
[2718874900002, 60],
[2718874960002, 60],
[2718875020002, 60],
[2718875080002, 60],
[2718875140002, 70],
],
},
],
},
{statement_id: 4},
{statement_id: 5},
{statement_id: 6},
],
uuid: '123456789',
}
})
it('parse', () => {
const hosts = parseHostsObject(cpu_load_hosts)
expect(hosts['my-host1']).toStrictEqual({
name: 'my-host1',
cpu: 2.29,
load: 1.57,
deltaUptime: 60,
apps: [],
})
expect(hosts['my-host2']).toStrictEqual({
name: 'my-host2',
cpu: 4.29,
load: 2.57,
deltaUptime: 70,
apps: [],
})
expect(hosts['my-host3']).toBeUndefined()
})
it('missing in cpu', () => {
cpu_load_hosts.results[1].series = [cpu_load_hosts.results[1].series[0]]
const hosts = parseHostsObject(cpu_load_hosts)
expect(hosts['my-host1']).toBeDefined()
expect(hosts['my-host1']).toStrictEqual({
name: 'my-host1',
cpu: 2.29,
load: 1.57,
deltaUptime: 60,
apps: [],
})
expect(hosts['my-host2']).toStrictEqual({
name: 'my-host2',
cpu: 0,
load: 2.57,
deltaUptime: 70,
apps: [],
})
expect(hosts['my-host3']).toBeUndefined()
})
it('missing in host', () => {
const series = cpu_load_hosts.results[0].series[0]
cpu_load_hosts.results[0].series = [series]
const hosts = parseHostsObject(cpu_load_hosts)
expect(hosts['my-host1']).toBeDefined()
expect(hosts['my-host1']).toStrictEqual({
name: 'my-host1',
cpu: 2.29,
load: 1.57,
deltaUptime: 60,
apps: [],
})
expect(hosts['my-host2']).toStrictEqual({
name: 'my-host2',
cpu: 4.29,
load: 2.57,
deltaUptime: 70,
apps: [],
})
expect(hosts['my-host3']).toBeUndefined()
})
})

View File

@ -4164,9 +4164,9 @@ create-react-class@^15.5.1:
object-assign "^4.1.1"
cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
version "6.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.6.tgz#30d0efa0712ddb7eb5a76e1e8721bffafa6b5d57"
integrity sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
@ -4175,9 +4175,9 @@ cross-spawn@^6.0.0:
which "^1.2.9"
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
version "7.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
@ -6091,10 +6091,10 @@ http-proxy-agent@^5.0.0:
agent-base "6"
debug "4"
http-proxy-middleware@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f"
integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==
http-proxy-middleware@^2.0.7:
version "2.0.7"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6"
integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==
dependencies:
"@types/http-proxy" "^1.17.8"
http-proxy "^1.18.1"