Skip to content

Commit 547e5c7

Browse files
authored
fix pipeline reconciler namespacing (#108)
1 parent 51a6e16 commit 547e5c7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

hoptimator-k8s/src/main/java/com/linkedin/hoptimator/k8s/K8sApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void update(T obj) throws SQLException {
108108
}
109109

110110
public void updateStatus(T obj, Object status) throws SQLException {
111-
if (!endpoint.clusterScoped()) {
111+
if (obj.getMetadata().getNamespace() == null && !endpoint.clusterScoped()) {
112112
obj.getMetadata().namespace(context.namespace());
113113
}
114114
KubernetesApiResponse<T> resp = context.<T, U>generic(endpoint).updateStatus(obj, x -> status);

hoptimator-operator/src/main/java/com/linkedin/hoptimator/operator/PipelineOperatorApp.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
public class PipelineOperatorApp {
2727
private static final Logger log = LoggerFactory.getLogger(PipelineOperatorApp.class);
2828

29+
final String watchNamespace;
2930
final Properties connectionProperties;
3031

31-
public PipelineOperatorApp(Properties connectionProperties) {
32+
public PipelineOperatorApp(String watchNamespace, Properties connectionProperties) {
33+
this.watchNamespace = watchNamespace;
3234
this.connectionProperties = connectionProperties;
3335
}
3436

@@ -55,18 +57,14 @@ public static void main(String[] args) throws Exception {
5557
}
5658

5759
String watchNamespaceInput = cmd.getOptionValue("watch", "");
58-
59-
Properties props = new Properties();
60-
props.put("k8s.namespace", watchNamespaceInput);
61-
62-
new PipelineOperatorApp(props).run();
60+
new PipelineOperatorApp(watchNamespaceInput, new Properties()).run();
6361
}
6462

6563
public void run() throws Exception {
6664
K8sContext context = new K8sContext(connectionProperties);
6765

6866
// register informers
69-
context.registerInformer(K8sApiEndpoints.PIPELINES, Duration.ofMinutes(5), context.namespace());
67+
context.registerInformer(K8sApiEndpoints.PIPELINES, Duration.ofMinutes(5), watchNamespace);
7068

7169
List<Controller> controllers = new ArrayList<>();
7270
// TODO: add additional controllers from ControllerProvider SPI

hoptimator-operator/src/main/java/com/linkedin/hoptimator/operator/pipeline/PipelineReconciler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.time.Duration;
44
import java.util.Arrays;
5+
import java.util.Properties;
56

67
import org.slf4j.Logger;
78
import org.slf4j.LoggerFactory;
@@ -42,10 +43,11 @@ private PipelineReconciler(K8sContext context) {
4243
public Result reconcile(Request request) {
4344
log.info("Reconciling request {}", request);
4445
String name = request.getName();
46+
String namespace = request.getNamespace();
4547

4648
Result result = new Result(true, pendingRetryDuration());
4749
try {
48-
V1alpha1Pipeline object = pipelineApi.get(name);
50+
V1alpha1Pipeline object = pipelineApi.get(namespace, name);
4951

5052
if (object == null) {
5153
log.info("Object {} deleted. Skipping.", name);

0 commit comments

Comments
 (0)