Skip to content

Owls 91143 - Move internal certificate initialization logic to operator initalization #2486

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

Merged
merged 13 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ spec:
command:
- "bash"
- "/operator/livenessProbe.sh"
initialDelaySeconds: 20
initialDelaySeconds: 40
periodSeconds: 5
readinessProbe:
exec:
Expand Down
125 changes: 0 additions & 125 deletions operator/scripts/initialize-internal-operator-identity.sh

This file was deleted.

3 changes: 3 additions & 0 deletions operator/scripts/livenessProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
RETVAL=$(test -f /operator/debug-config/livenessProbeSuccessOverride ; echo $?)

FILE=/operator/.alive
if [ ! -f ${FILE} ]; then
exit $RETVAL
fi
OLDTIME=60
CURTIME=$(date +%s)
FILETIME=$(stat $FILE -c %Y)
Expand Down
2 changes: 0 additions & 2 deletions operator/scripts/operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ function relay_SIGTERM {

trap relay_SIGTERM SIGTERM

/operator/initialize-internal-operator-identity.sh

/operator/initialize-external-operator-identity.sh

if [[ ! -z "$REMOTE_DEBUG_PORT" ]]; then
Expand Down
15 changes: 14 additions & 1 deletion operator/src/main/java/oracle/kubernetes/operator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import oracle.kubernetes.operator.rest.RestConfigImpl;
import oracle.kubernetes.operator.rest.RestServer;
import oracle.kubernetes.operator.steps.DefaultResponseStep;
import oracle.kubernetes.operator.steps.InitializeInternalIdentityStep;
import oracle.kubernetes.operator.work.Component;
import oracle.kubernetes.operator.work.Container;
import oracle.kubernetes.operator.work.ContainerResolver;
Expand Down Expand Up @@ -84,6 +85,8 @@ public class Main {
private NamespaceWatcher namespaceWatcher;
protected OperatorEventWatcher operatorNamespaceEventWatcher;
private boolean warnedOfCrdAbsence;
private static NextStepFactory NEXT_STEP_FACTORY =
(next) -> createInitializeInternalIdentityStep(next);

private static String getConfiguredServiceAccount() {
return TuningParameters.getInstance().get("serviceaccount");
Expand Down Expand Up @@ -310,7 +313,12 @@ void startOperator(Runnable completionAction) {
}

private Step createStartupSteps() {
return Namespaces.getSelection(new StartupStepsVisitor());

return NEXT_STEP_FACTORY.createInternalInitializationStep(Namespaces.getSelection(new StartupStepsVisitor()));
}

private static Step createInitializeInternalIdentityStep(Step next) {
return new InitializeInternalIdentityStep(next);
}

private Step createOperatorNamespaceEventListStep() {
Expand Down Expand Up @@ -594,4 +602,9 @@ public void onThrowable(Packet packet, Throwable throwable) {
}
}

// an interface to provide a hook for unit testing.
interface NextStepFactory {
Step createInternalInitializationStep(Step next);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ public <T> T execute(
wrap(
createConfigMapAsync(
usage, requestParams.namespace, (V1ConfigMap) requestParams.body, callback));
private final CallFactory<V1Secret> createSecret =
(requestParams, usage, cont, callback) ->
wrap(
createSecretAsync(
usage, requestParams.namespace, (V1Secret) requestParams.body, callback));
private final CallFactory<V1ConfigMap> replaceConfigmap =
(requestParams, usage, cont, callback) ->
wrap(
Expand All @@ -185,6 +190,15 @@ public <T> T execute(
requestParams.namespace,
(V1Patch) requestParams.body,
callback));
private final CallFactory<V1Secret> replaceSecret =
(requestParams, usage, cont, callback) ->
wrap(
replaceSecretAsync(
usage,
requestParams.name,
requestParams.namespace,
(V1Secret) requestParams.body,
callback));
private final CallFactory<V1Pod> createPod =
(requestParams, usage, cont, callback) ->
wrap(
Expand Down Expand Up @@ -990,6 +1004,28 @@ responseStep, new RequestParams("createConfigMap", namespace, null, body, callPa
createConfigmap);
}

private Call createSecretAsync(
ApiClient client, String namespace, V1Secret body, ApiCallback<V1Secret> callback)
throws ApiException {
return new CoreV1Api(client)
.createNamespacedSecretAsync(namespace, body, pretty, null, null, callback);
}

/**
* Asynchronous step for creating secret.
*
* @param namespace Namespace
* @param body Body
* @param responseStep Response step for when call completes
* @return Asynchronous step
*/
public Step createSecretAsync(
String namespace, V1Secret body, ResponseStep<V1Secret> responseStep) {
return createRequestAsync(
responseStep, new RequestParams("createSecret", namespace, null, body, callParams),
createSecret);
}

private Call deleteConfigMapAsync(
ApiClient client,
String name,
Expand Down Expand Up @@ -1086,6 +1122,34 @@ public Step patchConfigMapAsync(
patchConfigMap);
}

/**
* Asynchronous step for replacing secret.
*
* @param name Name
* @param namespace Namespace
* @param body Body
* @param responseStep Response step for when call completes
* @return Asynchronous step
*/
public Step replaceSecretAsync(
String name, String namespace, V1Secret body, ResponseStep<V1Secret> responseStep) {
return createRequestAsync(
responseStep,
new RequestParams("replaceSecretAsync", namespace, name, body, ""),
replaceSecret);
}

private Call replaceSecretAsync(
ApiClient client,
String name,
String namespace,
V1Secret body,
ApiCallback<V1Secret> callback)
throws ApiException {
return new CoreV1Api(client)
.replaceNamespacedSecretAsync(name, namespace, body, pretty, dryRun, null, callback);
}

private Call listPodAsync(
ApiClient client, String namespace, String cont, ApiCallback<V1PodList> callback)
throws ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public class MessageKeys {
public static final String DOMAIN_ROLL_COMPLETED = "WLSKO-0191";
public static final String EXECUTE_MAKE_RIGHT_DOMAIN = "WLSKO-0192";
public static final String LOG_WAITING_COUNT = "WLSKO-0193";
public static final String INTERNAL_IDENTITY_INITIALIZATION_FAILED = "WLSKO-0194";


// domain status messages
public static final String DUPLICATE_SERVER_NAME_FOUND = "WLSDO-0001";
Expand Down
Loading