Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support v2 backing image #3295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/backingimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (s *Server) BackingImageCreate(rw http.ResponseWriter, req *http.Request) e
return err
}

bi, err := s.m.CreateBackingImage(input.Name, input.ExpectedChecksum, input.SourceType, input.Parameters, input.MinNumberOfCopies, input.NodeSelector, input.DiskSelector, input.Secret, input.SecretNamespace)
bi, err := s.m.CreateBackingImage(input.Name, input.ExpectedChecksum, input.SourceType, input.Parameters, input.MinNumberOfCopies, input.NodeSelector, input.DiskSelector, input.Secret, input.SecretNamespace, input.DataEngine)
if err != nil {
return errors.Wrapf(err, "failed to create backing image %v from source type %v with parameters %+v", input.Name, input.SourceType, input.Parameters)
}
Expand Down
2 changes: 2 additions & 0 deletions api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ type BackingImage struct {
NodeSelector []string `json:"nodeSelector"`
MinNumberOfCopies int `json:"minNumberOfCopies"`
ExpectedChecksum string `json:"expectedChecksum"`
DataEngine string `json:"dataEngine"`

DiskFileStatusMap map[string]longhorn.BackingImageDiskFileStatus `json:"diskFileStatusMap"`
Size int64 `json:"size"`
Expand Down Expand Up @@ -2011,6 +2012,7 @@ func toBackingImageResource(bi *longhorn.BackingImage, apiContext *api.ApiContex
MinNumberOfCopies: bi.Spec.MinNumberOfCopies,
NodeSelector: bi.Spec.NodeSelector,
DiskSelector: bi.Spec.DiskSelector,
DataEngine: string(bi.Spec.DataEngine),

DiskFileStatusMap: diskFileStatusMap,
Size: bi.Status.Size,
Expand Down
4 changes: 3 additions & 1 deletion client/generated_backing_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type BackingImage struct {

CurrentChecksum string `json:"currentChecksum,omitempty" yaml:"current_checksum,omitempty"`

DataEngine string `json:"dataEngine,omitempty" yaml:"data_engine,omitempty"`

DeletionTimestamp string `json:"deletionTimestamp,omitempty" yaml:"deletion_timestamp,omitempty"`

DiskFileStatusMap map[string]BackingImageDiskFileStatus `json:"diskFileStatusMap,omitempty" yaml:"disk_file_status_map,omitempty"`
Expand All @@ -27,7 +29,7 @@ type BackingImage struct {

Secret string `json:"secret,omitempty" yaml:"secret,omitempty"`

SecretNamespace string `json:"secretNamespace,omitempty" yaml:"secretNamespace,omitempty"`
SecretNamespace string `json:"secretNamespace,omitempty" yaml:"secret_namespace,omitempty"`
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Breaking change detected in YAML tag for SecretNamespace field

The change from secretNamespace to secret_namespace in the YAML tag is a breaking change that affects BackingImage CRD configurations. This is confirmed by:

  1. The CRD definition in k8s/crds.yaml still uses secretNamespace in the spec
  2. Multiple Go code references show active usage of this field for encryption and secret handling
  3. No migration documentation was found for this breaking change

Recommendations:

  • Keep the YAML tag as secretNamespace to maintain backward compatibility
  • If snake_case standardization is required, it should be part of a major version upgrade with proper migration documentation
🔗 Analysis chain

Verify the impact of YAML tag change for SecretNamespace.

The YAML tag change from secretNamespace to secret_namespace is a breaking change that could affect existing YAML configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for YAML configurations that might be affected by the tag change
# Expected: Find any YAML files using the old secretNamespace format

# Search for YAML files using the old format
rg "secretNamespace:" --type yaml

# Check for any migration documentation
fd -e md -e txt | xargs rg -l "secret.?namespace"

Length of output: 175


Script:

#!/bin/bash
# Let's examine the CRD definition to understand the impact
cat k8s/crds.yaml

# Also search for any related test files or examples
fd -e yaml -e yml | xargs rg -l "secret.?namespace"

# Check for any related Go code that might handle this field
rg "SecretNamespace" -t go -C 2

Length of output: 131177


Script:

#!/bin/bash
# Let's check for any existing YAML files using the old format in examples, tests, or docs
rg -t yaml "secretNamespace:" -B 2 -A 2

# Check for any Go code references to understand the usage
rg "SecretNamespace" -t go -B 2 -A 2

# Look for any migration or upgrade documentation
fd -e md | xargs rg -l "secret.?namespace|breaking.?changes"

Length of output: 25559


Size int64 `json:"size,omitempty" yaml:"size,omitempty"`

Expand Down
2 changes: 2 additions & 0 deletions client/generated_backing_image_disk_file_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const (
type BackingImageDiskFileStatus struct {
Resource `yaml:"-"`

DataEngine string `json:"dataEngine,omitempty" yaml:"data_engine,omitempty"`

LastStateTransitionTime string `json:"lastStateTransitionTime,omitempty" yaml:"last_state_transition_time,omitempty"`

Message string `json:"message,omitempty" yaml:"message,omitempty"`
Expand Down
Loading
Loading