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

in_calyptia_fleet: fleet id search by name must use exact name. #9561

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

lecaros
Copy link
Contributor

@lecaros lecaros commented Nov 6, 2024

Given that this search is to get a fleet id, it should only return either 0 or 1 match. For this, this must be case-sensitive and do not return partial matches.

This is based on https://github.com/chronosphereio/calyptia-backend/blob/2704bda975697f64fd962a3d0d2d3bc6dae247ac/components/cloud/spec/open-api.yml#L9706-L9709

and https://github.com/chronosphereio/calyptia-backend/blob/2704bda975697f64fd962a3d0d2d3bc6dae247ac/components/cloud/internal/postgres/search.go#L15-L19


Tests with the CLI:

Starting point is, I have a fleet named TEST-case

➜  ~ calyptia create fleet --name test-case
Error: fleet name taken
➜  ~ calyptia get fleet test-case
Error: could not find fleet "test-case"
➜  ~ calyptia get fleet TEST-case
NAME      TAGS AGE
TEST-case      1 hour

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Given that this search is to get a fleet id, it should only return either 0 or 1 match. For this, this must be case-sensitive and do not return partial matches.

Signed-off-by: lecaros <[email protected]>
@lecaros
Copy link
Contributor Author

lecaros commented Nov 6, 2024

Test 1

Expected behavior: it should be able to find the fleet config, given it's using the exact case-sensitive name of the existing Fleet. (TEST-case)

[CUSTOM]
    Name calyptia
    API_Key a_secret_key
    Fleet_Name TEST-case
    Calyptia_Host cloud-api.calyptia.com

Output:

➜  fluent-bit git:(lecaros-fix-fleet-search-by-name) ✗ $FBIT_HOME/fluent-bit -c test-fleet.conf
Fluent Bit v3.2.0
* Copyright (C) 2015-2024 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____ 
|  ___| |                | |   | ___ (_) |         |____ |/ __  \
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   __   / /`' / /'
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \  / /  
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V /.___/ /./ /___
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)_____/


[2024/11/06 13:02:46] [ info] [fluent bit] version=3.2.0, commit=a9ccd4484f, pid=50017
[2024/11/06 13:02:46] [ info] [custom:calyptia:calyptia.0] custom initialized!
[2024/11/06 13:02:46] [ info] [storage] ver=1.1.6, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/11/06 13:02:46] [ info] [simd    ] disabled
[2024/11/06 13:02:46] [ info] [cmetrics] version=0.9.9
[2024/11/06 13:02:46] [ info] [ctraces ] version=0.5.7
[2024/11/06 13:02:46] [ info] [input:fluentbit_metrics:fluentbit_metrics.0] initializing
[2024/11/06 13:02:46] [ info] [input:fluentbit_metrics:fluentbit_metrics.0] storage_strategy='memory' (memory only)
[2024/11/06 13:02:46] [ info] [input:calyptia_fleet:calyptia_fleet.1] initializing
[2024/11/06 13:02:46] [ info] [input:calyptia_fleet:calyptia_fleet.1] storage_strategy='memory' (memory only)
[2024/11/06 13:02:46] [ info] [input:calyptia_fleet:calyptia_fleet.1] initializing calyptia fleet input.
[2024/11/06 13:02:46] [ info] [input:calyptia_fleet:calyptia_fleet.1] loading configuration from /tmp/calyptia-fleet/75ad55b4e1bc88472ecaabd098a8622df5c2e408622086a06e39cdaabc9fada4/TEST-case/cur.conf.
[2024/11/06 13:02:46] [ info] [input:calyptia_fleet:calyptia_fleet.1] changing to config dir: /tmp/calyptia-fleet/75ad55b4e1bc88472ecaabd098a8622df5c2e408622086a06e39cdaabc9fada4/TEST-case/1730918056
[2024/11/06 13:02:46] [ info] [input:calyptia_fleet:calyptia_fleet.1] changing to config dir: /tmp/calyptia-fleet/75ad55b4e1bc88472ecaabd098a8622df5c2e408622086a06e39cdaabc9fada4/TEST-case/1730918056
[2024/11/06 13:02:46] [ info] [sp] stream processor started
[2024/11/06 13:02:51] [engine] caught signal (SIGHUP)
[2024/11/06 13:02:51] [ info] reloading instance pid=50017 tid=0x2046a0f40
[2024/11/06 13:02:51] [ info] [reload] stop everything of the old context
[2024/11/06 13:02:51] [ info] [input] pausing fluentbit_metrics.0
[2024/11/06 13:02:51] [ info] [input] pausing calyptia_fleet.1
[2024/11/06 13:02:51] [ info] [reload] start everything
[2024/11/06 13:02:51] [ info] [fluent bit] version=3.2.0, commit=a9ccd4484f, pid=50017
[2024/11/06 13:02:51] [ info] [custom:calyptia:calyptia.0] custom initialized!
[2024/11/06 13:02:51] [ info] [storage] ver=1.1.6, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/11/06 13:02:51] [ info] [simd    ] disabled
[2024/11/06 13:02:51] [ info] [cmetrics] version=0.9.9
[2024/11/06 13:02:51] [ info] [ctraces ] version=0.5.7
[2024/11/06 13:02:51] [ info] [input:dummy:dummy.0] initializing
[2024/11/06 13:02:51] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2024/11/06 13:02:51] [ info] [input:fluentbit_metrics:fluentbit_metrics.1] initializing
[2024/11/06 13:02:51] [ info] [input:fluentbit_metrics:fluentbit_metrics.1] storage_strategy='memory' (memory only)
[2024/11/06 13:02:51] [ info] [input:calyptia_fleet:calyptia_fleet.2] initializing
[2024/11/06 13:02:51] [ info] [input:calyptia_fleet:calyptia_fleet.2] storage_strategy='memory' (memory only)
[2024/11/06 13:02:51] [ info] [input:calyptia_fleet:calyptia_fleet.2] initializing calyptia fleet input.
[2024/11/06 13:02:51] [error] [/Users/lecaros/workspaces/fluent/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:386 errno=22] Invalid argument
[2024/11/06 13:02:51] [error] [/Users/lecaros/workspaces/fluent/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:386 errno=22] Invalid argument
[2024/11/06 13:02:51] [ info] [sp] stream processor started
[2024/11/06 13:02:51] [ info] [output:stdout:stdout.0] worker #0 started
[0] dummy.4aaf0fd6-0f0c-47a3-92b1-7432382f5f3f: [[1730908972.830858000, {}], {"message"=>"dummy"}]
[0] dummy.4aaf0fd6-0f0c-47a3-92b1-7432382f5f3f: [[1730908973.831118000, {}], {"message"=>"dummy"}]
[0] dummy.4aaf0fd6-0f0c-47a3-92b1-7432382f5f3f: [[1730908974.831680000, {}], {"message"=>"dummy"}]
[0] dummy.4aaf0fd6-0f0c-47a3-92b1-7432382f5f3f: [[1730908975.831461000, {}], {"message"=>"dummy"}]
^C[2024/11/06 13:02:57] [engine] caught signal (SIGINT)

Test 2:

Expected behavior: It should not find the fleet since it's using the fleet name all lowercase.

[CUSTOM]
    Name calyptia
    API_Key a_secret_key
    Fleet_Name test-case
    Calyptia_Host cloud-api.calyptia.com
➜  fluent-bit git:(lecaros-fix-fleet-search-by-name) ✗ $FBIT_HOME/fluent-bit -c test-fleet.conf
Fluent Bit v3.2.0
* Copyright (C) 2015-2024 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____ 
|  ___| |                | |   | ___ (_) |         |____ |/ __  \
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   __   / /`' / /'
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \  / /  
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V /.___/ /./ /___
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)_____/


