Skip to content

Application Enhancement:#27

Merged
iasthc merged 3 commits intomainfrom
feat/add_workloadtype
Mar 13, 2026
Merged

Application Enhancement:#27
iasthc merged 3 commits intomainfrom
feat/add_workloadtype

Conversation

@tsaishawn
Copy link
Contributor

  1. Add deployment mount path
  2. Add CronJob workload
  3. Add Job workload

1. Add deployment mount path
2. Add CronJob workload
3. Add Job workload
Copilot AI review requested due to automatic review settings March 11, 2026 11:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for additional workload types and deployment storage configuration in the workload-operator’s Application controller, expanding beyond Deployment-only reconciliation.

Changes:

  • Introduces CronJob and Job workload reconciliation paths, including status observation and transition cleanup.
  • Moves Deployment-related config (Deployment/Service/PVC + MountPath) under spec.deploymentConfig and injects PVC volume mounts into Deployments.
  • Updates controller tests and RBAC to cover/manage the new resources.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/controller/application_controller.go Adds workload-type dispatch, cleanup on transitions, status observation for CronJob/Job, and watches/RBAC annotations.
internal/controller/application_controller_test.go Updates tests for deploymentConfig and adds CronJob/Job workload test coverage.
internal/application/deployment.go Reads Deployment from deploymentConfig and injects PVC volume mounts; adds deployment cleanup.
internal/application/service.go Reads Service from deploymentConfig, preserves ClusterIP/NodePorts, and adds service cleanup.
internal/application/pvc.go Reads PVC from deploymentConfig and adds PVC cleanup.
internal/application/cronjob.go Adds CronJob reconcile + cleanup implementation.
internal/application/job.go Adds Job reconcile + cleanup implementation (spec set only on create).
internal/application/helpers.go Removes unused condition constant.
config/rbac/role.yaml Grants controller permissions for batch CronJobs and Jobs.
go.mod / go.sum Bumps github.com/otterscale/api dependency to include new API fields/types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's capabilities by expanding the types of workloads it can manage. It introduces support for Kubernetes CronJobs and Jobs, alongside the existing Deployment functionality. The changes also include a structural refactor of deployment-related configurations, improving how persistent storage is integrated, and ensuring that the system intelligently manages and cleans up resources when an application's workload type changes. This provides greater flexibility in defining and operating diverse application patterns.

Highlights

  • New Workload Types: Introduced support for CronJob and Job workload types, allowing applications to be defined as scheduled tasks or one-off jobs in addition to long-running deployments.
  • Deployment Configuration Refactor: Refactored deployment-specific configurations (Deployment, Service, PersistentVolumeClaim, MountPath) into a new DeploymentConfig field within the Application spec for better organization and clarity.
  • Dynamic Resource Management: Implemented logic to dynamically create and clean up Kubernetes resources (Deployments, Services, PVCs, CronJobs, Jobs) based on the WorkloadType specified in the Application, ensuring only relevant resources exist.
  • Deployment Mount Path Support: Added functionality to inject PersistentVolumeClaim-backed volumes and volume mounts into Deployment pod specifications, enabling applications to easily utilize persistent storage at a specified mount path.
  • Enhanced Status Reporting: Updated the Application controller to observe and report status conditions (Ready, Progressing) and resource references (DeploymentRef, ServiceRef, PersistentVolumeClaimRef, CronJobRef, JobRef) specific to the active workload type.
Changelog
  • config/rbac/role.yaml
    • Added permissions for batchv1 CronJobs and Jobs.
  • go.mod
    • Updated github.com/otterscale/api dependency to v0.9.0-alpha.3.
  • go.sum
    • Updated checksums for github.com/otterscale/api to v0.9.0-alpha.3.
  • internal/application/cronjob.go
    • Added ReconcileCronJob function to create or update Kubernetes CronJobs.
    • Added CleanupCronJob function to delete owned CronJobs.
  • internal/application/deployment.go
    • Imported fmt and corev1 packages.
    • Updated ReconcileDeployment to use DeploymentConfig and inject PVCs.
    • Added injectPVC helper function to manage volume and volume mounts for PVCs.
    • Added CleanupDeployment function to delete owned Deployments.
  • internal/application/helpers.go
    • Removed ConditionTypeDegraded constant.
  • internal/application/job.go
    • Added ReconcileJob function to create or update Kubernetes Jobs, respecting immutability.
    • Added CleanupJob function to delete owned Jobs.
  • internal/application/pvc.go
    • Imported types package.
    • Updated ReconcilePVC to use DeploymentConfig and handle nil cases.
    • Added CleanupPVC function to delete owned PersistentVolumeClaims.
  • internal/application/service.go
    • Imported types package.
    • Updated ReconcileService to use DeploymentConfig and preserve NodePort values.
    • Added CleanupService function to delete owned Services.
  • internal/controller/application_controller.go
    • Imported batchv1 package.
    • Updated RBAC rules to include CronJobs and Jobs.
    • Refactored reconcileResources to handle different WorkloadTypes with cleanup logic.
    • Modified setReadyConditionFalse to return an error.
    • Updated updateStatus to reflect CronJob and Job statuses and resource references.
    • Replaced observeDeploymentStatus and observeDeploymentCondition with observeDeploymentStatuses, observeCronJobStatus, and observeJobStatus.
    • Updated SetupWithManager to own CronJob and Job resources.
  • internal/controller/application_controller_test.go
    • Imported batchv1 package.
    • Updated makeApplication to use DeploymentConfig.
    • Modified service and PVC tests to align with DeploymentConfig structure.
    • Added new test suites for CronJob and Job workloads, covering creation, ownership, status, and nil spec handling.
    • Added a test case to verify Job spec immutability on subsequent reconciles.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces significant enhancements by adding support for CronJob and Job workloads, alongside the existing Deployment workload. The changes are well-structured, including the necessary RBAC updates, API dependency changes, and extensive refactoring of the main controller logic to handle different workload types and their cleanup during transitions. The tests have also been expanded to cover these new features. My review focuses on improving maintainability by reducing code duplication in a few areas.

@tsaishawn tsaishawn added the enhancement New feature or request label Mar 11, 2026
@tsaishawn tsaishawn requested review from iasthc March 13, 2026 11:37
Copy link
Member

@iasthc iasthc left a comment

Choose a reason for hiding this comment

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

LGTM

@iasthc iasthc merged commit 18938cf into main Mar 13, 2026
11 checks passed
@iasthc iasthc deleted the feat/add_workloadtype branch March 13, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants