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

HPCC-28968 Expose internal HPCC settings as environment variables #17012

Conversation

jakesmith
Copy link
Member

@jakesmith jakesmith commented Feb 27, 2023

In particular the deployment name, such that ECL can use it with getEnv("HPCC_DEPLOYMENT")

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

@jakesmith
Copy link
Member Author

@ghalliday - this is new PR for closed #17010 (couldn't reopn).

Only difference is fixed comment typo' as per your comment in that PR.

@github-actions
Copy link

https://track.hpccsystems.com/browse/HPCC-28968
Jira not updated (pull request already registered)

@jakesmith
Copy link
Member Author

@ghalliday - added extra commit to fix win32 compile issue.

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

@jakesmith unfortunately not thread safe.

queryEnvironmentConf().getProp("deploymentName", deploymentName);
if (0 == deploymentName.length())
deploymentName.set("UNKNOWN");
setenv("HPCC_DEPLOYMENT", deploymentName, 1);
Copy link
Member

Choose a reason for hiding this comment

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

unfortunately setenv isn't thread-safe. That means that changes coming in here could cause the program to crash.... Needs some more thought. Probably our own structure (the config/global environment?) with thread protection.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, the original idea was to hook getEnv, so that it special cased based on some convention, and got the value from our own internal env. section.
Pity, but I'll change to follow that route vs using standard process env. variables.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ghalliday - please see revised scheme.

unsigned notifyFuncId = pendingInitializeFuncIds.back();
pendingInitializeFuncIds.pop_back();
ConfigUpdateFunc notifyFunc = notifyConfigUpdates[notifyFuncId];
notifyFunc(getComponentConfigSP(), getGlobalConfigSP());
Copy link
Member

Choose a reason for hiding this comment

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

trivial: more efficient to evaluate these once outside the loop? Fine as it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll change it.

@jakesmith jakesmith force-pushed the HPCC-28968-std-job-deployment branch from da5bd1a to 88db8c4 Compare March 7, 2023 12:45
@jakesmith jakesmith requested a review from ghalliday March 7, 2023 12:46
@ghalliday ghalliday changed the base branch from master to candidate-9.0.x March 13, 2023 10:58
Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

A couple of minor comments. Please squash (and fix the spurious newline)

@@ -1,3 +1,4 @@

Copy link
Member

Choose a reason for hiding this comment

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

spurious newline

Copy link
Member Author

Choose a reason for hiding this comment

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

will remove.

char *hpccEnvVal = getHPCCEnvVal(name, defaultValue);
if (hpccEnvVal)
return hpccEnvVal;
else
Copy link
Member

Choose a reason for hiding this comment

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

picky: I think this else is confusing - when I first read it I assumed the true branch would fall through to the code below, and then leak because of the extra strdup()

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, I wouldn't normally write like that, not sure why I did, will change.

@jakesmith jakesmith force-pushed the HPCC-28968-std-job-deployment branch from 88db8c4 to 9decf7b Compare March 13, 2023 16:25
In particular the deployment name, such that ECL can use it with
getEnv("HPCC_DEPLOYMENT")

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
@jakesmith jakesmith force-pushed the HPCC-28968-std-job-deployment branch from 9decf7b to 6621919 Compare March 13, 2023 16:25
@jakesmith
Copy link
Member Author

@ghalliday - minor changes made, and squashed

@ghalliday ghalliday merged commit cfbc5c7 into hpcc-systems:candidate-9.0.x Mar 14, 2023
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants