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

DUPLO-25704: Wait on bulk update image #110

Merged
merged 8 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- fixed the duplicating user section in the update kubeconfig command.
- fixed the wait on bulk update image.

## [0.2.37] - 2024-10-18

Expand Down
44 changes: 28 additions & 16 deletions src/duplo_resource/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,31 +364,43 @@ def update_pod_label(self,

@Command()
def bulk_update_image(self,
serviceimage: args.SERVICEIMAGE) -> dict:
"""Update multiple services.

Bulk update the image of a services.
serviceimage: args.SERVICEIMAGE,
wait: args.WAIT = False) -> dict:
"""
Bulk update the image of multiple services.

Usage: Basic CLI Use
shantanuduplo marked this conversation as resolved.
Show resolved Hide resolved
```sh
duploctl service bulk_update_image -S <service-name-1> <image-name-1> -S <service-name-2> <image-name-2>
```

Args:
serviceimage: takes n sets of two arguments, service name and image name. e.g -S service1 image1:tag -S service2 image2:tag
serviceimage: Takes n sets of two arguments, service name and image name.
e.g., -S service1 image1:tag -S service2 image2:tag
wait: Boolean flag to wait for service updates.
"""
payload = []
for i in serviceimage:
servicepair = dict([i])
for name, image in servicepair.items():
payloaditem = {}
service = self.find(name)
allocation_tags = service["Template"]["AllocationTags"]
payloaditem["Name"] = name
payloaditem["Image"] = image
payloaditem["AllocationTags"] = allocation_tags
payload.append(payloaditem)
wait_list = []
for name, image in serviceimage.items():
service = self.find(name)
payload_item = {
"Name": name,
"Image": image,
"AllocationTags": service["Template"]["AllocationTags"]
}
payload.append(payload_item)
if wait:
wait_list.append({
"old": service,
"updated": payload_item
})

self.duplo.post(self.endpoint("ReplicationControllerBulkChangeAll"), payload)

if wait:
for update_info in wait_list:
self.wait(**update_info)

return {"message": "Successfully updated images for services"}

@Command()
Expand Down