You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def poll_discovery_finished(resource_url, timeout_seconds, project_id):
"""Returns the discovery occurrence for a resource once it reaches a
terminal state."""
# resource_url = 'https://gcr.io/my-project/my-image@sha256:123'
# timeout_seconds = 20
# project_id = 'my-gcp-project'
import time
from grafeas.grafeas_v1 import DiscoveryOccurrence
from google.cloud.devtools import containeranalysis_v1
deadline = time.time() + timeout_seconds
client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
project_name = f"projects/{project_id}"
discovery_occurrence = None
while discovery_occurrence is None:
time.sleep(1)
filter_str = 'resourceUrl="{}" \
AND noteProjectId="goog-analysis" \
AND noteId="PACKAGE_VULNERABILITY"'.format(resource_url)
# [END containeranalysis_poll_discovery_occurrence_finished]
# The above filter isn't testable, since it looks for occurrences in a
# locked down project fall back to a more permissive filter for testing
filter_str = 'kind="DISCOVERY" AND resourceUrl="{}"'\
.format(resource_url)
# [START containeranalysis_poll_discovery_occurrence_finished]
result = grafeas_client.list_occurrences(parent=project_name, filter=filter_str)
# only one occurrence should ever be returned by ListOccurrences
# and the given filter
for item in result:
discovery_occurrence = item
if time.time() > deadline:
raise RuntimeError('timeout while retrieving discovery occurrence')
E RuntimeError: timeout while retrieving discovery occurrence
This test failed!
To configure my behavior, see the Build Cop Bot documentation.
If I'm commenting on this issue too often, add the
buildcop: quietlabel andI will stop commenting.
commit: d236cfc
buildURL: Build Status, Sponge
status: failed
Test output