-
Notifications
You must be signed in to change notification settings - Fork 48
Feat: Added functionalities to remove duplicate parameters and overwrite existing ones. #527
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
base: develop
Are you sure you want to change the base?
Conversation
…gement, and added functionalities to remove duplicate parameters and overwrite existing ones.
…Also, made minor code fixes.
…ub.com/AI-Hypercomputer/xpk into lidanny/feature/extended_subnet_ranges
@sharabiani ptal |
This PR is from #506 . @SujeethJinesh These errors likely aren't related to my modifications. They seem to be primarily about IP conflicts and the inability to get-credentials for the cluster. |
The tests are failing and I don't think fault is on the tests side this time @DannyLiCom |
@SujeethJinesh This issue likely stems from conflicts caused by the default network and IP. To pass the checks, we might need to include the creation of networks, subnetworks, firewalls, and so on, and then change the defaults to the new network.(Refer to here) This would involve a lot of related changes and modifications. |
@wstcliyu Might need to help Sujeeth discuss this with Piotr. Thanks! |
# After shlex.split: Print the tokens list | ||
xpk_print(f'Shlex-split tokens: {tokens}') | ||
i = 0 | ||
while i < len(tokens): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking again at this, this is custom loop, handling string with arguments. I find it hard to mantain and debug. It should be replaced with usage of some library is possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to modify argparse before, but I don't think it's flexible enough. You have to pre-define all the parameters it needs to parse.
https://screenshot.googleplex.com/8fpLsUdZMrouXXt
del final_gcloud_args[opposite_key] | ||
final_gcloud_args[key] = True | ||
elif key.startswith('--enable-'): | ||
opposite_key = f'--no-{key[2:]}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are we guaranteed that the only keys which will have opposite effect are formed with disable or no prefixes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our current processing logic is indeed based on the observed gcloud and our custom argument conventions, meaning keys with opposite effects use prefixes like --no-, --enable-, or --disable-. However, it is indeed a potential risk point.
https://screenshot.googleplex.com/dhSjkYf9LWhGupu
Currently, I'm only referring to this source.
https://cloud.google.com/sdk/gcloud/reference/container/clusters/create
src/xpk/commands/cluster.py
Outdated
command += f' --addons={addons_str}' | ||
conditional_params['--addons'] = ','.join(addons) | ||
|
||
for key, value in conditional_params.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this loop could be separate function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added merge_conditional_params
function.
src/xpk/commands/cluster.py
Outdated
process_gcloud_args(user_parsed_args, final_gcloud_args) | ||
|
||
command_parts = ['gcloud beta container clusters create', args.cluster] | ||
for key, value in final_gcloud_args.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this loop could be separate function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added construct_gcloud_command_string
function.
final_gcloud_args['--master-ipv4-cidr'] = '172.16.0.32/28' | ||
# This value is from here https://cloud.google.com/vpc/docs/subnets | ||
final_gcloud_args['--cluster-ipv4-cidr'] = '10.224.0.0/12' | ||
final_gcloud_args['--enable-private-nodes'] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use --master-ipv4-cidr, you must also include --enable-private-nodes, otherwise an error will occur.
error: ERROR: (gcloud.beta.container.clusters.create) Cannot specify --master-ipv4-cidr without --enable-private-nodes. It seems I might need to add --enable-private-nodes to execute python3 xpk/xpk.py cluster create-pathways.
What is the exact reason for this PR? |
…ub.com/AI-Hypercomputer/xpk into lidanny/feature/extended_subnet_ranges
This is a task @SujeethJinesh assigned to me. Here are Sujeeth's objectives. |
@SujeethJinesh This issue still exists. |
else: | ||
parsed_args[token] = True | ||
elif token.startswith('-'): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if branch could be removed.
final_gcloud_args[key] = value | ||
|
||
|
||
def merge_conditional_params(conditional_params, final_gcloud_args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor this to not modify the final_gcloud_args
input parameter, but copy it and return a copy.
return parsed_args | ||
|
||
|
||
def process_gcloud_args(user_parsed_args, final_gcloud_args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor this to not modify the final_gcloud_args
input parameter, but copy it and return a copy.
@SujeethJinesh @pawloch00 The reason my manual tests had no issues is that I would first create the network, subnetwork, firewall and so on as a prerequisite before running the test. But if I were to put the creation of networks, etc., inside the xpk code, it feels a bit illogical, and it would likely require a lot of modifications. The solutions I can think of are to either change the original default network or, as we just discussed, to add a method for creating networks inside the code. I might need some advice. |
Fixes / Features
Testing / Documentation
Can be tested when creating a cluster using XPK.