[2024/11/06 13:23:12] [ info] [fluent bit] version=3.2.0, commit=a9ccd4484f, pid=52980
[2024/11/06 13:23:12] [ info] [custom:calyptia:calyptia.0] custom initialized!
[2024/11/06 13:23:12] [ info] [storage] ver=1.1.6, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/11/06 13:23:12] [ info] [simd    ] disabled
[2024/11/06 13:23:12] [ info] [cmetrics] version=0.9.9
[2024/11/06 13:23:12] [ info] [ctraces ] version=0.5.7
[2024/11/06 13:23:12] [ info] [input:fluentbit_metrics:fluentbit_metrics.0] initializing
[2024/11/06 13:23:12] [ info] [input:fluentbit_metrics:fluentbit_metrics.0] storage_strategy='memory' (memory only)
[2024/11/06 13:23:12] [ info] [input:calyptia_fleet:calyptia_fleet.1] initializing
[2024/11/06 13:23:12] [ info] [input:calyptia_fleet:calyptia_fleet.1] storage_strategy='memory' (memory only)
[2024/11/06 13:23:12] [ info] [input:calyptia_fleet:calyptia_fleet.1] initializing calyptia fleet input.
[2024/11/06 13:23:12] [error] [/Users/lecaros/workspaces/fluent/fluent-bit/plugins/in_calyptia_fleet/in_calyptia_fleet.c:386 errno=22] Invalid argument
[2024/11/06 13:23:12] [ warn] [input:calyptia_fleet:calyptia_fleet.1] unable to find latest configuration file
[2024/11/06 13:23:12] [ info] [sp] stream processor started
[2024/11/06 13:23:28] [error] [input:calyptia_fleet:calyptia_fleet.1] unable to find fleet: test-case
[2024/11/06 13:23:28] [error] [input:calyptia_fleet:calyptia_fleet.1] unable to find fleet: test-case

@lecaros lecaros marked this pull request as ready for review November 6, 2024 16:29
@niedbalski niedbalski merged commit 48ccda0 into master Nov 6, 2024
52 of 53 checks passed
@niedbalski niedbalski deleted the lecaros-fix-fleet-search-by-name branch November 6, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants