-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(gce): Add GCP internal http(s) load balancer. #4725
Conversation
We prefer that non-test backend code be written in Java or Kotlin, rather than Groovy. The following files have been added and written in Groovy:
See our server-side commit conventions here. |
...er-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/model/GoogleSubnet.groovy
Show resolved
Hide resolved
@takaaki7 Let's hold off on merging the corresponding Deck PR until this PR is merged. Per @spinnakerbot's comment, could you please ensure that any new files are added in Java rather than Groovy before we review this? Would be great if @plumpy could take a look as well since he is most familiar with the Clouddriver GCE implementation. 🙏 🍡 |
Thanks for comment! I'll fix it. |
I converted groovy to Java. @plumpy Could you review this? Actually I just want deployment feature of internal http lb for my project. No need Upsert,Delete feature because I can manage loadbalancers by terraform. And I noticed, this PR might be split into two part. ( If PR for only deployment feature is acceptable (and if merging this large PR is hard), I'll try to split. |
@@ -220,7 +221,7 @@ class GoogleClusterProvider implements ClusterProvider<GoogleCluster.View> { | |||
serverGroupData.each { CacheData serverGroupCacheData -> | |||
GoogleServerGroup serverGroup = serverGroupFromCacheData(serverGroupCacheData, clusterView.accountName, instances, securityGroups, loadBalancers) | |||
clusterView.serverGroups << serverGroup.view | |||
clusterView.loadBalancers.addAll(serverGroup.loadBalancers*.view) | |||
clusterView.loadBalancers.addAll(serverGroup.loadBalancers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referencing nonexistent property GoogleLoadBalancerView.view
.
Using java, this line causes exception.
How is the progress? |
Sorry for the delay, but the PR build is failing because of a Groovy compilation error, so I was waiting for that to be resolved before I looked at it... if you don't know how to fix it, I can try to figure it out, I guess... It's going to take me a little bit to review this since it's quite a lot of code and I don't know much about the internal HTTP load balancers, so I'll need to research and play around with those, but I'm hoping to get to it this week. |
Oh, sorry for that. I looked at it but I couldn't figure it out... And the line causing the error seems no problem for me.. I’d like to ask you for your help. |
@takaaki7 |
...iver/google/deploy/ops/loadbalancer/UpsertGoogleInternalHttpLoadBalancerAtomicOperation.java
Outdated
Show resolved
Hide resolved
da0ecf1
to
d7a6778
Compare
Is it going to take a little longer? I know this PR is large, so I can consider different approach if prefered. But I want to hear your opinion at first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry this is taking so long. This code is just so messy that it's hard to understand what's going on. (The existing GCE code, not your changes.) I'm trying to focus mostly on the parts that will affect users who aren't using internal HTTP load balancers, to make sure this doesn't cause any new bugs for them.
I really appreciate you sending this PR and I'm sorry I'm taking so long to get it reviewed. I'll make sure we get it wrapped up and submitted next week.
...google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/model/callbacks/Utils.groovy
Outdated
Show resolved
Hide resolved
@@ -488,7 +492,7 @@ class BasicGoogleDeployHandler implements DeployHandler<BasicGoogleDeployDescrip | |||
.setTargetPools(targetPools) | |||
.setAutoHealingPolicies(autoHealingPolicy) | |||
|
|||
if (hasBackendServices && (description?.loadBalancingPolicy || description?.source?.serverGroupName)) { | |||
if (!internalLoadBalancers && (description?.loadBalancingPolicy || description?.source?.serverGroupName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about this change... it feels significant and risky, but it's hard to figure out what's happening in the middle of a 500-line method, with a variable defined 300 lines away 😨 Can you explain what this change does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it's written, lbs that isn't internal
(= external http/tcp/ssl , and internal HTTP) requires namedPorts handling.
Because hasBackendServices
is false when internal HTTP loadbalancers exists, now it's not appropriate here. (hasBackendServices
should be renamed to hasGlobalBackendServices
)
This condition can be written as following way to reduce the change impact, but I think it's not clean.
if ((hasBackendServices || internalHttpLoadBalancers) && (description?.loadBalancingPolicy || description?.source?.serverGroupName))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation! Isn't it possible that we have internalLoadBalancers
and tcpLoadsBalancers
(i.e. two types of load balancers for this server group)? In which case we need to configure the named ports, but as it's written here we won't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow that's right.
- fix
...er-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/model/GoogleSubnet.groovy
Show resolved
Hide resolved
0ac9e15
to
08c0be4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think this is all I have, nothing very major.
Thanks again for doing all this work, just clean up these smallish things and then I'll happily merge it. I really appreciate you doing this work (especially since you didn't even need all of it). 🍡
@ToString(includeSuper = true) | ||
@groovy.transform.EqualsAndHashCode(callSuper = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace these with lombok:
@ToString(includeSuper = true) | |
@groovy.transform.EqualsAndHashCode(callSuper = true) | |
@Data | |
@EqualsAndHashCode(callSuper = true) | |
@ToString(callSuper = true) |
Then:
- mark
type
andloadBalancingScheme
as final - delete all the getters and setters (except
getView
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for detailed instruction! It's very helpful.
return new InternalHttpLbView(); | ||
} | ||
|
||
@EqualsAndHashCode(callSuper = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EqualsAndHashCode(callSuper = false) | |
@Value | |
@EqualsAndHashCode(callSuper = true) | |
@ToString(callSuper = true) |
Then delete the serverGroups
field and all the methods.
import static com.netflix.spinnaker.clouddriver.google.deploy.GCEUtil.GLOBAL_LOAD_BALANCER_NAMES; | ||
import static com.netflix.spinnaker.clouddriver.google.deploy.GCEUtil.LOAD_BALANCING_POLICY; | ||
import static com.netflix.spinnaker.clouddriver.google.deploy.GCEUtil.REGIONAL_LOAD_BALANCER_NAMES; | ||
import static com.netflix.spinnaker.clouddriver.google.deploy.GCEUtil.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use wildcard imports
healthCheckUrls.addAll(backendService.getHealthChecks()); | ||
} | ||
|
||
DefaultGroovyMethods.unique(healthCheckUrls); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you can just make healthCheckUrls
into a Set
?
if (healthCheck.getTcpHealthCheck() != null) { | ||
port = healthCheck.getTcpHealthCheck().getPort(); | ||
hcType = GoogleHealthCheck.HealthCheckType.TCP; | ||
} else if (DefaultGroovyMethods.asBoolean(healthCheck.getSslHealthCheck())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these DefaultGroovyMethods.asBoolean
can just be != null
, right?
I've addressed your comments. |
Thanks again, I appreciate your contribution! And sorry again for the long delay... |
Thank you for merging! When will this feature be released? |
The next release is Spinnaker 1.22, for which the branches will be cut next week. You can subscribe to the Spinnaker release calendar or #spinnaker-releases Slack channel to see upcoming releases, and can also check the |
I see, thank you! |
Added GCP Internal HTTP(S) load balancer support. spinnaker/spinnaker#5042
PR for deck: spinnaker/deck#8397
Many parts are copy and pasted from HTTP Load Balancer implementation.
Differences are: