Skip to content

Commit

Permalink
Log error when update is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Nov 25, 2024
1 parent fa8b789 commit 94e06ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,15 @@ func (a *targetTCPProxyAdapter) Update(ctx context.Context, updateOp *directbase
}
region := parent.Region

// Regional API does not support Update
if region != "global" {
return updateOp.SkipUpdate(a.id.External)
}

tokens := strings.Split(a.id.External, "/")
targetTCPProxy.Name = direct.LazyPtr(tokens[len(tokens)-1])

// Regional API does not support Update
if !reflect.DeepEqual(targetTCPProxy.ProxyHeader, a.actual.ProxyHeader) && region == "global" {
if !reflect.DeepEqual(targetTCPProxy.ProxyHeader, a.actual.ProxyHeader) {
setProxyHeaderReq := &computepb.SetProxyHeaderTargetTcpProxyRequest{
Project: parent.ProjectID,
TargetTcpProxiesSetProxyHeaderRequestResource: &computepb.TargetTcpProxiesSetProxyHeaderRequest{ProxyHeader: targetTCPProxy.ProxyHeader},
Expand All @@ -283,7 +287,7 @@ func (a *targetTCPProxyAdapter) Update(ctx context.Context, updateOp *directbase
log.V(2).Info("successfully updated ComputeTargetTCPProxy proxy header", "name", a.id.External)
}

if !reflect.DeepEqual(targetTCPProxy.Service, a.actual.Service) && region == "global" {
if !reflect.DeepEqual(targetTCPProxy.Service, a.actual.Service) {
setBackendServiceReq := &computepb.SetBackendServiceTargetTcpProxyRequest{
Project: parent.ProjectID,
TargetTcpProxiesSetBackendServiceRequestResource: &computepb.TargetTcpProxiesSetBackendServiceRequest{Service: targetTCPProxy.Service},
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/direct/directbase/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (o *UpdateOperation) RecordUpdatingEvent() {
r.Event(o.object, corev1.EventTypeNormal, k8s.Updating, k8s.UpdatingMessage)
}

func (o *UpdateOperation) SkipUpdate(resource string) error {
return fmt.Errorf("update operation does not support for resource %s", resource)
}

var _ Operation = &CreateOperation{}

type CreateOperation struct {
Expand Down

0 comments on commit 94e06ba

Please sign in to comment.