Skip to content

Commit

Permalink
Patch 1.10.x (#3104)
Browse files Browse the repository at this point in the history
* fix(google): Survive missing, irrelevant target proxies during http lp deletion. (#3099)

* fix(google): Make other lb deletions also tolerant of missing, irrelevant resources. (#3100)
  • Loading branch information
Eric Wiseblatt authored and Matt Duftler committed Oct 30, 2018
1 parent 08c6178 commit 056d269
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.clouddriver.google.deploy.ops.loadbalancer

import com.google.api.client.googleapis.json.GoogleJsonResponseException
import com.google.api.services.compute.model.*
import com.netflix.spinnaker.clouddriver.data.task.Task
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository
Expand Down Expand Up @@ -82,7 +83,7 @@ class DeleteGoogleHttpLoadBalancerAtomicOperation extends DeleteGoogleLoadBalanc
def forwardingRuleName = description.loadBalancerName

// First we look everything up. Then, we call delete on all of it. Finally, we wait (with timeout) for all to complete.
// Start with the forwaring rule.
// Start with the forwarding rule.
task.updateStatus BASE_PHASE, "Retrieving global forwarding rule $forwardingRuleName..."

List<ForwardingRule> projectForwardingRules = timeExecute(
Expand Down Expand Up @@ -110,9 +111,19 @@ class DeleteGoogleHttpLoadBalancerAtomicOperation extends DeleteGoogleLoadBalanc

List<String> listenersToDelete = []
projectForwardingRules.each { ForwardingRule rule ->
def proxy = GCEUtil.getTargetProxyFromRule(compute, project, rule, BASE_PHASE, safeRetry, this)
if (GCEUtil.getLocalName(proxy?.urlMap) == urlMapName) {
listenersToDelete << rule.getName()
try {
def proxy = GCEUtil.getTargetProxyFromRule(compute, project, rule, BASE_PHASE, safeRetry, this)
if (GCEUtil.getLocalName(proxy?.urlMap) == urlMapName) {
listenersToDelete << rule.getName()
}
} catch (GoogleJsonResponseException e) {
// 404 is thrown if the target proxy does not exist.
// We can ignore 404's here because we are iterating over all forwarding rules and some other process may have
// deleted the target proxy between the time we queried for the list of forwarding rules and now.
// Any other exception needs to be propagated.
if (e.getStatusCode() != 404) {
throw e
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.clouddriver.google.deploy.ops.loadbalancer

import com.google.api.client.googleapis.json.GoogleJsonResponseException
import com.google.api.services.compute.model.BackendService
import com.google.api.services.compute.model.ForwardingRule
import com.google.api.services.compute.model.Operation
Expand Down Expand Up @@ -92,8 +93,18 @@ class DeleteGoogleInternalLoadBalancerAtomicOperation extends GoogleAtomicOperat
// Determine which listeners to delete.
List<String> listenersToDelete = []
projectForwardingRules.each { ForwardingRule rule ->
if (GCEUtil.getLocalName(rule.getBackendService()) == backendServiceName) {
listenersToDelete << rule.getName()
try {
if (GCEUtil.getLocalName(rule.getBackendService()) == backendServiceName) {
listenersToDelete << rule.getName()
}
} catch (GoogleJsonResponseException e) {
// 404 is thrown if the target proxy does not exist.
// We can ignore 404's here because we are iterating over all forwarding rules and some other process may have
// deleted the target proxy between the time we queried for the list of forwarding rules and now.
// Any other exception needs to be propagated.
if (e.getStatusCode() != 404) {
throw e
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.clouddriver.google.deploy.ops.loadbalancer

import com.google.api.client.googleapis.json.GoogleJsonResponseException
import com.google.api.services.compute.model.*
import com.netflix.spinnaker.clouddriver.data.task.Task
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository
Expand Down Expand Up @@ -63,7 +64,7 @@ class DeleteGoogleSslLoadBalancerAtomicOperation extends DeleteGoogleLoadBalance
def forwardingRuleName = description.loadBalancerName

// First we look everything up. Then, we call delete on all of it. Finally, we wait (with timeout) for all to complete.
// Start with the forwaring rule.
// Start with the forwarding rule.
task.updateStatus BASE_PHASE, "Retrieving global forwarding rule $forwardingRuleName..."

List<ForwardingRule> projectForwardingRules = timeExecute(
Expand Down Expand Up @@ -91,9 +92,19 @@ class DeleteGoogleSslLoadBalancerAtomicOperation extends DeleteGoogleLoadBalance

List<String> listenersToDelete = []
projectForwardingRules.each { ForwardingRule rule ->
def proxy = GCEUtil.getTargetProxyFromRule(compute, project, rule, BASE_PHASE, safeRetry, this)
if (GCEUtil.getLocalName(proxy?.service) == backendServiceName) {
listenersToDelete << rule.getName()
try {
def proxy = GCEUtil.getTargetProxyFromRule(compute, project, rule, BASE_PHASE, safeRetry, this)
if (GCEUtil.getLocalName(proxy?.service) == backendServiceName) {
listenersToDelete << rule.getName()
}
} catch (GoogleJsonResponseException e) {
// 404 is thrown if the target proxy does not exist.
// We can ignore 404's here because we are iterating over all forwarding rules and some other process may have
// deleted the target proxy between the time we queried for the list of forwarding rules and now.
// Any other exception needs to be propagated.
if (e.getStatusCode() != 404) {
throw e
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.clouddriver.google.deploy.ops.loadbalancer

import com.google.api.client.googleapis.json.GoogleJsonResponseException
import com.google.api.services.compute.model.*
import com.netflix.spinnaker.clouddriver.data.task.Task
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository
Expand Down Expand Up @@ -63,7 +64,7 @@ class DeleteGoogleTcpLoadBalancerAtomicOperation extends DeleteGoogleLoadBalance
def forwardingRuleName = description.loadBalancerName

// First we look everything up. Then, we call delete on all of it. Finally, we wait (with timeout) for all to complete.
// Start with the forwaring rule.
// Start with the forwarding rule.
task.updateStatus BASE_PHASE, "Retrieving global forwarding rule $forwardingRuleName..."

List<ForwardingRule> projectForwardingRules = timeExecute(
Expand Down Expand Up @@ -91,9 +92,19 @@ class DeleteGoogleTcpLoadBalancerAtomicOperation extends DeleteGoogleLoadBalance

List<String> listenersToDelete = []
projectForwardingRules.each { ForwardingRule rule ->
def proxy = GCEUtil.getTargetProxyFromRule(compute, project, rule, BASE_PHASE, safeRetry, this)
if (GCEUtil.getLocalName(proxy?.service) == backendServiceName) {
listenersToDelete << rule.getName()
try {
def proxy = GCEUtil.getTargetProxyFromRule(compute, project, rule, BASE_PHASE, safeRetry, this)
if (GCEUtil.getLocalName(proxy?.service) == backendServiceName) {
listenersToDelete << rule.getName()
}
} catch (GoogleJsonResponseException e) {
// 404 is thrown if the target proxy does not exist.
// We can ignore 404's here because we are iterating over all forwarding rules and some other process may have
// deleted the target proxy between the time we queried for the list of forwarding rules and now.
// Any other exception needs to be propagated.
if (e.getStatusCode() != 404) {
throw e
}
}
}

Expand Down

0 comments on commit 056d269

Please sign in to comment.