Skip to content

Lack of available impact data from the API crashes the scanner #622

@jnioche

Description

@jnioche
cloud_scanner_cli::impact_provider: Skipped counting resource: CloudResourceWithImpacts {
    cloud_resource: CloudResource {
        provider: AWS,
        id: "i-071e5a6416886ca8f",
        location: UsageLocation {
            aws_region: "us-east-1",
            iso_country_code: "USA",
        },
        resource_details: Instance {
            instance_type: "r8g.xlarge",
            usage: Some(
                InstanceUsage {
                    average_cpu_load: 99.19700071378819,
                    state: Running,
                },
            ),
        },
        tags: [
            CloudResourceTag {
                key: "Cluster",
                value: Some(
                    "crawl",
                ),
            },
            CloudResourceTag {
                key: "Name",
                value: Some(
                    "Hadoop Core",
                ),
            },
            CloudResourceTag {
                key: "Role",
                value: Some(
                    "task",
                ),
            },
            CloudResourceTag {
                key: "Hadoop",
                value: Some(
                    "Running",
                ),
            },
        ],
    },
    impacts_values: None,
    impacts_duration_hours: 1.0,
} while building summary because it has no impact data

causes the scanner to panic

called `Option::unwrap()` on a `None` value
rocket::server: Handler metrics panicked.
rocket::server: This is an application bug.
rocket::server: A panic in Rust must be treated as an exceptional event.
rocket::server: Panicking is not a suitable error handling mechanism.
rocket::server: Unwinding, the result of a panic, is an expensive operation.
rocket::server: Panics will degrade application performance.
rocket::server: Instead of panicking, return `Option` and/or `Result`.
rocket::server: Values of either type can be returned directly from handlers.
rocket::server: A panic is treated as an internal server error.
rocket::server: Outcome: Error(500 Internal Server Error)
rocket::server: No 500 catcher registered. Using Rocket default.
rocket::server: sending response: Response {
    status: 500,
    version: HTTP/1.1,
    headers: {
        "content-type": "text/html; charset=utf-8",
        "server": "Rocket",
        "permissions-policy": "interest-cohort=()",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "content-length": "488",
    },
    body: Body(
        Streaming,
    ),
}'''

as a result a 500 is returned to Prometheus and no data is available at all.

The exporter should handle the lack of impact data gracefully 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions