-
Notifications
You must be signed in to change notification settings - Fork 202
Improve support for sidecar containers #1202
Conversation
retest this please |
f33dd5a
to
4cf8190
Compare
|
||
/** | ||
* Enriches containers with health check probes. | ||
*/ | ||
public abstract class AbstractHealthCheckEnricher extends BaseEnricher { | ||
|
||
private enum Config implements Configs.Key { | ||
enrichAllContainers {{ d = "false"; }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
/** | ||
* Enriches containers with health check probes. | ||
*/ | ||
public abstract class AbstractHealthCheckEnricher extends BaseEnricher { | ||
|
||
private enum Config implements Configs.Key { | ||
enrichAllContainers {{ d = "false"; }}, | ||
enrichContainers {{ d = null; }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -80,6 +87,46 @@ private String describe(Probe probe) { | |||
return desc.toString(); | |||
} | |||
|
|||
protected List<ContainerBuilder> getContainersToEnrich(KubernetesListBuilder builder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally.. JMockit was not working well.. |
@nicolaferraro Thanks for the PR. Will review it soon :) |
@hrishin did you have time to have a look? |
@nicolaferraro sorry to say I got sidetracked from FMP these days. I can give initial look but @rohanKanojia @piyush1594 can help here to review it. @piyush1594 @rohanKanojia lets priorities this PR review ASAP |
Hi, Is there any news on this? I ran into this issue as well |
@nicolaferraro Would you like to rebase and push again. |
@nicolaferraro we have rebased it. Could you please verify it? |
Rebased... |
hey, @nicolaferraro 3.5.40 got released two days, you need to put it in 3.5.41. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like and support the intention of the PR. Although I haven't much time to dig into the details, the only thing I dislike a bit is the introduction of a kind of 'processing instruction' in form of a container env which doesn't get remove afterwards.
Actually, it would be nice if the Kubernetes Model would allow for such kind of transient meta data, so it might be worth to open an issue over there. In the meantime, I would add a postprocess step to remove the "FABRIC8_GENERATED" env vzr.
@@ -53,6 +53,12 @@ | |||
.endValueFrom() | |||
.build()); | |||
|
|||
ret.add( | |||
new EnvVarBuilder() | |||
.withName("FABRIC8_GENERATED") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we could use some other kind of meta-data for a container to indicate that it's auto generated? As this env var is visible within the container it might have side effects (although unlikely) but at least it pollutes the env namespace and increases the descriptors size. I understand that a container within a pod cannot carry any annotations/labels.
However, we need this information only during the (internal) build up of the model, so it sounds a bit over the top to make this information persistent. I suspect that the Kubernetes model objects don't carry any 'transient' meta information (which would be useful here), but maybe we could, in a postrpocess step, remove our markers before writing out the resource files ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was my concern too. I think having a enricher that removes the env variable at the end of the build is ok. However, I think that I can also use a annotation at pod level to specify the name of the container that is generated by fabric8. Let's keep this on hold and I'll try to provide a different implementation. I don't like the added env variable either.
9087d2b
to
038244b
Compare
93acc9c
to
d4c5dd0
Compare
Codecov Report
@@ Coverage Diff @@
## master #1202 +/- ##
===========================================
+ Coverage 35.76% 36.06% +0.3%
- Complexity 1110 1131 +21
===========================================
Files 180 180
Lines 9969 10041 +72
Branches 1617 1632 +15
===========================================
+ Hits 3565 3621 +56
- Misses 5976 5987 +11
- Partials 428 433 +5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rohanKanojia I think removing the env variable at the end is the easiest way to implement the functionality without affecting the end user. This way, the variable is just a marker within the enrichment process.
LGTM
d4c5dd0
to
e4344fc
Compare
|
||
public DeploymentOpenShiftConverter(PlatformMode mode, Long openshiftDeployTimeoutSeconds) { | ||
public DeploymentOpenShiftConverter(PlatformMode mode, Long openshiftDeployTimeoutSeconds, MavenProject project) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing the MavenProject
, can we only pass the artifactId
?
fixes #1037 |
@@ -38,7 +38,7 @@ | |||
|
|||
private final EnricherConfig config; | |||
private final String name; | |||
private EnricherContext enricherContext; | |||
public EnricherContext enricherContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like to have a public
field, maybe protected? Or create a getter?
deploymentConfigBuilder.editSpec().addNewTrigger().withType("ConfigChange").endTrigger().endSpec(); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private void setProcessingInstruction(List<String> containerNames) { | ||
Map<String, String> pi = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename to a meaningful var name?
We can have a varible called Processing Instructions(pi) in EnricherContext which would be propagated through the chain of enrichers rather than polluting application's container environment.
Don't add ImageChange triggers to containers other than main application containers. In Openshift mode, ImageStream is used by default. This is just a workaround for fabric8io#1037
This fixes #968, and its implementation is based on a discussion with @kameshsampath a long time ago.
This changes how the fragments are merged with generated resources. If a container in a fragment has a name (different from the f-m-p generated one) it's considered a sidecar and not merged, creating 2 containers. Fragments that don't declare a name (or with a matching one) are considered an addition to the default container.
I've changed the health-check enrichment process to enrich only generated containers and not sidecars. In order to do this I needed to add a env variable to generated containers (there are no annotation/labels at container level) to recognize it during enrichment.