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

When updating a protection job, it just says "'{"errorCode":"KInternalError","message":"Request failed with error code: KInvalidRequest"}" . No other explanation #81

Closed
anusajith opened this issue Nov 23, 2023 · 17 comments
Assignees

Comments

@anusajith
Copy link

anusajith commented Nov 23, 2023

🐛 Bug Report

Hey Team,
I am trying to update a protection job (Cohesity view type) by adding one newly created view to it.

To Reproduce

These are the snippets I am using:

  1. Getting the protection job by name :

def get_protection_job_by_name(self, group_name: str):
protection_job_list = self._client.protection_jobs.get_protection_jobs()
for job in protection_job_list:
if job.name == group_name:
return job
return None
existing_job =get_protection_job_by_name("cohesity views")

  1. getting view id of the new view created eg: 11111111

  2. As a work around: When fetching a Protection Job , source Ids are not same as the View Ids. So When we are trying to update a protection job with 100+ views in it, we have to explicitly convert those source ids to respective View Ids and then run the update method.(view_source_ids)

  3. new_source_ids= view_source_ids.append(11111111)

job_body = ProtectionJobRequestBody(
name=job_info["job_name"],
source_ids=new_source_ids,
policy_id=existing_job.policy_id,
view_box_id=existing_job.view_box_id,
environment="kView",
timezone="Australia/Sydney",
)
job_body.id = existing_job.id
6. cohesity_client.protection_jobs.update_protection_job(job_body, existing_job.id)

Expected behavior

update protection job should be successful.

Actual Behavior

It is failing with following error:
'{"errorCode":"KInternalError","message":"Request failed with error code: KInvalidRequest"}\n'

No other explanations . It is working through UI without any issues.
How can I validate the ProtectionJobRequestBody I am sending is proper? or where am I going wrong?

Regards,
Anu

@naveena-maplelabs
Copy link
Contributor

@anusajith Will check and let you know

@naveena-maplelabs
Copy link
Contributor

@anusajith What is the cluster version and SDK version you're using?

@anusajith
Copy link
Author

sdk version - 1.10.1
cluster version - 6.8.1_u5_release-20230907_89061e30

@anusajith
Copy link
Author

anusajith commented Nov 23, 2023

here I am trying to add more than 100 views to the cohesity view type protection job. Is there a limit to that number through api?

One other thing noted was:
while we are trying to update a protection job through api, this is url it's hitting:
'https://<cohesity_endpoint>/irisservices/api/v1/public/protectionJobs/'

Through UI: https://<cohesity_endpoint>/v2/data-protect/protection-groups/

Is the client version (v1 or v2) is a reason of this error?

@naveena-maplelabs
Copy link
Contributor

@anusajith I m using a 7.0 cluster. I was able to create and update job using viewId(not source id) with SDK. The issue doesn't seem to be with SDK, can you please try with different cluster version?

@anusajith
Copy link
Author

anusajith commented Nov 26, 2023

image

@naveena-maplelabs , Did you try updating a Protection job with more than 100 + views in it as shown.?
For me, also, the update will work till the number reaches 100. After 100, it is failing with the error mentioned.
Can you please confirm on this?

@anusajith
Copy link
Author

@naveena-maplelabs , can you please provide an update, as this is stopping our automation for cohesity provision.

@naveena-maplelabs
Copy link
Contributor

@anusajith I was able to reproduce the issue when the total number of views greater than 100. Have reported to the concerned team, Can you try View_job creation using V2 APIs?

@anusajith
Copy link
Author

anusajith commented Nov 28, 2023

@naveena-maplelabs Thank you for that.
Will you be able to confirm the ETA on this fix?
Do you have python client for V2? we could see a branch named "v2_sdk", is that the one?
And can you please share some examples for creating view , protection job and updating these using V2 client.

@naveena-maplelabs
Copy link
Contributor

naveena-maplelabs commented Nov 29, 2023

@anusajith

You can install the V2 SDK using following command.
pip install cohesity-sdk

Links:
https://pypi.org/project/cohesity-sdk/
https://github.com/cohesity/cohesity_sdk/

Sample Code:

from cohesity_sdk.cluster.cluster_client import ClusterClient
from cohesity_sdk.cluster.model.create_or_update_protection_group_request import (
    CreateOrUpdateProtectionGroupRequest,
)
from cohesity_sdk.cluster.model.view_protection_group_params import (
    ViewProtectionGroupParams,
)
from cohesity_sdk.cluster.model.view_protection_group_object_params import (
    ViewProtectionGroupObjectParams,
)

v2_client = ClusterClient(
    "x.x.x.x", username="admin", password="admin", domain="LOCAL"
)
objects = list()
for view in v2_client.view.get_views().views:
    objects.append(ViewProtectionGroupObjectParams(id=view.view_id))
view_params = ViewProtectionGroupParams(objects=objects)
body = CreateOrUpdateProtectionGroupRequest(
    storage_domain_id=5,
    policy_id=policy_id,
    name="Test",
    environment="kView",
    view_params=view_params,
)
print(v2_client.protection_group.create_protection_group(body))

@anusajith
Copy link
Author

anusajith commented Nov 30, 2023

@naveena-maplelabs , Having issues with V2 client too: cohesity/cohesity_sdk#1. Not sure , whether it will be answered or not.

@anusajith
Copy link
Author

Any update on this?

@naveena-maplelabs
Copy link
Contributor

@anusajith Will check and get back to you.

@naveena-maplelabs
Copy link
Contributor

Issue resolved with V2 SDk 1.2.0 version.

@anusajith
Copy link
Author

So will there be any fix going in V1 client?

@naveena-maplelabs
Copy link
Contributor

@anusajith That need a V1 API fix, our SDK has nothing to do with it. Even with API we can't create job with more than 100+ views.

@anusajith
Copy link
Author

Thank you @naveena-maplelabs for all your responses.

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

No branches or pull requests

2 participants