Skip to content

Commit

Permalink
Bump Dekorate to 3.4.0
Browse files Browse the repository at this point in the history
Changes: https://github.com/dekorateio/dekorate/releases/tag/3.4.0

This version includes a detecion cycle logic to spot issues when applying decorators. 

Actually, we have detected a couple of issues with the decorators:
- RemoveDeploymentTriggerDecorator:

```
[error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.RuntimeException: Cycle detected when ordering decorators: 
[ERROR] - io.quarkus.kubernetes.deployment.ChangeDeploymentTriggerDecorator
[ERROR] - io.quarkus.kubernetes.deployment.RemoveDeploymentTriggerDecorator
[ERROR] 
[ERROR]         at io.dekorate.utils.TopologicalSort.throwCycleDetectedException(TopologicalSort.java:166)
[ERROR]         at io.dekorate.utils.TopologicalSort.sortNodes(TopologicalSort.java:132)
[ERROR]         at io.dekorate.utils.TopologicalSort.sortDecorators(TopologicalSort.java:35)
```

- RemoveOptionalFromConfigMapEnvSource, ...

```
[error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.RuntimeException: Cycle detected when ordering decorators: 
- io.quarkus.kubernetes.deployment.RemoveOptionalFromSecretEnvSourceDecorator
- io.quarkus.kubernetes.deployment.RemoveOptionalFromSecretKeySelectorDecorator
- io.quarkus.kubernetes.deployment.RemoveOptionalFromConfigMapEnvSourceDecorator
- io.quarkus.kubernetes.deployment.RemoveOptionalFromConfigMapKeySelectorDecorator
```
  • Loading branch information
Sgitario committed Feb 9, 2023
1 parent dfa30a2 commit 239c632
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<kotlin.version>1.8.10</kotlin.version>
<kotlin.coroutine.version>1.6.4</kotlin.coroutine.version>
<kotlin-serialization.version>1.4.1</kotlin-serialization.version>
<dekorate.version>3.3.1</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<dekorate.version>3.4.0</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.0</awaitility.version>
<jboss-logmanager.version>1.1.1</jboss-logmanager.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.quarkus.kubernetes.deployment;

import io.dekorate.kubernetes.decorator.AddToMatchingLabelsDecorator;
import io.dekorate.kubernetes.decorator.AddToSelectorDecorator;
import io.dekorate.kubernetes.decorator.Decorator;
import io.dekorate.kubernetes.decorator.NamedResourceDecorator;
import io.dekorate.kubernetes.decorator.ResourceProvidingDecorator;
Expand Down Expand Up @@ -29,6 +30,6 @@ public Class<? extends Decorator>[] after() {

@Override
public Class<? extends Decorator>[] before() {
return new Class[] { AddToMatchingLabelsDecorator.class };
return new Class[] { AddToMatchingLabelsDecorator.class, AddToSelectorDecorator.class };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
String imageStreamWithTag = name + ":" + i.getTag();
result.add(new DecoratorBuildItem(OPENSHIFT, new ApplyContainerImageDecorator(name, imageStreamWithTag)));
// remove the default trigger which has a wrong version
result.add(new DecoratorBuildItem(OPENSHIFT, new RemoveDeploymentTriggerDecorator()));
result.add(new DecoratorBuildItem(OPENSHIFT, new RemoveDeploymentTriggerDecorator(name)));
// re-add the trigger with the correct version
result.add(new DecoratorBuildItem(OPENSHIFT, new ChangeDeploymentTriggerDecorator(name, imageStreamWithTag)));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

public class RemoveDeploymentTriggerDecorator extends NamedResourceDecorator<DeploymentConfigSpecFluent<?>> {

public RemoveDeploymentTriggerDecorator(String name) {
super(name);
}

@Override
public void andThenVisit(DeploymentConfigSpecFluent<?> deploymentConfigSpec, ObjectMeta objectMeta) {
deploymentConfigSpec.withTriggers(Collections.emptyList());
Expand All @@ -19,4 +23,9 @@ public void andThenVisit(DeploymentConfigSpecFluent<?> deploymentConfigSpec, Obj
public Class<? extends Decorator>[] after() {
return new Class[] { ApplyDeploymentTriggerDecorator.class };
}

@Override
public Class<? extends Decorator>[] before() {
return new Class[] { ChangeDeploymentTriggerDecorator.class };
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.quarkus.kubernetes.deployment;

import io.dekorate.knative.decorator.AddConfigMapVolumeToRevisionDecorator;
import io.dekorate.knative.decorator.AddSecretVolumeToRevisionDecorator;
import io.dekorate.kubernetes.decorator.AddConfigMapVolumeDecorator;
import io.dekorate.kubernetes.decorator.AddEnvVarDecorator;
import io.dekorate.kubernetes.decorator.AddSecretVolumeDecorator;
import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator;
import io.dekorate.kubernetes.decorator.Decorator;
import io.fabric8.kubernetes.api.model.ConfigMapEnvSourceFluent;
Expand All @@ -14,6 +18,8 @@ public void andThenVisit(ConfigMapEnvSourceFluent ref) {

@Override
public Class<? extends Decorator>[] after() {
return new Class[] { AddEnvVarDecorator.class, ApplicationContainerDecorator.class };
return new Class[] { AddEnvVarDecorator.class,
AddSecretVolumeDecorator.class, AddSecretVolumeToRevisionDecorator.class,
AddConfigMapVolumeToRevisionDecorator.class, AddConfigMapVolumeDecorator.class };
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.quarkus.kubernetes.deployment;

import io.dekorate.knative.decorator.AddConfigMapVolumeToRevisionDecorator;
import io.dekorate.knative.decorator.AddSecretVolumeToRevisionDecorator;
import io.dekorate.kubernetes.decorator.AddConfigMapVolumeDecorator;
import io.dekorate.kubernetes.decorator.AddEnvVarDecorator;
import io.dekorate.kubernetes.decorator.AddSecretVolumeDecorator;
import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator;
import io.dekorate.kubernetes.decorator.Decorator;
import io.fabric8.kubernetes.api.model.ConfigMapKeySelectorFluent;
Expand All @@ -14,6 +18,8 @@ public void andThenVisit(ConfigMapKeySelectorFluent fluent) {

@Override
public Class<? extends Decorator>[] after() {
return new Class[] { AddEnvVarDecorator.class, ApplicationContainerDecorator.class };
return new Class[] { AddEnvVarDecorator.class,
AddSecretVolumeDecorator.class, AddSecretVolumeToRevisionDecorator.class,
AddConfigMapVolumeToRevisionDecorator.class, AddConfigMapVolumeDecorator.class };
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

package io.quarkus.kubernetes.deployment;

import io.dekorate.knative.decorator.AddConfigMapVolumeToRevisionDecorator;
import io.dekorate.knative.decorator.AddSecretVolumeToRevisionDecorator;
import io.dekorate.kubernetes.decorator.AddConfigMapVolumeDecorator;
import io.dekorate.kubernetes.decorator.AddEnvVarDecorator;
import io.dekorate.kubernetes.decorator.AddSecretVolumeDecorator;
import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator;
import io.dekorate.kubernetes.decorator.Decorator;
import io.fabric8.kubernetes.api.model.SecretEnvSourceFluent;
Expand All @@ -15,7 +19,9 @@ public void andThenVisit(SecretEnvSourceFluent ref) {

@Override
public Class<? extends Decorator>[] after() {
return new Class[] { AddEnvVarDecorator.class, ApplicationContainerDecorator.class };
return new Class[] { AddEnvVarDecorator.class,
AddSecretVolumeDecorator.class, AddSecretVolumeToRevisionDecorator.class,
AddConfigMapVolumeToRevisionDecorator.class, AddConfigMapVolumeDecorator.class };
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

package io.quarkus.kubernetes.deployment;

import io.dekorate.knative.decorator.AddConfigMapVolumeToRevisionDecorator;
import io.dekorate.knative.decorator.AddSecretVolumeToRevisionDecorator;
import io.dekorate.kubernetes.decorator.AddConfigMapVolumeDecorator;
import io.dekorate.kubernetes.decorator.AddEnvVarDecorator;
import io.dekorate.kubernetes.decorator.AddSecretVolumeDecorator;
import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator;
import io.dekorate.kubernetes.decorator.Decorator;
import io.fabric8.kubernetes.api.model.SecretKeySelectorFluent;
Expand All @@ -15,6 +19,8 @@ public void andThenVisit(SecretKeySelectorFluent fluent) {

@Override
public Class<? extends Decorator>[] after() {
return new Class[] { AddEnvVarDecorator.class, ApplicationContainerDecorator.class };
return new Class[] { AddEnvVarDecorator.class,
AddSecretVolumeDecorator.class, AddSecretVolumeToRevisionDecorator.class,
AddConfigMapVolumeToRevisionDecorator.class, AddConfigMapVolumeDecorator.class };
}
}

0 comments on commit 239c632

Please sign in to comment.