Skip to content

Latest commit

 

History

History
174 lines (125 loc) · 6.4 KB

File metadata and controls

174 lines (125 loc) · 6.4 KB

Konveyor Kantra Analysis Findings and Modernization Example

This document demonstrates how Konveyor Kantra can identify legacy practices and guide application modernization, showing both analysis findings and implemented solutions.

About Konveyor and Kantra

Konveyor is an open-source project providing tools for application modernization, helping organizations migrate applications to cloud-native environments.

Kantra is Konveyor's static analysis tool that identifies:

  • Legacy patterns and antipatterns
  • Cloud-native readiness issues
  • Migration blockers and modernization opportunities
  • Dependency concerns

Analysis Process Flow

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Legacy App     │     │  Kantra         │     │  Analysis       │
│  (Source Code)  │ ──> │  Analysis       │ ──> │  Report         │
└─────────────────┘     │  Engine         │     │  (output.yaml)  │
                        └─────────────────┘     └─────────────────┘
                              │
                              ▼
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Custom Rules   │     │  Built-in       │     │  Modernization  │
│  (YAML files)   │ ──> │  Rules          │ ──> │  Solutions      │
└─────────────────┘     └─────────────────┘     └─────────────────┘

Project Structure and Setup

Components

mmdemo/
├── before-container/    # Legacy application to analyze
├── after-container/     # Modernized version with fixes
└── migration-konveyor/  # Analysis tools and configuration
    ├── rulesets/       # Custom and built-in rules
    ├── reports/        # Analysis output
    ├── kantra/         # Kantra binary and dependencies
    └── analyze.sh      # Analysis script

Platform Requirements

  • Tested on macOS (Darwin) with Apple Silicon (ARM64)
  • For other platforms:
    • macOS (Darwin) with Intel: Update KANTRA_URL to use x86_64 binary
    • Windows: Update KANTRA_URL to use windows binary and adjust paths
    • Linux: Update KANTRA_URL to use Linux binary and adjust paths

Dependencies

  • Konveyor Kantra v0.6.1
  • curl, unzip, bash shell, Git

Analysis Configuration

Analysis Settings (reports/settings.json)

{
  "analysis": {
    "mode": "containerless",
    "target": "cloud-readiness",
    "scope": "source",
    "output": {
      "format": "yaml",
      "include-insights": true
    }
  }
}

Execution Process

  1. Preparation: Clean artifacts, verify rules, check workspace
  2. Execution: Run analysis, evaluate rules, generate output
  3. Output Generation: Create logs and reports
  4. Validation: Review findings, verify rule triggers

Rules and Findings

Custom Rules Overview

Rule ID Description Pattern Effort
custom-ruleset-legacy-code-01000 Legacy Code Style .*\.java$ 3
custom-ruleset-legacy-config-01000 Hard coded Configuration .*\.properties$ 5
custom-ruleset-legacy-logging-01000 File-based Logging .*\.log$ 5
custom-ruleset-legacy-storage-01000 File-based Storage .*\.json$ 5

Analysis Findings Summary

  1. Legacy Code Style Issues

    • Files: Java model, service, and servlet classes
    • Issues: Missing documentation, inconsistent formatting, non-standard patterns
  2. Hard coded Configuration Paths

    • Files: Properties and configuration files
    • Issues: Local file system references, absolute paths, environment-specific values
  3. File-based Logging

    • Files: Log files and logging configuration
    • Issues: Local storage, non-structured logging, container-incompatible paths
  4. File-based Storage

    • Files: JSON data files
    • Issues: No transaction support, data consistency problems
  5. Embedded Cache Libraries

    • Files: EhCache JAR, configuration, and implementation
    • Issues: Container-incompatible caching, local dependencies

Modernization Solutions

1. Code Style Improvements

Location: after-container/src/main/java/

  • Implemented Google Style Guide compliance with Checkstyle
  • Added comprehensive documentation (JavaDoc at all levels)
  • Standardized 2-space indentation and 100-character line limits
  • Enabled automated style checking integrated with CI/CD

2. Configuration Management

Location: after-container/podman/

  • Moved configuration to environment variables with validation
  • Removed hard coded paths and implemented path resolution
  • Added container-friendly configuration and runtime detection
  • Implemented environment separation with secure defaults

3. Logging Modernization

Location: after-container/src/main/resources/logback.xml

  • Implemented container stdout/stderr logging with console appender
  • Added JSON-formatted structured logs with correlation
  • Removed all file-based logging mechanisms

4. Storage Modernization

Location: after-container/src/main/java/com/example/todo/service/TodoStorage.java

  • Replaced file storage with PostgreSQL database
  • Implemented connection pooling with HikariCP
  • Added proper transaction management and data validation
  • Removed all file system dependencies

5. Cache Modernization

Location: after-container/src/main/java/com/example/todo/service/

  • Removed EhCache dependency completely
  • Implemented stateless design with request context
  • Prepared for horizontal scaling with session handling

Conclusion

Konveyor Kantra helps:

  1. Identify legacy practices in applications
  2. Provide specific modernization guidance
  3. Track improvements through analysis
  4. Guide the modernization process

Successful application modernization typically requires a combination of automated tools, manual review, expert knowledge, and business context.

For more details on the modernization approach, see the after-container README.