Skip to content

Shiffi ports and .......#383

Open
shiffiH wants to merge 5 commits intomainfrom
Shiffi_ports
Open

Shiffi ports and .......#383
shiffiH wants to merge 5 commits intomainfrom
Shiffi_ports

Conversation

@shiffiH
Copy link
Copy Markdown
Collaborator

@shiffiH shiffiH commented Nov 13, 2025

No description provided.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Nov 13, 2025

Greptile Overview

Greptile Summary

This PR updates Docker service networking configurations and resolves port conflicts across the AgCloud platform. The main changes involve replacing host.docker.internal references with proper Docker service names (db_api_service) in the sensorGuard service, updating multiple service port mappings to resolve conflicts, and optimizing Flink resource allocation. The changes transition the system from Docker Desktop-specific host networking to proper container-to-container communication using Docker's internal service discovery.

The sensorGuard service files are updated consistently to use db_api_service:8001 instead of host.docker.internal:8001 for API communications. The docker-compose.yml file contains extensive port reassignments including sound_metrics (8005→8003), sounds_classifier (8088→8056), and sensorguard-jobmanager (8081→8999). Additionally, Flink task slots are increased from 2 to 4 and memory allocation is boosted from 1728m to 2048m for better performance.

Important Files Changed

Filename Score Overview
services/sensorGuard/sensorGuard/flink_app/api/devices_updater.py 4/5 Updates API base URL from host.docker.internal to db_api_service for proper Docker networking
services/sensorGuard/sensorGuard/flink_app/main.py 5/5 Changes default API base URL to use Docker service name instead of host networking
services/sensorGuard/sensorGuard/flink_app/config/settings.py 4/5 Updates DEVICES_API_BASE configuration to use proper service name reference
services/sensorGuard/sensorGuard/flink_app/core/engine.py 5/5 Simple networking configuration change to use Docker internal service discovery
docker-compose.yml 2/5 Complex changes with port reassignments and resource optimization but contains network configuration issues

Confidence score: 2/5

  • This PR contains significant networking inconsistencies that could break deployment
  • Score lowered due to flink-net network being removed from networks section while still referenced by air services, and multiple complex changes that increase risk of service disruption
  • Pay close attention to docker-compose.yml file which has network configuration problems that will prevent proper service startup

Sequence Diagram

sequenceDiagram
    participant User
    participant Kafka as "Kafka Topic (sensors)"
    participant FlinkApp as "SensorGuard Flink App"
    participant Engine as "Engine"
    participant StateStore as "State Store"
    participant API as "DB API Service"
    participant Writers as "Writers (Kafka/Console)"
    participant SilenceSweep as "Silence Sweep Thread"

    User->>Kafka: "Publish sensor data"
    
    FlinkApp->>API: "Authenticate and get token"
    API-->>FlinkApp: "Return access token"
    
    FlinkApp->>API: "Fetch active sensors"
    API-->>FlinkApp: "Return sensor list"
    
    FlinkApp->>StateStore: "Initialize with active sensors"
    
    FlinkApp->>SilenceSweep: "Start background thread"
    
    loop Continuous Processing
        FlinkApp->>Kafka: "Consume sensor events"
        Kafka-->>FlinkApp: "Return sensor data JSON"
        
        FlinkApp->>FlinkApp: "Parse JSON to Event object"
        
        FlinkApp->>Engine: "process_event(Event)"
        
        Engine->>StateStore: "Check if device is known"
        StateStore-->>Engine: "Return device status"
        
        alt Device is known
            Engine->>StateStore: "Update device last_seen_ts"
            Engine->>API: "update_device_last_seen(device_id)"
            API-->>Engine: "Confirm update"
            
            Engine->>Engine: "Close keepalive alerts"
            
            Engine->>Engine: "Check for corrupted readings"
            Engine->>Engine: "Check for out-of-range values"
            Engine->>Engine: "Check for stuck sensor"
            
            alt Alert condition detected
                Engine->>StateStore: "Open new alert"
                Engine->>Writers: "write(Alert)"
                Writers->>Kafka: "Publish alert to alerts topic"
            else Alert condition resolved
                Engine->>StateStore: "Close existing alert"
                Engine->>Writers: "write(Alert with end_ts)"
                Writers->>Kafka: "Publish closed alert"
            end
        else Device unknown
            Engine->>Engine: "Skip processing"
        end
    end
    
    loop Periodic Silence Sweep
        SilenceSweep->>SilenceSweep: "Wait for interval"
        SilenceSweep->>API: "get_sensors_last_seen()"
        API-->>SilenceSweep: "Return sensor timestamps"
        
        SilenceSweep->>SilenceSweep: "Check for missing keepalive"
        
        alt Sensor silent too long
            SilenceSweep->>StateStore: "Create missing_keepalive alert"
            SilenceSweep->>Writers: "write(Alert)"
            Writers->>Kafka: "Publish silence alert"
        else Sensor back online
            SilenceSweep->>StateStore: "Close missing_keepalive alert"
            SilenceSweep->>Writers: "write(Alert with end_ts)"
            Writers->>Kafka: "Publish resolved alert"
        end
    end
Loading

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread docker-compose.yml
- HTTP_INFER_URL=http://fruit-inference-http:8004/infer_json
volumes:
- ./streaming/flink/jobs:/opt/flink/jobs:ro
- ./streaming/flink/jobs:/opt/flink/jobs
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Jobs volume mount changed from read-only (:ro) to read-write - could allow unintended modifications. Is read-write access needed for the Flink jobs directory?

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

1 participant