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

fix(banzai/KafkaCluster): Update health.lua #15962

Merged
merged 6 commits into from
Oct 25, 2023
Merged

fix(banzai/KafkaCluster): Update health.lua #15962

merged 6 commits into from
Oct 25, 2023

Conversation

OneCricketeer
Copy link
Contributor

@OneCricketeer OneCricketeer commented Oct 13, 2023

Updates the Lua logic to more correctly count broker objects

Closes #15963

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

@OneCricketeer OneCricketeer requested a review from a team as a code owner October 13, 2023 19:15
@OneCricketeer OneCricketeer changed the title [banzai/KafkaCluster] Update health.lua fix(banzai/KafkaCluster): Update health.lua Oct 13, 2023
Copy link

@ctrlaltluc ctrlaltluc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OneCricketeer thanks for your help with this! I left some questions, mostly for my understanding. Thanks in advance for your patience! (:

@ecojan
Copy link

ecojan commented Oct 18, 2023

Tried running this locally with lua,
The Lua # operator only counts entries with integer keys so might not work here,
can you try something similar with

        counter = 0
        brokers = 0
        for _, broker in pairs(obj.status.brokersState) do
            if broker.configurationState == "ConfigInSync" then
                if broker.gracefulActionState.cruiseControlState == "GracefulUpscaleSucceeded" or broker.gracefulActionState.cruiseControlState == "GracefulDownscaleSucceeded" then
                    counter = counter + 1
                end
            end
            brokers = brokers + 1
        end
        if counter == brokers then        

@OneCricketeer
Copy link
Contributor Author

OneCricketeer commented Oct 18, 2023

only counts entries with integer keys

@ecojan Thanks, but I'm not so sure? It's a table length operator. You can look at my commit history, and you'll see I tried the explicit counter, and the tests were still failing with that, so something else is causing the tests to fail, and I'm just not seeing it.

Ref https://en.m.wikibooks.org/wiki/Lua_Programming/length_operator

I converted my logic to Python even, and I cannot reproduce the failure

I may need to look more at how I can setup this test bed locally and setup a debugger

@OneCricketeer
Copy link
Contributor Author

OneCricketeer commented Oct 18, 2023

Ah, I see.

length operator returns zero for tables when the first numeric key is nil or there are no numeric keys.

Apologies.

Also see Stackoverflow answers simply suggesting not to use # and rather do explicit loop

Uses ipairs() to correctly iterates over indexed elements

Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (9e0e8d5) 49.62% compared to head (7328136) 49.62%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15962   +/-   ##
=======================================
  Coverage   49.62%   49.62%           
=======================================
  Files         267      267           
  Lines       46479    46479           
=======================================
  Hits        23063    23063           
  Misses      21144    21144           
  Partials     2272     2272           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@34fathombelow 34fathombelow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@alex-necula alex-necula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can we merge this PR?

@alexmt alexmt merged commit f1d3d66 into argoproj:master Oct 25, 2023
27 checks passed
@OneCricketeer OneCricketeer deleted the patch-1 branch October 25, 2023 14:58
ymktmk pushed a commit to ymktmk/argo-cd that referenced this pull request Oct 29, 2023
fix(banzai/KafkaCluster): Update health.lua (argoproj#15962)

Uses ipairs() to correctly iterates over indexed elements

Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
jmilic1 pushed a commit to jmilic1/argo-cd that referenced this pull request Nov 13, 2023
fix(banzai/KafkaCluster): Update health.lua (argoproj#15962)

Uses ipairs() to correctly iterates over indexed elements

Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Signed-off-by: jmilic1 <70441727+jmilic1@users.noreply.github.com>
vladfr pushed a commit to vladfr/argo-cd that referenced this pull request Dec 13, 2023
fix(banzai/KafkaCluster): Update health.lua (argoproj#15962)

Uses ipairs() to correctly iterates over indexed elements

Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
tesla59 pushed a commit to tesla59/argo-cd that referenced this pull request Dec 16, 2023
fix(banzai/KafkaCluster): Update health.lua (argoproj#15962)

Uses ipairs() to correctly iterates over indexed elements

Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Hariharasuthan99 pushed a commit to AmadeusITGroup/argo-cd that referenced this pull request Jun 16, 2024
fix(banzai/KafkaCluster): Update health.lua (argoproj#15962)

Uses ipairs() to correctly iterates over indexed elements

Signed-off-by: Jordan Moore <1930631+OneCricketeer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

BanzaiCloud KafkaCluster healthcheck assumes incremental ids, starting at 0
7 participants