Closed glover-chris closed 1 year ago
Describe the bug The users/list api call returns 500 and DSL does not loop through the next offset of 500 if more than 500 users present.
Branch/Container master
To Reproduce Steps to reproduce the behavior:
Expected behavior All users should be included in the update cache command.
Findings/Troubleshooting Done Issue may be in the code here where the user api is called but there is no logic for more than 500 users.
https://github.com/nutanix/calm-dsl/blob/884be6b2cf4298f97dc8b064efbd6c02d8018086/calm/dsl/db/table_config.py#L1197
Line 1200 client = get_api_client() Obj = get_resource_api("users", client.connection) res, err = Obj.list({"length": 1000})
Screenshots If applicable, add screenshots to help explain your problem.
System Configuration:
Additional context Temporary fix in code at line 1195 of calm/dsl/db/table_config.py is working.
client = get_api_client() Obj = get_resource_api("users", client.connection) offset = 0 length = 500 while True: res, err = Obj.list({"length": length, "offset": offset}) if err: raise Exception("[{}] - {}".format(err["code"], err["error"])) res = res.json() for entity in res["entities"]: name = entity["status"]["name"] uuid = entity["metadata"]["uuid"] display_name = entity["status"]["resources"].get("display_name") or "" directory_service_user = ( entity["status"]["resources"].get("directory_service_user") or dict() ) directory_service_ref = ( directory_service_user.get("directory_service_reference") or dict() ) directory_service_name = directory_service_ref.get("name", "LOCAL") if directory_service_name: cls.create_entry( name=name, uuid=uuid, display_name=display_name, directory=directory_service_name, ) if offset + length >= res['metadata']['total_matches']: break else: offset += length
Describe the bug The users/list api call returns 500 and DSL does not loop through the next offset of 500 if more than 500 users present.
Branch/Container master
To Reproduce Steps to reproduce the behavior:
Expected behavior All users should be included in the update cache command.
Findings/Troubleshooting Done Issue may be in the code here where the user api is called but there is no logic for more than 500 users.
https://github.com/nutanix/calm-dsl/blob/884be6b2cf4298f97dc8b064efbd6c02d8018086/calm/dsl/db/table_config.py#L1197
Line 1200 client = get_api_client() Obj = get_resource_api("users", client.connection) res, err = Obj.list({"length": 1000})
Screenshots If applicable, add screenshots to help explain your problem.
System Configuration:
Additional context Temporary fix in code at line 1195 of calm/dsl/db/table_config.py is working.