Complete the code to define the percentage of traffic routed to the new version in a canary deployment.
canary_traffic_percentage = [1]In canary deployment, a small percentage like 10% of traffic is routed to the new version initially to test it safely.
Complete the code to check if the canary deployment is healthy before increasing traffic.
if canary_health_status == [1]: increase_traffic()
Traffic should only be increased if the canary deployment is healthy.
Fix the error in the traffic routing rule to send 20% traffic to the canary version.
route_traffic(canary_version, percentage=[1])The percentage should be an integer representing 20%, not a decimal or string.
Fill both blanks to define a canary deployment function that routes traffic and monitors health.
def canary_deploy(version, traffic_percentage): route_traffic(version, percentage=[1]) status = check_health(version) if status == [2]: return "Canary is healthy" else: return "Canary failed"
The function routes the given traffic percentage to the version and checks if the health status is 'healthy'.
Fill all three blanks to implement a canary deployment loop that gradually increases traffic.
traffic = [1] while traffic <= 100: route_traffic('canary', percentage=traffic) health = check_health('canary') if health != [2]: rollback('canary') break traffic += [3]
The loop starts traffic at 10%, checks health, rolls back if unhealthy, and increases traffic by 10% each iteration.