Skip to content

Conversation

@PauloMigAlmeida
Copy link
Contributor

@PauloMigAlmeida PauloMigAlmeida commented Sep 30, 2021

By default singularity-compose will always append --net to command to be executed in which it will prompt for either having --network=none or --fakeroot added.

Depending on your environment's configuration and isolation requirements you may want to be able to instruct singularity-compose not to append --net or any network-related params to the command sent to singularity CLI.

The example below will disable the network features:

  instance1:
    ...
    network:      
      enable: true | false

Paulo Almeida added 3 commits October 1, 2021 11:58
Signed-off-by: Paulo Almeida <paulo.almeidarodenas@niwa.co.nz>
Signed-off-by: Paulo Almeida <paulo.almeidarodenas@niwa.co.nz>
Signed-off-by: Paulo Almeida <paulo.almeidarodenas@niwa.co.nz>

# if not specified, set the default value for enable property
if "enable" not in self.network:
self.network["enable"] = True
Copy link
Member

Choose a reason for hiding this comment

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

For these two, how about:

for key in ["enable", "allocate_ip"]:
    self.network[key] = self.network.get(key, True)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the suggestion! Will do it it now

Copy link
Member

@vsoch vsoch left a comment

Choose a reason for hiding this comment

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

Oh I absolutely love this!! I made a suggestion for a more concise population of True values, and other than that let's just add a note to the CHANGELOG and another tiny version bump.

Signed-off-by: Paulo Almeida <paulo.almeidarodenas@niwa.co.nz>
@PauloMigAlmeida
Copy link
Contributor Author

Really liked the suggestion, thanks for that @vsoch

I just implemented the suggestions that you gave, let me know if there is anything else that I can do on this PR

options += self._get_network_commands(ip_address)

# Hostname
options += ["--hostname", self.name]
Copy link
Member

Choose a reason for hiding this comment

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

I haven't tried this so I don't know the answer - do we want a hostname if we don't enable network options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I tried that. It doesn't enable the network options.. I agree that sounds counter intuitive but singularity is funny sometimes, ay? 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But if you want I can move the --hostname under the same if statement.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's okay to leave - if there is some addition to a resolver file that gives the container a hostname without setting up networking, I suppose someone could want that? And it doesn't hurt to have it. So let's leave as is until there is more evidence to change that.

@vsoch vsoch merged commit 4c691eb into singularityhub:master Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants