-
Notifications
You must be signed in to change notification settings - Fork 319
Fixed docker facts to check for active swarm clusters before running docker swarm sub-commands. #817
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
Merged
Merged
Fixed docker facts to check for active swarm clusters before running docker swarm sub-commands. #817
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
81a9af0
Fixed docker facts to check for active swarm clusters before running …
nmaludy 2eaec42
Update lib/facter/docker.rb
nmaludy 96d36f6
Fixed docker facts to check for active swarm clusters before running …
nmaludy a8d8858
Merge remote-tracking branch 'origin/bugfix/docker-swarm-facts' into …
nmaludy c519de9
Confine facts based on availability of docker binary
nmaludy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -80,9 +80,20 @@ def interfaces | |||
Facter.add(:docker_worker_join_token) do | ||||
setcode do | ||||
if Facter::Core::Execution.which('docker') | ||||
val = Facter::Core::Execution.execute( | ||||
"#{docker_command} swarm join-token worker -q", timeout: 90 | ||||
# only run `docker swarm` commands if this node is in active in a cluster | ||||
docker_json_str = Facter::Core::Execution.execute( | ||||
"#{docker_command} info --format '{{json .}}'", timeout: 90 | ||||
) | ||||
begin | ||||
docker = JSON.parse(docker_json_str) | ||||
if docker.fetch('Swarm', {})['LocalNodeState'] == 'active' | ||||
val = Facter::Core::Execution.execute( | ||||
"#{docker_command} swarm join-token worker -q", timeout: 90 | ||||
) | ||||
end | ||||
rescue JSON::ParserError | ||||
nil | ||||
end | ||||
end | ||||
val | ||||
end | ||||
|
@@ -91,14 +102,26 @@ def interfaces | |||
Facter.add(:docker_manager_join_token) do | ||||
setcode do | ||||
if Facter::Core::Execution.which('docker') | ||||
val = Facter::Core::Execution.execute( | ||||
"#{docker_command} swarm join-token manager -q", timeout: 90 | ||||
# only run `docker swarm` commands if this node is in active in a cluster | ||||
docker_json_str = Facter::Core::Execution.execute( | ||||
"#{docker_command} info --format '{{json .}}'", timeout: 90 | ||||
) | ||||
begin | ||||
docker = JSON.parse(docker_json_str) | ||||
if docker.fetch('Swarm', {})['LocalNodeState'] == 'active' | ||||
val = Facter::Core::Execution.execute( | ||||
"#{docker_command} swarm join-token manager -q", timeout: 90 | ||||
) | ||||
end | ||||
rescue JSON::ParserError | ||||
nil | ||||
end | ||||
end | ||||
val | ||||
end | ||||
end | ||||
|
||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this came back after your latest merge |
||||
Facter.add(:docker) do | ||||
setcode do | ||||
docker_version = Facter.value(:docker_client_version) | ||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"Architecture": "x86_64", | ||
"BridgeNfIp6tables": true, | ||
"BridgeNfIptables": true, | ||
"CPUSet": true, | ||
"CPUShares": true, | ||
"CgroupDriver": "cgroupfs", | ||
"ClusterAdvertise": "", | ||
"ClusterStore": "", | ||
"ContainerdCommit": { | ||
"Expected": "4ab9917febca54791c5f071a9d1f404867857fcc", | ||
"ID": "4ab9917febca54791c5f071a9d1f404867857fcc" | ||
}, | ||
"Containers": 46, | ||
"ContainersPaused": 0, | ||
"ContainersRunning": 5, | ||
"ContainersStopped": 41, | ||
"CpuCfsPeriod": true, | ||
"CpuCfsQuota": true, | ||
"Debug": false, | ||
"DefaultRuntime": "runc", | ||
"DockerRootDir": "/var/lib/docker", | ||
"Driver": "aufs", | ||
"DriverStatus": [ | ||
[ | ||
"Root Dir", | ||
"/var/lib/docker/aufs" | ||
], | ||
[ | ||
"Backing Filesystem", | ||
"extfs" | ||
], | ||
[ | ||
"Dirs", | ||
"408" | ||
], | ||
[ | ||
"Dirperm1 Supported", | ||
"false" | ||
] | ||
], | ||
"ExperimentalBuild": false, | ||
"HttpProxy": "", | ||
"HttpsProxy": "", | ||
"ID": "VYL2:ZOEC:PG3V:3UFK:EXBT:FR3X:6IY4:ELX4:EQ5B:35C7:6OPZ:EQC6", | ||
"IPv4Forwarding": true, | ||
"Images": 50, | ||
"IndexServerAddress": "https://index.docker.io/v1/", | ||
"InitBinary": "docker-init", | ||
"InitCommit": { | ||
"Expected": "949e6fa", | ||
"ID": "949e6fa" | ||
}, | ||
"Isolation": "", | ||
"KernelMemory": true, | ||
"KernelVersion": "3.13.0-115-generic", | ||
"Labels": null, | ||
"LiveRestoreEnabled": false, | ||
"LoggingDriver": "json-file", | ||
"MemTotal": 1977839616, | ||
"MemoryLimit": true, | ||
"NCPU": 2, | ||
"NEventsListener": 0, | ||
"NFd": 52, | ||
"NGoroutines": 50, | ||
"Name": "docker00", | ||
"NoProxy": "", | ||
"OSType": "linux", | ||
"OomKillDisable": true, | ||
"OperatingSystem": "Ubuntu 14.04.5 LTS", | ||
"Plugins": { | ||
"Authorization": null, | ||
"Network": [ | ||
"bridge", | ||
"host", | ||
"macvlan", | ||
"null", | ||
"overlay" | ||
], | ||
"Volume": [ | ||
"local" | ||
] | ||
}, | ||
"RegistryConfig": { | ||
"IndexConfigs": { | ||
"docker.io": { | ||
"Mirrors": null, | ||
"Name": "docker.io", | ||
"Official": true, | ||
"Secure": true | ||
} | ||
}, | ||
"InsecureRegistryCIDRs": [ | ||
"127.0.0.0/8" | ||
], | ||
"Mirrors": [] | ||
}, | ||
"RuncCommit": { | ||
"Expected": "54296cf40ad8143b62dbcaa1d90e520a2136ddfe", | ||
"ID": "54296cf40ad8143b62dbcaa1d90e520a2136ddfe" | ||
}, | ||
"Runtimes": { | ||
"runc": { | ||
"path": "docker-runc" | ||
} | ||
}, | ||
"SecurityOptions": [ | ||
"name=apparmor" | ||
], | ||
"ServerVersion": "17.03.1-ce", | ||
"SwapLimit": false, | ||
"Swarm": { | ||
"Cluster": { | ||
"CreatedAt": "0001-01-01T00:00:00Z", | ||
"ID": "", | ||
"Spec": { | ||
"CAConfig": {}, | ||
"Dispatcher": {}, | ||
"EncryptionConfig": { | ||
"AutoLockManagers": false | ||
}, | ||
"Orchestration": {}, | ||
"Raft": { | ||
"ElectionTick": 0, | ||
"HeartbeatTick": 0 | ||
}, | ||
"TaskDefaults": {} | ||
}, | ||
"UpdatedAt": "0001-01-01T00:00:00Z", | ||
"Version": {} | ||
}, | ||
"ControlAvailable": false, | ||
"Error": "", | ||
"LocalNodeState": "inactive", | ||
"Managers": 0, | ||
"NodeAddr": "", | ||
"NodeID": "", | ||
"Nodes": 0, | ||
"RemoteManagers": null | ||
}, | ||
"SystemStatus": null, | ||
"SystemTime": "2017-04-11T01:12:52.292117616-04:00" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.