Skip to content
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

Initial implementation of containerNamePattern #1004

Merged
merged 8 commits into from Sep 24, 2018
Merged

Initial implementation of containerNamePattern #1004

merged 8 commits into from Sep 24, 2018

Conversation

marcust
Copy link
Contributor

@marcust marcust commented Apr 18, 2018

Replacement of #944

In general I'm quite happy, but even though the tests work and I tried I'm not so sure if there are not any naming configurations that do not work with watchers and the shutdown code.

@codecov
Copy link

codecov bot commented Apr 18, 2018

Codecov Report

Merging #1004 into master will increase coverage by 0.08%.
The diff coverage is 44.85%.

@@             Coverage Diff              @@
##             master    #1004      +/-   ##
============================================
+ Coverage     51.77%   51.86%   +0.08%     
- Complexity     1398     1413      +15     
============================================
  Files           147      148       +1     
  Lines          7573     7643      +70     
  Branches       1143     1151       +8     
============================================
+ Hits           3921     3964      +43     
- Misses         3278     3296      +18     
- Partials        374      383       +9
Impacted Files Coverage Δ Complexity Δ
...ven/docker/access/hc/DockerAccessWithHcClient.java 13.62% <0%> (ø) 12 <0> (ø) ⬇️
...rc/main/java/io/fabric8/maven/docker/LogsMojo.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...va/io/fabric8/maven/docker/service/RunService.java 48.84% <0%> (+0.88%) 22 <0> (ø) ⬇️
...c/main/java/io/fabric8/maven/docker/WatchMojo.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../io/fabric8/maven/docker/service/WatchService.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...c/main/java/io/fabric8/maven/docker/StartMojo.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...rc/main/java/io/fabric8/maven/docker/StopMojo.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...config/handler/property/PropertyConfigHandler.java 73.87% <0%> (ø) 112 <0> (ø) ⬇️
.../io/fabric8/maven/docker/service/QueryService.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ic8/maven/docker/config/RunImageConfiguration.java 90.27% <100%> (-1.22%) 46 <2> (-1)
... and 3 more

@rhuss
Copy link
Collaborator

rhuss commented Apr 18, 2018

Thanks a lot ! I will have a look asap, however quite busy this week (even busier than usual), so might take a bit ...

Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general except that I think the stop logic wont work as before (see inline comment).

We should go back to the original logic which evaluate labels which has been attached when a container has been started. Thats easier and we dont have to hunt for the name.

I did some refactorings/simplifications and pushed to your branch. 'hope you don't mind.

As I'm going to make a release today, we wont get this in right now, but for the next release.

I also plan to switch to Java 8, so the next releaes will be probably something like 0.30

String key = pomLabel.getKey();
Map<String, String> labels = container.getLabels();
return labels.containsKey(key) && pomLabel.equals(new PomLabel(labels.get(key)));
return container.getName().equals(namingConfiguration.calculateLastContainerName());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wont work as your build timestamp / index might be different than at the time when docker:start was called. Remember, this method is for checking whether a container should be stopped when mvn docker:stop has been called after one or more docker:start and it is supposed to stop all of them. Therefore the labels are examined whether it has been started by this particular pom. So we should keep the logic around excaming the marker labels on the containers. See also the documentation at https://dmp.fabric8.io/#docker:stop

@rhuss
Copy link
Collaborator

rhuss commented May 16, 2018

Many Thanks btw, and sorry for the delay ;-)

@marcust
Copy link
Contributor Author

marcust commented May 22, 2018

@rhuss sure, no worries. Didn't know this was there otherwise I'd have used it. So you changed what you commented on already, is there anything else that needs to be done?

@marcust marcust closed this Sep 4, 2018
@rhuss
Copy link
Collaborator

rhuss commented Sep 4, 2018

Sorry, overlooked your question ;-( I will relook at it and probably going to merge towards the end of the week.

@rhuss rhuss reopened this Sep 4, 2018
Marcus Thiesen and others added 3 commits September 23, 2018 18:25
* Moved most logic into an utility class with a single static method
* Moved calculation of the names to the service layer, Mojos should stay as slim as possible.
* Reused already existing "FormatParameterReplacer" (and introduced lambda for the first time)
@@ -188,7 +188,7 @@ private RunImageConfiguration extractRunConfiguration(ImageConfiguration fromCon
.links(valueProvider.getList(LINKS, config == null ? null : config.getLinks()))
.memory(valueProvider.getLong(MEMORY, config == null ? null : config.getMemory()))
.memorySwap(valueProvider.getLong(MEMORY_SWAP, config == null ? null : config.getMemorySwap()))
.namingStrategy(valueProvider.getString(NAMING_STRATEGY, config == null || config.getNamingStrategyRaw() == null ? null : config.getNamingStrategyRaw().name()))
.namingStrategy(valueProvider.getString(NAMING_STRATEGY, config == null || config.getNamingStrategy() == null ? null : config.getNamingStrategy().name()))
Copy link
Collaborator

@pepperbot pepperbot Sep 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this use of "namingStrategy"; it is deprecated. rule
MINOR Remove this use of "getNamingStrategy"; it is deprecated. rule
MINOR Remove this use of "getNamingStrategy"; it is deprecated. rule

if (runConfig.getContainerNamePattern() != null) {
return runConfig.getContainerNamePattern();
}
if (runConfig.getNamingStrategy() == RunImageConfiguration.NamingStrategy.alias) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this use of "getNamingStrategy"; it is deprecated. rule
MINOR Remove this use of "NamingStrategy"; it is deprecated. rule
MINOR Remove this use of "alias"; it is deprecated. rule

* @deprecated use {@link #getContainerNamePattern} instead
*/
@Deprecated
public NamingStrategy getNamingStrategy() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Do not forget to remove this deprecated code someday. rule

// Naming scheme for how to name container
@Deprecated // for backward compatibility, us containerNamePattern instead
public enum NamingStrategy {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Do not forget to remove this deprecated code someday. rule

/**
* @deprecated use {@link #containerNamePattern} instead
*/
@Deprecated
public Builder namingStrategy(NamingStrategy namingStrategy) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Do not forget to remove this deprecated code someday. rule

@Parameter
@Deprecated
private NamingStrategy namingStrategy;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Do not forget to remove this deprecated code someday. rule

/**
* @deprecated use {@link #containerNamePattern} instead
*/
@Deprecated
public Builder namingStrategy(String namingStrategy) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Do not forget to remove this deprecated code someday. rule

@pepperbot
Copy link
Collaborator

SonarQube analysis reported 11 issues

  • MINOR 6 minor
  • INFO 5 info

Watch the comments in this conversation to review them.

Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have refactored a bit and added documentation.

Thanks a lot @marcust the configuration syntax has been used without changes.

'hope its ok for you that I picked and polished it up.
Should be available now quite soon.

@rhuss rhuss merged commit b746dd7 into fabric8io:master Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants