Skip to content

Commit 60d43d5

Browse files
authored
Merge pull request #596 from oracle/develop-feature-disable-hooks
Develop feature disable hooks
2 parents e8cd36f + 4621dfb commit 60d43d5

File tree

13 files changed

+5
-709
lines changed

13 files changed

+5
-709
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Operator.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -209,30 +209,7 @@ private void callHelmInstall() throws Exception {
209209
}
210210

211211
private void reportHelmInstallFailure(String cmd, ExecResult result) throws Exception {
212-
String cause = getExecFailure(cmd, result);
213-
if (result.stderr().contains("Error: Job failed: BackoffLimitExceeded")) {
214-
// The operator helm chart pre-install hook probably failed.
215-
// This is probably because there is a problem with the values passed in,
216-
// for example a listed domain namespace does not exist.
217-
// Fetch the pre-install hook's results and return it too.
218-
String hookResults = getOperatorHelmChartHookResults("pre-install");
219-
cause = cause + "\n pre-install-hook returned\n" + hookResults;
220-
}
221-
throw new RuntimeException(cause);
222-
}
223-
224-
private String getOperatorHelmChartHookResults(String hookType) throws Exception {
225-
String cmd =
226-
"kubectl logs job/"
227-
+ operatorMap.get("releaseName")
228-
+ "-weblogic-operator-"
229-
+ hookType
230-
+ "-hook -n kube-system";
231-
ExecResult result = ExecCommand.exec(cmd);
232-
if (result.exitValue() != 0) {
233-
return getExecFailure(cmd, result);
234-
}
235-
return result.stdout();
212+
throw new RuntimeException(getExecFailure(cmd, result));
236213
}
237214

238215
private String getExecFailure(String cmd, ExecResult result) throws Exception {

kubernetes/charts/weblogic-operator/templates/_operator-verification-hook.tpl

Lines changed: 0 additions & 45 deletions
This file was deleted.

kubernetes/charts/weblogic-operator/templates/_validate-inputs.tpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
{{- $ignore := include "utils.verifyInteger" (list $scope "elasticSearchPort") -}}
3434
{{- end -}}
3535
{{- end -}}
36-
{{- $ignore := include "utils.verifyString" (list $scope "tillerNamespace") -}}
37-
{{- $ignore := include "utils.verifyString" (list $scope "tillerServiceAccount") -}}
3836
{{- $ignore := include "utils.verifyOptionalBoolean" (list $scope "mockWLS") -}}
3937
{{- $ignore:= include "utils.endValidation" $scope -}}
40-
{{- include "operator.operatorVerificationHook" (list $scope "pre-upgrade") }}
41-
{{- include "operator.operatorVerificationHook" (list $scope "pre-install") }}
4238
{{- end -}}

kubernetes/charts/weblogic-operator/values.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,3 @@ elasticSearchHost: "elasticsearch.default.svc.cluster.local"
9696

9797
# elasticSearchPort specifies the port number of where elasticsearch is running
9898
elasticSearchPort: 9200
99-
100-
# tillerNamespace is the name of the namespace that tiller is configured to use.
101-
tillerNamespace: "kube-system"
102-
103-
# tillerServiceAccount is the name of the service account that tiller is configured to use.
104-
tillerServiceAccount: "default"

kubernetes/src/test/java/oracle/kubernetes/operator/create/CreateOperatorGeneratedFilesOptionalFeaturesEnabledTestBase.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import io.kubernetes.client.models.ExtensionsV1beta1Deployment;
1515
import io.kubernetes.client.models.V1Container;
16-
import io.kubernetes.client.models.V1Job;
1716
import io.kubernetes.client.models.V1Service;
1817
import oracle.kubernetes.operator.utils.OperatorYamlFactory;
1918

@@ -51,18 +50,6 @@ protected V1Service getExpectedExternalWeblogicOperatorService() {
5150
return getExpectedExternalWeblogicOperatorService(true, true);
5251
}
5352

54-
@Override
55-
protected V1Job getExpectedWeblogicOperatorHookJob(String hookType) {
56-
V1Job expected = super.getExpectedWeblogicOperatorHookJob(hookType);
57-
expected
58-
.getSpec()
59-
.getTemplate()
60-
.getSpec()
61-
.addImagePullSecretsItem(
62-
newLocalObjectReference().name(getInputs().getWeblogicOperatorImagePullSecretName()));
63-
return expected;
64-
}
65-
6653
@Override
6754
public ExtensionsV1beta1Deployment getExpectedWeblogicOperatorDeployment() {
6855
ExtensionsV1beta1Deployment expected = super.getExpectedWeblogicOperatorDeployment();

kubernetes/src/test/java/oracle/kubernetes/operator/create/CreateOperatorGeneratedFilesTestBase.java

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newEnvVar;
2222
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newEnvVarSource;
2323
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newExecAction;
24-
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newJob;
25-
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newJobSpec;
2624
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newNamespace;
2725
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newObjectFieldSelector;
2826
import static oracle.kubernetes.operator.utils.KubernetesArtifactUtils.newObjectMeta;
@@ -50,8 +48,6 @@
5048
import io.kubernetes.client.models.V1ClusterRole;
5149
import io.kubernetes.client.models.V1ClusterRoleBinding;
5250
import io.kubernetes.client.models.V1ConfigMap;
53-
import io.kubernetes.client.models.V1Container;
54-
import io.kubernetes.client.models.V1Job;
5551
import io.kubernetes.client.models.V1Namespace;
5652
import io.kubernetes.client.models.V1Role;
5753
import io.kubernetes.client.models.V1RoleBinding;
@@ -92,79 +88,6 @@ protected static void setup(OperatorYamlFactory factory, OperatorValues val) thr
9288
generatedFiles = factory.generate(val);
9389
}
9490

95-
@Test
96-
public void generatesCorrect_operatorPreInstallHookJob() {
97-
assertThat(
98-
getActualWeblogicOperatorPreInstallHookJob(),
99-
yamlEqualTo(getExpectedWeblogicOperatorPreInstallHookJob()));
100-
}
101-
102-
private V1Job getActualWeblogicOperatorPreInstallHookJob() {
103-
return getGeneratedFiles().getOperatorPreInstallHookJob();
104-
}
105-
106-
protected V1Job getExpectedWeblogicOperatorPreInstallHookJob() {
107-
return getExpectedWeblogicOperatorHookJob("pre-install");
108-
}
109-
110-
@Test
111-
public void generatesCorrect_operatorPreUpgradeHookJob() {
112-
assertThat(
113-
getActualWeblogicOperatorPreUpgradeHookJob(),
114-
yamlEqualTo(getExpectedWeblogicOperatorPreUpgradeHookJob()));
115-
}
116-
117-
private V1Job getActualWeblogicOperatorPreUpgradeHookJob() {
118-
return getGeneratedFiles().getOperatorPreUpgradeHookJob();
119-
}
120-
121-
protected V1Job getExpectedWeblogicOperatorPreUpgradeHookJob() {
122-
return getExpectedWeblogicOperatorHookJob("pre-upgrade");
123-
}
124-
125-
protected V1Job getExpectedWeblogicOperatorHookJob(String hookType) {
126-
V1Job job =
127-
newJob()
128-
.metadata(
129-
newObjectMeta()
130-
.name(OPERATOR_RELEASE + "-weblogic-operator-" + hookType + "-hook")
131-
.namespace(getInputs().getTillerNamespace())
132-
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V2)
133-
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace())
134-
.putAnnotationsItem("helm.sh/hook", hookType)
135-
.putAnnotationsItem(
136-
"helm.sh/hook-delete-policy", "before-hook-creation,hook-succeeded"))
137-
.spec(
138-
newJobSpec()
139-
.backoffLimit(0)
140-
.template(
141-
newPodTemplateSpec()
142-
.metadata(
143-
newObjectMeta()
144-
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V2)
145-
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
146-
.spec(
147-
newPodSpec()
148-
.restartPolicy("Never")
149-
.serviceAccount(getInputs().getTillerServiceAccount())
150-
.addContainersItem(
151-
newContainer()
152-
.name("weblogic-operator")
153-
.image(getInputs().getWeblogicOperatorImage())
154-
.imagePullPolicy(
155-
getInputs().getWeblogicOperatorImagePullPolicy())
156-
.addCommandItem(
157-
"/operator/operator-helm-verification-hook.sh")
158-
.addCommandItem(hookType)
159-
.addCommandItem(getInputs().getNamespace())
160-
.addCommandItem(getInputs().getServiceAccount())))));
161-
V1Container container = job.getSpec().getTemplate().getSpec().getContainers().get(0);
162-
for (String targetNamespace : getInputs().getTargetNamespaces().split(",")) {
163-
container.addCommandItem(targetNamespace);
164-
}
165-
return job;
166-
}
167-
16891
@Test
16992
public void generatesCorrect_operatorConfigMap() {
17093
assertThat(

kubernetes/src/test/java/oracle/kubernetes/operator/helm/CreateOperatorInputsValidationIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public class CreateOperatorInputsValidationIT extends OperatorChartITBase {
2525
"externalRestEnabled", "remoteDebugNodePortEnabled", "elkIntegrationEnabled"
2626
};
2727

28-
private static final String[] OPERATOR_LEVEL_STRING_PROPERTIES = {
29-
"serviceAccount", "image", "tillerNamespace", "tillerServiceAccount"
30-
};
28+
private static final String[] OPERATOR_LEVEL_STRING_PROPERTIES = {"serviceAccount", "image"};
3129

3230
private static final String[] OPERATOR_LEVEL_ENUM_PROPERTIES = {
3331
"imagePullPolicy", "javaLoggingLevel"

kubernetes/src/test/java/oracle/kubernetes/operator/helm/HelmOperatorValues.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class HelmOperatorValues extends OperatorValues {
3333
loadFromMap(map, this::setExternalOperatorKey, "externalOperatorKey");
3434
loadFromMap(map, this::setLogStashImage, "logStashImage");
3535
loadFromMap(map, this::setElasticSearchHost, "elasticSearchHost");
36-
loadFromMap(map, this::setTillerNamespace, "tillerNamespace");
37-
loadFromMap(map, this::setTillerServiceAccount, "tillerServiceAccount");
3836

3937
loadBooleanFromMap(map, this::setExternalRestEnabled, "externalRestEnabled");
4038
loadBooleanFromMap(map, this::setRemoteDebugNodePortEnabled, "remoteDebugNodePortEnabled");
@@ -102,8 +100,6 @@ Map<String, Object> createMap() {
102100
addStringMapEntry(map, this::getExternalOperatorKey, "externalOperatorKey");
103101
addStringMapEntry(map, this::getLogStashImage, "logStashImage");
104102
addStringMapEntry(map, this::getElasticSearchHost, "elasticSearchHost");
105-
addStringMapEntry(map, this::getTillerNamespace, "tillerNamespace");
106-
addStringMapEntry(map, this::getTillerServiceAccount, "tillerServiceAccount");
107103

108104
addMapEntry(map, this::isExternalRestEnabled, "externalRestEnabled");
109105
addMapEntry(map, this::isRemoteDebugNotPortEnabled, "remoteDebugNodePortEnabled");

kubernetes/src/test/java/oracle/kubernetes/operator/helm/HelmOperatorValuesTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,7 @@ private String getExpectedOperatorHelmChartDefaultValues() {
482482
.append("javaLoggingLevel: INFO\n")
483483
.append("logStashImage: logstash:5\n")
484484
.append("remoteDebugNodePortEnabled: false\n")
485-
.append("serviceAccount: default\n")
486-
.append("tillerNamespace: kube-system\n")
487-
.append("tillerServiceAccount: default\n");
485+
.append("serviceAccount: default\n");
488486
return sb.toString();
489487
}
490488

kubernetes/src/test/java/oracle/kubernetes/operator/utils/GeneratedOperatorObjects.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io.kubernetes.client.models.V1ClusterRole;
99
import io.kubernetes.client.models.V1ClusterRoleBinding;
1010
import io.kubernetes.client.models.V1ConfigMap;
11-
import io.kubernetes.client.models.V1Job;
1211
import io.kubernetes.client.models.V1Namespace;
1312
import io.kubernetes.client.models.V1Role;
1413
import io.kubernetes.client.models.V1RoleBinding;
@@ -44,10 +43,6 @@ public int getObjectCount() {
4443
return operatorYaml.getObjectCount() + securityYaml.getObjectCount();
4544
}
4645

47-
public V1Job getOperatorPreUpgradeHookJob() {
48-
return operatorYaml.getOperatorPreUpgradeHookJob();
49-
}
50-
5146
public V1Namespace getOperatorNamespace() {
5247
return securityYaml.getOperatorNamespace();
5348
}
@@ -72,10 +67,6 @@ public V1Service getInternalOperatorService() {
7267
return operatorYaml.getInternalOperatorService();
7368
}
7469

75-
public V1Job getOperatorPreInstallHookJob() {
76-
return operatorYaml.getOperatorPreInstallHookJob();
77-
}
78-
7970
public V1ServiceAccount getOperatorServiceAccount() {
8071
return securityYaml.getOperatorServiceAccount();
8172
}

0 commit comments

Comments
 (0)