...

Source file src/k8s.io/api/storagemigration/v1alpha1/types.go

Documentation: k8s.io/api/storagemigration/v1alpha1

     1  /*
     2  Copyright 2024 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1alpha1
    18  
    19  import (
    20  	corev1 "k8s.io/api/core/v1"
    21  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    22  )
    23  
    24  // +genclient
    25  // +genclient:nonNamespaced
    26  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    27  // +k8s:prerelease-lifecycle-gen:introduced=1.30
    28  
    29  // StorageVersionMigration represents a migration of stored data to the latest
    30  // storage version.
    31  type StorageVersionMigration struct {
    32  	metav1.TypeMeta `json:",inline"`
    33  	// Standard object metadata.
    34  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    35  	// +optional
    36  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    37  	// Specification of the migration.
    38  	// +optional
    39  	Spec StorageVersionMigrationSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    40  	// Status of the migration.
    41  	// +optional
    42  	Status StorageVersionMigrationStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
    43  }
    44  
    45  // Spec of the storage version migration.
    46  type StorageVersionMigrationSpec struct {
    47  	// The resource that is being migrated. The migrator sends requests to
    48  	// the endpoint serving the resource.
    49  	// Immutable.
    50  	Resource GroupVersionResource `json:"resource" protobuf:"bytes,1,opt,name=resource"`
    51  	// The token used in the list options to get the next chunk of objects
    52  	// to migrate. When the .status.conditions indicates the migration is
    53  	// "Running", users can use this token to check the progress of the
    54  	// migration.
    55  	// +optional
    56  	ContinueToken string `json:"continueToken,omitempty" protobuf:"bytes,2,opt,name=continueToken"`
    57  	// TODO: consider recording the storage version hash when the migration
    58  	// is created. It can avoid races.
    59  }
    60  
    61  // The names of the group, the version, and the resource.
    62  type GroupVersionResource struct {
    63  	// The name of the group.
    64  	Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
    65  	// The name of the version.
    66  	Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
    67  	// The name of the resource.
    68  	Resource string `json:"resource,omitempty" protobuf:"bytes,3,opt,name=resource"`
    69  }
    70  
    71  type MigrationConditionType string
    72  
    73  const (
    74  	// Indicates that the migration is running.
    75  	MigrationRunning MigrationConditionType = "Running"
    76  	// Indicates that the migration has completed successfully.
    77  	MigrationSucceeded MigrationConditionType = "Succeeded"
    78  	// Indicates that the migration has failed.
    79  	MigrationFailed MigrationConditionType = "Failed"
    80  )
    81  
    82  // Describes the state of a migration at a certain point.
    83  type MigrationCondition struct {
    84  	// Type of the condition.
    85  	Type MigrationConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=MigrationConditionType"`
    86  	// Status of the condition, one of True, False, Unknown.
    87  	Status corev1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
    88  	// The last time this condition was updated.
    89  	// +optional
    90  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,3,opt,name=lastUpdateTime"`
    91  	// The reason for the condition's last transition.
    92  	// +optional
    93  	Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
    94  	// A human readable message indicating details about the transition.
    95  	// +optional
    96  	Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
    97  }
    98  
    99  // Status of the storage version migration.
   100  type StorageVersionMigrationStatus struct {
   101  	// The latest available observations of the migration's current state.
   102  	// +patchMergeKey=type
   103  	// +patchStrategy=merge
   104  	// +listType=map
   105  	// +listMapKey=type
   106  	// +optional
   107  	Conditions []MigrationCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
   108  	// ResourceVersion to compare with the GC cache for performing the migration.
   109  	// This is the current resource version of given group, version and resource when
   110  	// kube-controller-manager first observes this StorageVersionMigration resource.
   111  	ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,2,opt,name=resourceVersion"`
   112  }
   113  
   114  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   115  // +k8s:prerelease-lifecycle-gen:introduced=1.30
   116  
   117  // StorageVersionMigrationList is a collection of storage version migrations.
   118  type StorageVersionMigrationList struct {
   119  	metav1.TypeMeta `json:",inline"`
   120  
   121  	// Standard list metadata
   122  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   123  	// +optional
   124  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
   125  	// Items is the list of StorageVersionMigration
   126  	// +patchMergeKey=type
   127  	// +patchStrategy=merge
   128  	// +listType=map
   129  	// +listMapKey=type
   130  	Items []StorageVersionMigration `json:"items" listType:"map" listMapKey:"type" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=items"`
   131  }
   132  

View as plain text