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

PMM-13540 Fix pmm client v3 build for nomad. #3298

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

talhabinrizwan
Copy link
Contributor

@talhabinrizwan talhabinrizwan commented Nov 12, 2024

PMM-13540

Link to the Feature Build: SUBMODULES-3766

@talhabinrizwan talhabinrizwan requested a review from a team as a code owner November 12, 2024 08:11
@talhabinrizwan talhabinrizwan requested review from idoqo and JiriCtvrtka and removed request for a team November 12, 2024 08:11
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.53%. Comparing base (6bfa326) to head (4127d38).
Report is 1 commits behind head on v3.

Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #3298      +/-   ##
==========================================
- Coverage   43.54%   43.53%   -0.01%     
==========================================
  Files         366      366              
  Lines       44162    44162              
==========================================
- Hits        19232    19228       -4     
- Misses      23249    23252       +3     
- Partials     1681     1682       +1     
Flag Coverage Δ
admin 11.47% <ø> (-0.05%) ⬇️
agent 51.96% <ø> (ø)
managed 45.25% <ø> (-0.01%) ⬇️
vmproxy 68.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@@ -5,6 +5,21 @@ set -o xtrace

. $(dirname $0)/vars

# Determine the architecture and set TARGETS for Nomad accordingly
ARCH=$(uname -m)
Copy link
Member

Choose a reason for hiding this comment

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

This declaration makes ARCH a global variable. Can we move the whole block to extract_source_tarball and declare ARCH as a local variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted to keep ARCH as a global variable since we're currently building the client for multi-architecture, and having it set globally may streamline future adjustments. However, I'm open to making it local to another function if necessary.

Could you clarify why you suggest moving ARCH specifically to the extract_source_tarball function? At present, ARCH is only used in the gobuild_component function.

Copy link
Member

Choose a reason for hiding this comment

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

No, it's used elsewhere, and it's also global there. I suggested this since global variables are normally considered evil - you won't know in case one overrides the other. Moreover, such collisions are difficult to troubleshoot.

As a general rule, defaulting to use local variables is a good programming practice no matter what the language is, including bash scripting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand that global variables can lead to conflicts and troubleshooting issues due to potential overrides, which is why they’re generally avoided in programming. However, there are cases in scripting, especially in bash where global variables simplify tasks by making key parameters available across functions. In this case, setting ARCH globally could streamline changes if we expand to multi-architecture builds in the future. So while local variables are often preferable, some situations benefit from a well-managed global variable. That said, I’m okay with moving it into the function, would you like me to place it in the gobuild_component function?

Copy link
Member

@ademidoff ademidoff Nov 12, 2024

Choose a reason for hiding this comment

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

Using global vars across multiple scripts requires a good structure. Usually, globals are not declared everywhere, otherwise they become difficult to understand and maintain.

Making ARCH a global variable would necessitate declaring it in vars script, which is the proper place for globals, and which should be the only place for globals. Also, it would be necessary to refactor the use of this variable across other scripts.

Apart from that, we are undertaking a heavy refactoring of the build scripts, which will hopefully make it possible to build an arm/aarch flavor of PMM as well. I suggest we address it there.

That said, I suggest we make it local for now.

@talhabinrizwan talhabinrizwan merged commit 9369be0 into v3 Nov 12, 2024
32 checks passed
@talhabinrizwan talhabinrizwan deleted the PMM-13540-Fix-pmm-client-build branch November 12, 2024 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants