You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Andrew Donald Kennedy <no...@github.com> on 2016/04/14 22:10:11 UTC

[jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Do not reset `entrypoint` or `commands` options to an empty list, which overrides any Dockerfile provided values.
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/260

-- Commit Summary --

  * Make DockerTemplateOptions values null safe

-- File Changes --

    M docker/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java (22)
    M docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java (8)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/260.patch
https://github.com/jclouds/jclouds-labs/pull/260.diff

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -83,15 +83,15 @@
>     private static final String NO_IMAGE = "jclouds-placeholder-for-image";
>  
>     protected List<String> dns = ImmutableList.of();
> -   protected String hostname;
> -   protected Integer memory;
> -   protected Integer cpuShares;
> -   protected List<String> entrypoint = ImmutableList.of();
> -   protected List<String> commands = ImmutableList.of();
> +   @Nullable protected String hostname;
> +   @Nullable protected Integer memory;
> +   @Nullable protected Integer cpuShares;
> +   @Nullable List<String> entrypoint;
> +   @Nullable List<String> commands;

Out of curiosity, does enforcing empty lists here (and never null) cause an undesired behaviour when creating containers using the docker compute service adapter?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260/files/f856176702be7ed9f376edbfb6d8fa8595238616#r59854213

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Ignasi Barrera <no...@github.com>.
Closed #260.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260#event-633095182

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Andrew Donald Kennedy <no...@github.com>.
@andreaturli This and #261 are more changes needed for Clocker

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260#issuecomment-210129206

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Andrew Donald Kennedy <no...@github.com>.
> @@ -83,15 +83,15 @@
>     private static final String NO_IMAGE = "jclouds-placeholder-for-image";
>  
>     protected List<String> dns = ImmutableList.of();
> -   protected String hostname;
> -   protected Integer memory;
> -   protected Integer cpuShares;
> -   protected List<String> entrypoint = ImmutableList.of();
> -   protected List<String> commands = ImmutableList.of();
> +   @Nullable protected String hostname;
> +   @Nullable protected Integer memory;
> +   @Nullable protected Integer cpuShares;
> +   @Nullable List<String> entrypoint;
> +   @Nullable List<String> commands;

No, we do an `isEmpty()` check on the non `@Nullable` values before setting them in the `createContainer` API call

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260/files/f856176702be7ed9f376edbfb6d8fa8595238616#r59901886

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Ignasi Barrera <no...@github.com>.
Apologies for the delay. I've finally had time to get back to this and properly read the Brooklyn issue and understand the fix. Pushed to master as [44ddd688](http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/44ddd688). Thanks @grkvlt!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260#issuecomment-211972505

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Andrew Donald Kennedy <no...@github.com>.
> @@ -83,15 +83,15 @@
>     private static final String NO_IMAGE = "jclouds-placeholder-for-image";
>  
>     protected List<String> dns = ImmutableList.of();
> -   protected String hostname;
> -   protected Integer memory;
> -   protected Integer cpuShares;
> -   protected List<String> entrypoint = ImmutableList.of();
> -   protected List<String> commands = ImmutableList.of();
> +   @Nullable protected String hostname;
> +   @Nullable protected Integer memory;
> +   @Nullable protected Integer cpuShares;
> +   @Nullable List<String> entrypoint;
> +   @Nullable List<String> commands;

FYI, the JSON that the Docker API recieves will treat null differently to an empty list. So for the entrypoint value, null means 'do nothing, just use the values from the image' but an empty list means 'change this value to an empty list, and discard the value from the image' which is why we need to be `@Nullable` here.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260/files/f856176702be7ed9f376edbfb6d8fa8595238616#r61090728

Re: [jclouds/jclouds-labs] Make DockerTemplateOptions values null safe (#260)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -83,15 +83,15 @@
>     private static final String NO_IMAGE = "jclouds-placeholder-for-image";
>  
>     protected List<String> dns = ImmutableList.of();
> -   protected String hostname;
> -   protected Integer memory;
> -   protected Integer cpuShares;
> -   protected List<String> entrypoint = ImmutableList.of();
> -   protected List<String> commands = ImmutableList.of();
> +   @Nullable protected String hostname;
> +   @Nullable protected Integer memory;
> +   @Nullable protected Integer cpuShares;
> +   @Nullable List<String> entrypoint;
> +   @Nullable List<String> commands;

Which is the purpose of making them nullable then? Having null collections is a bad pattern and a potential source of NPEs; we should try to avoid them.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/260/files/f856176702be7ed9f376edbfb6d8fa8595238616#r59949494