Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Scope
Commits
a082c289
Commit
a082c289
authored
7 years ago
by
Bryan Boreham
Browse files
Options
Download
Email Patches
Plain Diff
Don't de-reference pointers from AWS without checking
parent
99fad2f1
master
3810-cordon-control
Remove-stale-external-collaborators
add-weave-cloud
aliyun-sls-master
better-nat
bia-layout-prototype
bump-alpine
check-blank-id
consul-cleanup
container-netns
count-real-hosts
cri-container-state
delete-data
dependabot/go_modules/github.com/weaveworks/weave-2.6.3incompatible
docker-os
dont-stream-children
feature/read-password-from-file
feature/read-password-from-file-faq
fewer-closed-connections
filter-pseudo-pseudo-adjacencies
fix-build
fix-process-containername
fix-show-in
gh-pages
go-1-17-8
golangci-lint
hier-s3-key
less-quay
limit-parallel-decoding
map-container-to-pod-ip
more-renderers-b
no-hex-hostnames
no-latest-timestamp
node-unsafe-merge
pod-name-promql
popup-terminal-delete-pipe
release-1.11
release-1.7
release-1.8
release-1.9
remove-endpoint-benchmark
remove-proxima
s390x-support
scan-data
scope_s390x
sets-sorted-slice
simplify-load-report
streamline-withparents
unsafe-merge-nodes
update-aws-sdk
update-lodash
update-node-deps
update-opentracing
update-ugorji
wheel-event
wip-aws-timestamp
wip-child-ids
wip-drop-map-image
wip-render-docs
wip-simplify-connection-join
withlatests-slice
1.13.0
v1.13.2
v1.13.1
v1.12.0
v1.11.6
v1.11.5
v1.11.4
v1.11.3
v1.11.2
v1.11.1
v1.11.0
v1.10.2
v1.10.1
v1.10.0
v1.9.1
v1.9.0
v1.8.1
v1.8.0
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.6.7
v1.6.6
latest_release
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
probe/awsecs/client.go
+37
-14
probe/awsecs/client.go
with
37 additions
and
14 deletions
+37
-14
probe/awsecs/client.go
+
37
-
14
View file @
a082c289
...
...
@@ -89,28 +89,51 @@ func newClient(cluster string, cacheSize int, cacheExpiry time.Duration, cluster
},
nil
}
// Helper functions to map from the AWS practice of storing everything
// via a pointer to the Go practice of using zero values
func
stringOrBlank
(
s
*
string
)
string
{
if
s
==
nil
{
return
""
}
return
*
s
}
func
timeOrZero
(
t
*
time
.
Time
)
time
.
Time
{
if
t
==
nil
{
return
time
.
Time
{}
}
return
*
t
}
func
int64OrZero
(
i
*
int64
)
int64
{
if
i
==
nil
{
return
0
}
return
*
i
}
func
newECSTask
(
task
*
ecs
.
Task
)
EcsTask
{
return
EcsTask
{
TaskARN
:
*
task
.
TaskArn
,
CreatedAt
:
*
task
.
CreatedAt
,
TaskDefinitionARN
:
*
task
.
TaskDefinitionArn
,
StartedAt
:
*
task
.
StartedAt
,
StartedBy
:
*
task
.
StartedBy
,
TaskARN
:
stringOrBlank
(
task
.
TaskArn
)
,
CreatedAt
:
timeOrZero
(
task
.
CreatedAt
)
,
TaskDefinitionARN
:
stringOrBlank
(
task
.
TaskDefinitionArn
)
,
StartedAt
:
timeOrZero
(
task
.
StartedAt
)
,
StartedBy
:
stringOrBlank
(
task
.
StartedBy
)
,
}
}
func
newECSService
(
service
*
ecs
.
Service
)
EcsService
{
deploymentIDs
:=
make
([]
string
,
len
(
service
.
Deployments
))
for
i
,
deployment
:=
range
service
.
Deployments
{
deploymentIDs
[
i
]
=
*
deployment
.
Id
deploymentIDs
[
i
]
=
stringOrBlank
(
deployment
.
Id
)
}
return
EcsService
{
ServiceName
:
*
service
.
ServiceName
,
ServiceName
:
stringOrBlank
(
service
.
ServiceName
)
,
DeploymentIDs
:
deploymentIDs
,
DesiredCount
:
*
service
.
DesiredCount
,
PendingCount
:
*
service
.
PendingCount
,
RunningCount
:
*
service
.
RunningCount
,
TaskDefinitionARN
:
*
service
.
TaskDefinition
,
DesiredCount
:
int64OrZero
(
service
.
DesiredCount
)
,
PendingCount
:
int64OrZero
(
service
.
PendingCount
)
,
RunningCount
:
int64OrZero
(
service
.
RunningCount
)
,
TaskDefinitionARN
:
stringOrBlank
(
service
.
TaskDefinition
)
,
}
}
...
...
@@ -208,11 +231,11 @@ func (c ecsClientImpl) describeServicesBatch(names []string) {
}
for
_
,
failure
:=
range
resp
.
Failures
{
log
.
Warnf
(
"Failed to describe ECS service %s, ECS service report may be incomplete: %s"
,
*
failure
.
Arn
,
failure
.
Reason
)
log
.
Warnf
(
"Failed to describe ECS service %s, ECS service report may be incomplete: %s"
,
stringOrBlank
(
failure
.
Arn
)
,
stringOrBlank
(
failure
.
Reason
)
)
}
for
_
,
service
:=
range
resp
.
Services
{
if
service
!=
nil
{
if
service
!=
nil
&&
service
.
ServiceName
!=
nil
{
c
.
serviceCache
.
Set
(
*
service
.
ServiceName
,
newECSService
(
service
))
}
}
...
...
@@ -239,7 +262,7 @@ func (c ecsClientImpl) getTasks(taskARNs []string) {
}
for
_
,
failure
:=
range
resp
.
Failures
{
log
.
Warnf
(
"Failed to describe ECS task %s, ECS service report may be incomplete: %s"
,
*
failure
.
Arn
,
*
failure
.
Reason
)
log
.
Warnf
(
"Failed to describe ECS task %s, ECS service report may be incomplete: %s"
,
stringOrBlank
(
failure
.
Arn
)
,
stringOrBlank
(
failure
.
Reason
)
)
}
for
_
,
task
:=
range
resp
.
Tasks
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help