-
Notifications
You must be signed in to change notification settings - Fork 218
Owls88611 make sure REST calls are made using the expected port and protocol #2301
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
Conversation
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.
LGTM
I could use some more explanations, here. There are a fair number of places where we need to select the REST port, including for the health check and the metrics. WlsServerConfig.getLocalAdminProtocolChannelPort as its own logic, which may not match that used in other places. I see fairly high level tests, but nothing that pertains directly to the algorithm for doing this selection. I could be missing something. |
WlsServerConfig.getLocalAdminProtocolChannelPort has exactly what we need here: it chooses a port to use in the following order:
The original logic uses the ports on the server's K8S service, which is not needed. As to the test cases, they do test if the correct port/protocol is picked/used given a server configuration. The expected URL is specified in the line like this: defineResponse(200, "", "http://dyn-managed-server2.Test:7001");. This means the test expects that the default listenport 7001 is picked. I noticed that the test names do not make this obvious. I can make some changes to make it clearer. |
operator/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainValidationTest.java
Outdated
Show resolved
Hide resolved
operator/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainValidationTest.java
Outdated
Show resolved
Hide resolved
operator/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainValidationTest.java
Outdated
Show resolved
Hide resolved
operator/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainValidationTest.java
Outdated
Show resolved
Hide resolved
operator/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainValidationTest.java
Outdated
Show resolved
Hide resolved
operator/src/main/java/oracle/kubernetes/operator/steps/ReadHealthStep.java
Outdated
Show resolved
Hide resolved
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.
LGTM
One minor comment - It looks like there are still some test methods with unused clusterName variable - |
@@ -131,4 +131,8 @@ public static String exceedMaxExternalServiceName( | |||
String domainUid, String adminServerName, String result, int limit) { | |||
return getMessage(MessageKeys.ILLEGAL_EXTERNAL_SERVICE_NAME_LENGTH, domainUid, adminServerName, result, limit); | |||
} | |||
|
|||
public static String noAvaiablePortToUse(String domainUid, String serverName) { |
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.
Spelling: "available" not "avaiable"
@@ -167,9 +167,11 @@ WLSDO-0019=DomainUID ''{0}'' and admin server name ''{1}'' combination ''{2}'' e | |||
WLSDO-0020=Online WebLogic configuration updates complete \ | |||
but there are pending non-dynamic changes that require \ | |||
pod restarts to take effect. The changes are: | |||
|
|||
WLSDO-0021=DomainUID ''{0}'' server ''{1}'' does not have a port available for the operator to send REST calls. \ | |||
The default listen port and SSL port are disabled, the admin port is not configured and there is not a channel with the admin privileges.\ |
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.
Phrasing is clumsy. You could check with Rosemary, but I would recommend, "... and there is no channel with admin privileges."
Mostly looks good; some questions/comments:
|
@doxiao, @russgold, @ankedia, @jshum2479, can someone provide the list of all code points that need this information? I can think of the monitoring exporter, the server health check through REST, and the dynamic update in the introspector (this likely will be a different code base since it's behavior from WDT). Are there other cases? These then need to give the correct answer with and without Istio. |
The problem exists in code paths where the result of WlsServerConfig#getAdminProtocolChannelName method is used to match a port among server service's ports. The result of getAdminProtocolChannelName does not reflect the server port names in the istio enabled case. As far as I can tell, only REST (ReadHealthStep) and exporter (PodHelper) do this. I have changed both places to NOT use server service ports to determine which port to use, instead just call getLocalAdminProtocolChannelPort method, which is the same no matter if istio is enabled or not. |
The problem and fix are not in WlsServerConfig layer, instead, in ReadHealthStep. Therefore the newly added test cases are at the ReadHealthStep layer.
I changed PodHelper to do the same as in ReadHealthStep. Note that the exporter related code did not have the problem that ReadHealthStep had because it had different orElse handling (when the port chosen by name does not match anything), but it had a different problem - it choose server's listen port over SSL port. I changed it to match exactly what we do now in ReadHealthStep. |
@russgold I noticed that in PodHelper#createMonitoringExporterContainer method, the logic of choosing a port for the Java options -DWLS_PORT is different from what is for choosing a port for the ContainerPort. The former looks for a channel with admin privileges before looking for server's admin port, ssl port and listen port, but the latter does not. Changes in this PR only impacts the former where WlsServerConfig#getAdminProtocolChannelName is used. I think we are fine there because the WLS_PORT is the one that the exporter is going to use to talk to WLS side. But want to double check with you. |
The changes in this PR fix an issue where, in some configurations, the operator may choose a wrong port and/or a wrong protocol (mistakenly considering a non-sure port to be secure) for making REST calls to get WLS server health states.
The issue is caused by the following bugs in operator.
The changes fix these issues by
Unit test cases are added to cover different configuration permutations.
Integrations test run on Jenkins (had no additional failures except for the known failures in main): https://build.weblogick8s.org:8443/job/weblogic-kubernetes-operator-kind-new/4623/.
Jenkins run with the latest version: https://build.weblogick8s.org:8443/job/weblogic-kubernetes-operator-kind-new/4658/.