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

agent-spawner: base64 encode the resalloc ticket DATA in env #145

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

praiskup
Copy link
Owner

Fixes: #144

@siteshwar
Copy link
Contributor

I have not tested these changes, but here are some general observations:

  • Where is this variable named RESALLOC_RESOURCE_DATA?
  • Where are RESOURCE_NAME, RESOURCE_POOL_ID etc. are set?
  • Why RESALLOC_RESOURCE_DATA has to be base64 encoded? Is that because terminal output may contain binary characters?

@praiskup
Copy link
Owner Author

These are set here:

def command_env(pool_id=None, res_id=None, res_name=None,
id_in_pool=None, data=None):
pfx = 'RESALLOC_'
env = os.environ.copy()
env[pfx + 'ID'] = str(res_id)
env[pfx + 'NAME'] = str(res_name)
env[pfx + 'POOL_ID'] = str(pool_id)
env[pfx + 'ID_IN_POOL'] = str(id_in_pool)
if data is not None:
env[pfx + 'RESOURCE_DATA'] = base64.b64encode(data)
return env

Is that because terminal output may contain binary characters?

Yes.

@siteshwar
Copy link
Contributor

These are set here:

Why they are not visible in the env output?

@praiskup
Copy link
Owner Author

They are actually. But resalloc != agent spawner.

@siteshwar
Copy link
Contributor

They are actually. But resalloc != agent spawner.

Is this comment valid for agent spawner? If not, it should be removed and we should mention AGENT_SPAWNER_RESOURCE_DATA instead.

@praiskup praiskup force-pushed the praiskup-agent-spawner-base64 branch from d0fa7de to 41e7132 Compare February 27, 2024 13:50
@praiskup
Copy link
Owner Author

Thank you for patiently punching me. You are right; the comment was wrong. I updated the docs, and fixed the fix.

Can you please take another look now?

@siteshwar
Copy link
Contributor

Thank you for patiently punching me. You are right; the comment was wrong. I updated the docs, and fixed the fix.

Can you please take another look now?

LGTM. Although I have not tested these changes.

# # Prepare the agent. Variable $RESALLOC_RESOURCE_DATA (base64 encoded)
# # is provided in the script environment. Other variables like
# # RESOURCE_NAME, RESOURCE_POOL_ID, etc. are provided as well.
# # Prepare the agent. Variable $AGENT_SPAWNER_RESOURCE_DATA (base64
Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing I may add is that base64 decoded data may contain new lines. It could be tricky to debug, if you are not familiar with functioning of resalloc. It kept me confused for a while.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Indeed, the current code doesn't modify the stdout at all, and thus it contains the trailing newline. We could implement some RFE for stdout post-processing if you think it is worth it.

@praiskup praiskup merged commit fddb704 into main Feb 27, 2024
2 of 3 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
Development

Successfully merging this pull request may close these issues.

Non-base64 encoded AGENT_SPAWNER_RESOURCE_DATA
2 participants