Skip to content

Remove non-generic resource items from AppWrapper API #457

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

Merged
merged 1 commit into from
Jul 24, 2023
Merged
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
75 changes: 14 additions & 61 deletions pkg/apis/controller/v1beta1/appwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const AppWrapperPlural string = "appwrappers"
// which AppWrapper it belongs to.
const AppWrapperAnnotationKey = "appwrapper.mcad.ibm.com/appwrapper-name"

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// Definition of AppWrapper class
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -54,7 +54,7 @@ type AppWrapper struct {
Status AppWrapperStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// AppWrapperList is a collection of AppWrappers.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -89,8 +89,6 @@ type AppWrapperResourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

// +optional
Items []AppWrapperResource `json:"Items"`
// +optional
GenericItems []AppWrapperGenericResource `json:"GenericItems"`
}
Expand All @@ -100,42 +98,7 @@ type AppWrapperService struct {
Spec v1.ServiceSpec `json:"spec"`
}

// AppWrapperResource is App Wrapper aggregation resource
// todo: To be depricated
type AppWrapperResource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
// Replicas is the number of desired replicas
Replicas int32 `json:"replicas,omitempty" protobuf:"bytes,2,opt,name=replicas"`

// The minimal available pods to run for this AppWrapper; the default value is nil
MinAvailable *int32 `json:"minavailable,omitempty" protobuf:"bytes,3,opt,name=minavailable"`

// The number of allocated replicas from this resource type
// +optional
AllocatedReplicas int32 `json:"allocatedreplicas"`

// +kubebuilder:validation:Type=number
// +kubebuilder:validation:Format=float
// +optional
Priority float64 `json:"priority,omitempty"`

// The increasing rate of priority value for this resource
// +kubebuilder:validation:Type=number
// +kubebuilder:validation:Format=float
PrioritySlope float64 `json:"priorityslope"`

//The type of the resource (is the resource a Pod, a ReplicaSet, a ... ?)
// +optional
Type ResourceType `json:"type"`

//The template for the resource; it is now a raw text because we don't know for what resource
//it should be instantiated
// +kubebuilder:pruning:PreserveUnknownFields
Template runtime.RawExtension `json:"template"`
}

// AppWrapperResource is App Wrapper aggregation resource
// AppWrapperGenericResource is App Wrapper aggregation resource
type AppWrapperGenericResource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Expand All @@ -161,25 +124,25 @@ type AppWrapperGenericResource struct {
// +kubebuilder:validation:Format=float
PrioritySlope float64 `json:"priorityslope"`

//The template for the resource; it is now a raw text because we don't know for what resource
//it should be instantiated
// The template for the resource; it is now a raw text because we don't know for what resource
// it should be instantiated
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:EmbeddedResource
GenericTemplate runtime.RawExtension `json:"generictemplate"`

//Optional section that specifies resource requirements for non-standard k8s resources, follows same format as that
// Optional section that specifies resource requirements for non-standard k8s resources, follows same format as that
// of standard k8s resources
CustomPodResources []CustomPodResourceTemplate `json:"custompodresources,omitempty"`

//Optional field for users to determine completion status of item
// Optional field for users to determine completion status of item
CompletionStatus string `json:"completionstatus,omitempty"`
}

type CustomPodResourceTemplate struct {
Replicas int `json:"replicas"`
//todo: replace with
//Containers []Container Contain v1.ResourceRequirements
// todo: replace with
// Containers []Container Contain v1.ResourceRequirements
Requests v1.ResourceList `json:"requests"`

// +optional
Expand All @@ -190,17 +153,7 @@ type CustomPodResourceTemplate struct {
type ResourceType string

const (
ResourceTypePod ResourceType = "Pod"
ResourceTypeService ResourceType = "Service"
ResourceTypeSecret ResourceType = "Secret"
ResourceTypeStatefulSet ResourceType = "StatefulSet"
ResourceTypeDeployment ResourceType = "Deployment"
ResourceTypeReplicaSet ResourceType = "ReplicaSet"
ResourceTypePersistentVolume ResourceType = "PersistentVolume"
ResourceTypePersistentVolumeClaim ResourceType = "PersistentVolumeClaim"
ResourceTypeNamespace ResourceType = "Namespace"
ResourceTypeConfigMap ResourceType = "ConfigMap"
ResourceTypeNetworkPolicy ResourceType = "NetworkPolicy"
ResourceTypePod ResourceType = "Pod"
)

// AppWrapperStatus represents the current state of a AppWrapper
Expand All @@ -224,13 +177,13 @@ type AppWrapperStatus struct {
// +optional
MinAvailable int32 `json:"template,omitempty" protobuf:"bytes,4,opt,name=template"`

//Can run?
// Can run?
CanRun bool `json:"canrun,omitempty" protobuf:"bytes,1,opt,name=canrun"`

//Is Dispatched?
// Is Dispatched?
IsDispatched bool `json:"isdispatched,omitempty" protobuf:"bytes,1,opt,name=isdispatched"`

//State - Pending, Running, Failed, Deleted
// State - Pending, Running, Failed, Deleted
State AppWrapperState `json:"state,omitempty"`

Message string `json:"message,omitempty"`
Expand Down
31 changes: 0 additions & 31 deletions pkg/apis/controller/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading