1010import io .kubernetes .client .ApiException ;
1111import io .kubernetes .client .models .V1ConfigMap ;
1212import io .kubernetes .client .models .V1ObjectMeta ;
13- import io .kubernetes .client .models .V1Pod ;
13+ import oracle .kubernetes .operator .KubernetesConstants ;
14+ import oracle .kubernetes .operator .LabelConstants ;
1415import oracle .kubernetes .operator .logging .LoggingFacade ;
1516import oracle .kubernetes .operator .logging .LoggingFactory ;
1617import oracle .kubernetes .operator .logging .MessageKeys ;
@@ -43,37 +44,54 @@ public ScriptConfigMapStep(String namespace, Step next) {
4344
4445 @ Override
4546 public NextAction apply (Packet packet ) {
46- String name = "weblogic-domain-config-map" ;
47+ String name = KubernetesConstants . DOMAIN_CONFIG_MAP_NAME ;
4748 V1ConfigMap cm = new V1ConfigMap ();
4849
4950 V1ObjectMeta metadata = new V1ObjectMeta ();
5051 metadata .setName (name );
5152 metadata .setNamespace (namespace );
53+
54+ AnnotationHelper .annotateWithFormat (metadata );
55+
56+ Map <String , String > labels = new HashMap <>();
57+ labels .put (LabelConstants .CREATEDBYOPERATOR_LABEL , "true" );
58+ metadata .setLabels (labels );
59+
5260 cm .setMetadata (metadata );
5361
5462 Map <String , String > data = new HashMap <>();
5563
56- // HERE
5764 data .put ("livenessProbe.sh" ,
5865 "#!/bin/bash\n " +
59- "\n " +
6066 "# Kubernetes periodically calls this liveness probe script to determine whether\n " +
6167 "# the pod should be restarted. The script checks a WebLogic Server state file which\n " +
6268 "# is updated by the node manager.\n " +
69+ "STATEFILE=/shared/domain/$1/servers/$2/data/nodemanager/$2.state\n " +
70+ "if [ \\ `jps -l | grep -c \" weblogic.NodeManager\" \\ ` -eq 0 ]; then\n " +
71+ " exit 1\n " +
72+ "fi\n " +
73+ "if [ -f \\ ${STATEFILE} ] && [ \\ `grep -c \" FAILED_NOT_RESTARTABLE\" \\ ${STATEFILE}\\ ` -eq 1 ]; then\n " +
74+ " exit 1\n " +
75+ "fi\n " +
76+ "exit 0" );
77+
78+ data .put ("readinessProbe.sh" ,
79+ "#!/bin/bash\n " +
80+ "\n " +
81+ "# Kubernetes periodically calls this readiness probe script to determine whether\n " +
82+ "# the pod should be included in load balancing. The script checks a WebLogic Server state\n " +
83+ "# file which is updated by the node manager.\n " +
6384 "\n " +
64- "STATEFILE=${DOMAIN_HOME} /servers/${SERVER_NAME} /data/nodemanager/${SERVER_NAME} .state\n " +
85+ "STATEFILE=/shared/domain/$1 /servers/$2 /data/nodemanager/$2 .state\n " +
6586 "\n " +
6687 "if [ \\ `jps -l | grep -c \" weblogic.NodeManager\" \\ ` -eq 0 ]; then\n " +
67- " echo \" Error: WebLogic NodeManager process not found.\" \n " +
6888 " exit 1\n " +
6989 "fi\n " +
7090 "\n " +
71- "if [ -f \\ ${STATEFILE} ] && [ \\ `grep -c \" FAILED_NOT_RESTARTABLE\" \\ ${STATEFILE}\\ ` -eq 1 ]; then\n " +
72- " echo \" Error: WebLogic Server FAILED_NOT_RESTARTABLE.\" \n " +
91+ "if [ -f \\ ${STATEFILE} ] && [ \\ `grep -c \" RUNNING\" \\ ${STATEFILE}\\ ` -ne 1 ]; then\n " +
7392 " exit 1\n " +
7493 "fi\n " +
7594 "\n " +
76- "echo \" Info: Probe check passed.\" \n " +
7795 "exit 0" );
7896
7997 cm .setData (data );
@@ -97,14 +115,14 @@ public NextAction onSuccess(Packet packet, V1ConfigMap result, int statusCode,
97115 public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
98116 Map <String , List <String >> responseHeaders ) {
99117
100- LOGGER .info (MessageKeys .ADMIN_POD_CREATED , weblogicDomainUID , spec . getAsName () );
118+ LOGGER .info (MessageKeys .CM_CREATED , namespace );
101119 return doNext (packet );
102120 }
103121 });
104122 return doNext (create , packet );
105- } else if (result .getData ().entrySet ().containsAll (data .entrySet ())) {
123+ } else if (AnnotationHelper . checkFormatAnnotation ( result . getMetadata ()) && result .getData ().entrySet ().containsAll (data .entrySet ())) {
106124 // existing config map has correct data
107- LOGGER .fine (MessageKeys .ADMIN_POD_EXISTS , weblogicDomainUID , spec . getAsName () );
125+ LOGGER .fine (MessageKeys .CM_EXISTS , namespace );
108126 return doNext (packet );
109127 } else {
110128 // we need to update the config map
@@ -115,7 +133,7 @@ public NextAction onSuccess(Packet packet, V1ConfigMap result, int statusCode,
115133 @ Override
116134 public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
117135 Map <String , List <String >> responseHeaders ) {
118- LOGGER .info (MessageKeys .ADMIN_POD_REPLACED , weblogicDomainUID , spec . getAsName () );
136+ LOGGER .info (MessageKeys .CM_REPLACED , namespace );
119137 return doNext (packet );
120138 }
121139 });
0 commit comments