mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
Migrate from snapClient.VolumesnapshotV1alpha1Client to
snapClient.SnapshotV1alpha1Client and also update kube dependency Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
3bc6771df8
commit
22ff5c0911
14
vendor/k8s.io/kubernetes/pkg/kubectl/apps/kind_visitor.go
generated
vendored
14
vendor/k8s.io/kubernetes/pkg/kubectl/apps/kind_visitor.go
generated
vendored
@ -73,17 +73,3 @@ func (elem GroupKindElement) GroupMatch(groups ...string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// NoOpKindVisitor implements KindVisitor with no-op functions.
|
||||
type NoOpKindVisitor struct{}
|
||||
|
||||
var _ KindVisitor = &NoOpKindVisitor{}
|
||||
|
||||
func (*NoOpKindVisitor) VisitDaemonSet(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitDeployment(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitJob(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitPod(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitReplicaSet(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitReplicationController(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitStatefulSet(kind GroupKindElement) {}
|
||||
func (*NoOpKindVisitor) VisitCronJob(kind GroupKindElement) {}
|
||||
|
153
vendor/k8s.io/kubernetes/pkg/kubectl/describe/versioned/describe.go
generated
vendored
153
vendor/k8s.io/kubernetes/pkg/kubectl/describe/versioned/describe.go
generated
vendored
@ -29,10 +29,12 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/fatih/camelcase"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
||||
@ -43,7 +45,7 @@ import (
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
@ -189,7 +191,7 @@ func describerMap(clientConfig *rest.Config) (map[schema.GroupKind]describe.Desc
|
||||
{Group: rbacv1.GroupName, Kind: "RoleBinding"}: &RoleBindingDescriber{c},
|
||||
{Group: rbacv1.GroupName, Kind: "ClusterRoleBinding"}: &ClusterRoleBindingDescriber{c},
|
||||
{Group: networkingv1.GroupName, Kind: "NetworkPolicy"}: &NetworkPolicyDescriber{c},
|
||||
{Group: schedulingv1beta1.GroupName, Kind: "PriorityClass"}: &PriorityClassDescriber{c},
|
||||
{Group: schedulingv1.GroupName, Kind: "PriorityClass"}: &PriorityClassDescriber{c},
|
||||
}
|
||||
|
||||
return m, nil
|
||||
@ -302,8 +304,15 @@ func printUnstructuredContent(w PrefixWriter, level int, content map[string]inte
|
||||
}
|
||||
|
||||
func smartLabelFor(field string) string {
|
||||
commonAcronyms := []string{"API", "URL", "UID", "OSB", "GUID"}
|
||||
// skip creating smart label if field name contains
|
||||
// special characters other than '-'
|
||||
if strings.IndexFunc(field, func(r rune) bool {
|
||||
return !unicode.IsLetter(r) && r != '-'
|
||||
}) != -1 {
|
||||
return field
|
||||
}
|
||||
|
||||
commonAcronyms := []string{"API", "URL", "UID", "OSB", "GUID"}
|
||||
parts := camelcase.Split(field)
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
@ -661,7 +670,9 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
|
||||
w.Write(LEVEL_0, "Namespace:\t%s\n", pod.Namespace)
|
||||
if pod.Spec.Priority != nil {
|
||||
w.Write(LEVEL_0, "Priority:\t%d\n", *pod.Spec.Priority)
|
||||
w.Write(LEVEL_0, "PriorityClassName:\t%s\n", stringOrNone(pod.Spec.PriorityClassName))
|
||||
}
|
||||
if len(pod.Spec.PriorityClassName) > 0 {
|
||||
w.Write(LEVEL_0, "Priority Class Name:\t%s\n", stringOrNone(pod.Spec.PriorityClassName))
|
||||
}
|
||||
if pod.Spec.NodeName == "" {
|
||||
w.Write(LEVEL_0, "Node:\t<none>\n")
|
||||
@ -809,6 +820,8 @@ func describeVolumes(volumes []corev1.Volume, w PrefixWriter, space string) {
|
||||
printFlockerVolumeSource(volume.VolumeSource.Flocker, w)
|
||||
case volume.VolumeSource.Projected != nil:
|
||||
printProjectedVolumeSource(volume.VolumeSource.Projected, w)
|
||||
case volume.VolumeSource.CSI != nil:
|
||||
printCSIVolumeSource(volume.VolumeSource.CSI, w)
|
||||
default:
|
||||
w.Write(LEVEL_1, "<unknown>\n")
|
||||
}
|
||||
@ -1208,6 +1221,23 @@ func printFlockerVolumeSource(flocker *corev1.FlockerVolumeSource, w PrefixWrite
|
||||
flocker.DatasetName, flocker.DatasetUUID)
|
||||
}
|
||||
|
||||
func printCSIVolumeSource(csi *corev1.CSIVolumeSource, w PrefixWriter) {
|
||||
var readOnly bool
|
||||
var fsType string
|
||||
if csi.ReadOnly != nil && *csi.ReadOnly {
|
||||
readOnly = true
|
||||
}
|
||||
if csi.FSType != nil {
|
||||
fsType = *csi.FSType
|
||||
}
|
||||
w.Write(LEVEL_2, "Type:\tCSI (a Container Storage Interface (CSI) volume source)\n"+
|
||||
" Driver:\t%v\n"+
|
||||
" FSType:\t%v\n"+
|
||||
" ReadOnly:\t%v\n",
|
||||
csi.Driver, fsType, readOnly)
|
||||
printCSIPersistentVolumeAttributesMultiline(w, "VolumeAttributes", csi.VolumeAttributes)
|
||||
}
|
||||
|
||||
func printCSIPersistentVolumeSource(csi *corev1.CSIPersistentVolumeSource, w PrefixWriter) {
|
||||
w.Write(LEVEL_2, "Type:\tCSI (a Container Storage Interface (CSI) volume source)\n"+
|
||||
" Driver:\t%v\n"+
|
||||
@ -1491,6 +1521,8 @@ func describePersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim, events *co
|
||||
if pvc.Spec.VolumeMode != nil {
|
||||
w.Write(LEVEL_0, "VolumeMode:\t%v\n", *pvc.Spec.VolumeMode)
|
||||
}
|
||||
printPodsMultiline(w, "Mounted By", mountPods)
|
||||
|
||||
if len(pvc.Status.Conditions) > 0 {
|
||||
w.Write(LEVEL_0, "Conditions:\n")
|
||||
w.Write(LEVEL_1, "Type\tStatus\tLastProbeTime\tLastTransitionTime\tReason\tMessage\n")
|
||||
@ -1509,8 +1541,6 @@ func describePersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim, events *co
|
||||
DescribeEvents(events, w)
|
||||
}
|
||||
|
||||
printPodsMultiline(w, "Mounted By", mountPods)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@ -1936,6 +1966,9 @@ func DescribePodTemplate(template *corev1.PodTemplateSpec, w PrefixWriter) {
|
||||
}
|
||||
describeContainers("Containers", template.Spec.Containers, nil, nil, w, " ")
|
||||
describeVolumes(template.Spec.Volumes, w, " ")
|
||||
if len(template.Spec.PriorityClassName) > 0 {
|
||||
w.Write(LEVEL_1, "Priority Class Name:\t%s\n", template.Spec.PriorityClassName)
|
||||
}
|
||||
}
|
||||
|
||||
// ReplicaSetDescriber generates information about a ReplicaSet and the pods it has created.
|
||||
@ -2087,7 +2120,7 @@ func describeCronJob(cronJob *batchv1beta1.CronJob, events *corev1.EventList) (s
|
||||
w.Write(LEVEL_0, "Concurrency Policy:\t%s\n", cronJob.Spec.ConcurrencyPolicy)
|
||||
w.Write(LEVEL_0, "Suspend:\t%s\n", printBoolPtr(cronJob.Spec.Suspend))
|
||||
if cronJob.Spec.SuccessfulJobsHistoryLimit != nil {
|
||||
w.Write(LEVEL_0, "Successful Job History Limit:\t%d\n", cronJob.Spec.SuccessfulJobsHistoryLimit)
|
||||
w.Write(LEVEL_0, "Successful Job History Limit:\t%d\n", *cronJob.Spec.SuccessfulJobsHistoryLimit)
|
||||
} else {
|
||||
w.Write(LEVEL_0, "Successful Job History Limit:\t<unset>\n")
|
||||
}
|
||||
@ -2258,7 +2291,7 @@ type IngressDescriber struct {
|
||||
}
|
||||
|
||||
func (i *IngressDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
c := i.ExtensionsV1beta1().Ingresses(namespace)
|
||||
c := i.NetworkingV1beta1().Ingresses(namespace)
|
||||
ing, err := c.Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -2266,7 +2299,7 @@ func (i *IngressDescriber) Describe(namespace, name string, describerSettings de
|
||||
return i.describeIngress(ing, describerSettings)
|
||||
}
|
||||
|
||||
func (i *IngressDescriber) describeBackend(ns string, backend *extensionsv1beta1.IngressBackend) string {
|
||||
func (i *IngressDescriber) describeBackend(ns string, backend *networkingv1beta1.IngressBackend) string {
|
||||
endpoints, _ := i.CoreV1().Endpoints(ns).Get(backend.ServiceName, metav1.GetOptions{})
|
||||
service, _ := i.CoreV1().Services(ns).Get(backend.ServiceName, metav1.GetOptions{})
|
||||
spName := ""
|
||||
@ -2286,7 +2319,7 @@ func (i *IngressDescriber) describeBackend(ns string, backend *extensionsv1beta1
|
||||
return formatEndpoints(endpoints, sets.NewString(spName))
|
||||
}
|
||||
|
||||
func (i *IngressDescriber) describeIngress(ing *extensionsv1beta1.Ingress, describerSettings describe.DescriberSettings) (string, error) {
|
||||
func (i *IngressDescriber) describeIngress(ing *networkingv1beta1.Ingress, describerSettings describe.DescriberSettings) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%v\n", ing.Name)
|
||||
@ -2297,7 +2330,7 @@ func (i *IngressDescriber) describeIngress(ing *extensionsv1beta1.Ingress, descr
|
||||
if def == nil {
|
||||
// Ingresses that don't specify a default backend inherit the
|
||||
// default backend in the kube-system namespace.
|
||||
def = &extensionsv1beta1.IngressBackend{
|
||||
def = &networkingv1beta1.IngressBackend{
|
||||
ServiceName: "default-http-backend",
|
||||
ServicePort: intstr.IntOrString{Type: intstr.Int, IntVal: 80},
|
||||
}
|
||||
@ -2339,7 +2372,7 @@ func (i *IngressDescriber) describeIngress(ing *extensionsv1beta1.Ingress, descr
|
||||
})
|
||||
}
|
||||
|
||||
func describeIngressTLS(w PrefixWriter, ingTLS []extensionsv1beta1.IngressTLS) {
|
||||
func describeIngressTLS(w PrefixWriter, ingTLS []networkingv1beta1.IngressTLS) {
|
||||
w.Write(LEVEL_0, "TLS:\n")
|
||||
for _, t := range ingTLS {
|
||||
if t.SecretName == "" {
|
||||
@ -3074,20 +3107,31 @@ type HorizontalPodAutoscalerDescriber struct {
|
||||
}
|
||||
|
||||
func (d *HorizontalPodAutoscalerDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
hpa, err := d.client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var events *corev1.EventList
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = d.client.CoreV1().Events(namespace).Search(scheme.Scheme, hpa)
|
||||
|
||||
// autoscaling/v2beta2 is introduced since v1.12 and autoscaling/v1 does not have full backward compatibility
|
||||
// with autoscaling/v2beta2, so describer will try to get and describe hpa v2beta2 object firstly, if it fails,
|
||||
// describer will fall back to do with hpa v1 object
|
||||
hpaV2beta2, err := d.client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).Get(name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = d.client.CoreV1().Events(namespace).Search(scheme.Scheme, hpaV2beta2)
|
||||
}
|
||||
return describeHorizontalPodAutoscalerV2beta2(hpaV2beta2, events, d)
|
||||
}
|
||||
|
||||
return describeHorizontalPodAutoscaler(hpa, events, d)
|
||||
hpaV1, err := d.client.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = d.client.CoreV1().Events(namespace).Search(scheme.Scheme, hpaV1)
|
||||
}
|
||||
return describeHorizontalPodAutoscalerV1(hpaV1, events, d)
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
|
||||
func describeHorizontalPodAutoscaler(hpa *autoscalingv2beta2.HorizontalPodAutoscaler, events *corev1.EventList, d *HorizontalPodAutoscalerDescriber) (string, error) {
|
||||
func describeHorizontalPodAutoscalerV2beta2(hpa *autoscalingv2beta2.HorizontalPodAutoscaler, events *corev1.EventList, d *HorizontalPodAutoscalerDescriber) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%s\n", hpa.Name)
|
||||
@ -3188,6 +3232,44 @@ func describeHorizontalPodAutoscaler(hpa *autoscalingv2beta2.HorizontalPodAutosc
|
||||
})
|
||||
}
|
||||
|
||||
func describeHorizontalPodAutoscalerV1(hpa *autoscalingv1.HorizontalPodAutoscaler, events *corev1.EventList, d *HorizontalPodAutoscalerDescriber) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%s\n", hpa.Name)
|
||||
w.Write(LEVEL_0, "Namespace:\t%s\n", hpa.Namespace)
|
||||
printLabelsMultiline(w, "Labels", hpa.Labels)
|
||||
printAnnotationsMultiline(w, "Annotations", hpa.Annotations)
|
||||
w.Write(LEVEL_0, "CreationTimestamp:\t%s\n", hpa.CreationTimestamp.Time.Format(time.RFC1123Z))
|
||||
w.Write(LEVEL_0, "Reference:\t%s/%s\n",
|
||||
hpa.Spec.ScaleTargetRef.Kind,
|
||||
hpa.Spec.ScaleTargetRef.Name)
|
||||
|
||||
if hpa.Spec.TargetCPUUtilizationPercentage != nil {
|
||||
w.Write(LEVEL_0, "Target CPU utilization:\t%d%%\n", *hpa.Spec.TargetCPUUtilizationPercentage)
|
||||
current := "<unknown>"
|
||||
if hpa.Status.CurrentCPUUtilizationPercentage != nil {
|
||||
current = fmt.Sprintf("%d", *hpa.Status.CurrentCPUUtilizationPercentage)
|
||||
}
|
||||
w.Write(LEVEL_0, "Current CPU utilization:\t%s%%\n", current)
|
||||
}
|
||||
|
||||
minReplicas := "<unset>"
|
||||
if hpa.Spec.MinReplicas != nil {
|
||||
minReplicas = fmt.Sprintf("%d", *hpa.Spec.MinReplicas)
|
||||
}
|
||||
w.Write(LEVEL_0, "Min replicas:\t%s\n", minReplicas)
|
||||
w.Write(LEVEL_0, "Max replicas:\t%d\n", hpa.Spec.MaxReplicas)
|
||||
w.Write(LEVEL_0, "%s pods:\t", hpa.Spec.ScaleTargetRef.Kind)
|
||||
w.Write(LEVEL_0, "%d current / %d desired\n", hpa.Status.CurrentReplicas, hpa.Status.DesiredReplicas)
|
||||
|
||||
if events != nil {
|
||||
DescribeEvents(events, w)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func describeNodeResource(nodeNonTerminatedPodsList *corev1.PodList, node *corev1.Node, w PrefixWriter) {
|
||||
w.Write(LEVEL_0, "Non-terminated Pods:\t(%d in total)\n", len(nodeNonTerminatedPodsList.Items))
|
||||
w.Write(LEVEL_1, "Namespace\tName\t\tCPU Requests\tCPU Limits\tMemory Requests\tMemory Limits\tAGE\n")
|
||||
@ -3713,7 +3795,7 @@ type PriorityClassDescriber struct {
|
||||
}
|
||||
|
||||
func (s *PriorityClassDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
|
||||
pc, err := s.SchedulingV1beta1().PriorityClasses().Get(name, metav1.GetOptions{})
|
||||
pc, err := s.SchedulingV1().PriorityClasses().Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -3726,7 +3808,7 @@ func (s *PriorityClassDescriber) Describe(namespace, name string, describerSetti
|
||||
return describePriorityClass(pc, events)
|
||||
}
|
||||
|
||||
func describePriorityClass(pc *schedulingv1beta1.PriorityClass, events *corev1.EventList) (string, error) {
|
||||
func describePriorityClass(pc *schedulingv1.PriorityClass, events *corev1.EventList) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%s\n", pc.Name)
|
||||
@ -3774,6 +3856,11 @@ func describePodSecurityPolicy(psp *policyv1beta1.PodSecurityPolicy) (string, er
|
||||
if len(psp.Spec.AllowedFlexVolumes) > 0 {
|
||||
w.Write(LEVEL_1, "Allowed FlexVolume Types:\t%s\n", flexVolumesToString(psp.Spec.AllowedFlexVolumes))
|
||||
}
|
||||
|
||||
if len(psp.Spec.AllowedCSIDrivers) > 0 {
|
||||
w.Write(LEVEL_1, "Allowed CSI Drivers:\t%s\n", csiDriversToString(psp.Spec.AllowedCSIDrivers))
|
||||
}
|
||||
|
||||
if len(psp.Spec.AllowedUnsafeSysctls) > 0 {
|
||||
w.Write(LEVEL_1, "Allowed Unsafe Sysctls:\t%s\n", sysctlsToString(psp.Spec.AllowedUnsafeSysctls))
|
||||
}
|
||||
@ -3839,6 +3926,14 @@ func flexVolumesToString(flexVolumes []policyv1beta1.AllowedFlexVolume) string {
|
||||
return stringOrDefaultValue(strings.Join(volumes, ","), "<all>")
|
||||
}
|
||||
|
||||
func csiDriversToString(csiDrivers []policyv1beta1.AllowedCSIDriver) string {
|
||||
drivers := []string{}
|
||||
for _, csiDriver := range csiDrivers {
|
||||
drivers = append(drivers, "driver="+csiDriver.Name)
|
||||
}
|
||||
return stringOrDefaultValue(strings.Join(drivers, ","), "<all>")
|
||||
}
|
||||
|
||||
func sysctlsToString(sysctls []string) string {
|
||||
return stringOrNone(strings.Join(sysctls, ","))
|
||||
}
|
||||
@ -4316,16 +4411,6 @@ func shorten(s string, maxLength int) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// translateTimestampUntil returns the elapsed time until timestamp in
|
||||
// human-readable approximation.
|
||||
func translateTimestampUntil(timestamp metav1.Time) string {
|
||||
if timestamp.IsZero() {
|
||||
return "<unknown>"
|
||||
}
|
||||
|
||||
return duration.HumanDuration(time.Until(timestamp.Time))
|
||||
}
|
||||
|
||||
// translateTimestampSince returns the elapsed time since timestamp in
|
||||
// human-readable approximation.
|
||||
func translateTimestampSince(timestamp metav1.Time) string {
|
||||
@ -4422,7 +4507,7 @@ func extractCSRStatus(csr *certificatesv1beta1.CertificateSigningRequest) (strin
|
||||
}
|
||||
|
||||
// backendStringer behaves just like a string interface and converts the given backend to a string.
|
||||
func backendStringer(backend *extensionsv1beta1.IngressBackend) string {
|
||||
func backendStringer(backend *networkingv1beta1.IngressBackend) string {
|
||||
if backend == nil {
|
||||
return ""
|
||||
}
|
||||
|
12
vendor/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go
generated
vendored
12
vendor/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go
generated
vendored
@ -38,13 +38,9 @@ import (
|
||||
deploymentutil "k8s.io/kubernetes/pkg/kubectl/util/deployment"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/podutils"
|
||||
"k8s.io/utils/integer"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func newInt32Ptr(val int) *int32 {
|
||||
ret := int32(val)
|
||||
return &ret
|
||||
}
|
||||
|
||||
func valOrZero(val *int32) int32 {
|
||||
if val == nil {
|
||||
return int32(0)
|
||||
@ -393,12 +389,12 @@ func (r *RollingUpdater) scaleDown(newRc, oldRc *corev1.ReplicationController, d
|
||||
nextOldVal := valOrZero(oldRc.Spec.Replicas) - decrement
|
||||
oldRc.Spec.Replicas = &nextOldVal
|
||||
if valOrZero(oldRc.Spec.Replicas) < 0 {
|
||||
oldRc.Spec.Replicas = newInt32Ptr(0)
|
||||
oldRc.Spec.Replicas = utilpointer.Int32Ptr(0)
|
||||
}
|
||||
// If the new is already fully scaled and available up to the desired size, go
|
||||
// ahead and scale old all the way down.
|
||||
if valOrZero(newRc.Spec.Replicas) == desired && newAvailable == desired {
|
||||
oldRc.Spec.Replicas = newInt32Ptr(0)
|
||||
oldRc.Spec.Replicas = utilpointer.Int32Ptr(0)
|
||||
}
|
||||
// Perform the scale-down.
|
||||
fmt.Fprintf(config.Out, "Scaling %s down to %d\n", oldRc.Name, valOrZero(oldRc.Spec.Replicas))
|
||||
@ -482,7 +478,7 @@ func (r *RollingUpdater) getOrCreateTargetControllerWithClient(controller *corev
|
||||
}
|
||||
controller.Annotations[desiredReplicasAnnotation] = fmt.Sprintf("%d", valOrZero(controller.Spec.Replicas))
|
||||
controller.Annotations[sourceIDAnnotation] = sourceID
|
||||
controller.Spec.Replicas = newInt32Ptr(0)
|
||||
controller.Spec.Replicas = utilpointer.Int32Ptr(0)
|
||||
newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(controller)
|
||||
return newRc, false, err
|
||||
}
|
||||
|
19
vendor/k8s.io/kubernetes/pkg/kubectl/scale.go
generated
vendored
19
vendor/k8s.io/kubernetes/pkg/kubectl/scale.go
generated
vendored
@ -21,11 +21,11 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
autoscalingapi "k8s.io/api/autoscaling/v1"
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
||||
scaleclient "k8s.io/client-go/scale"
|
||||
)
|
||||
|
||||
@ -95,7 +95,7 @@ func ScaleCondition(r Scaler, precondition *ScalePrecondition, namespace, name s
|
||||
}
|
||||
|
||||
// validateGeneric ensures that the preconditions match. Returns nil if they are valid, otherwise an error
|
||||
func (precondition *ScalePrecondition) validate(scale *autoscalingapi.Scale) error {
|
||||
func (precondition *ScalePrecondition) validate(scale *autoscalingv1.Scale) error {
|
||||
if precondition.Size != -1 && int(scale.Spec.Replicas) != precondition.Size {
|
||||
return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(int(scale.Spec.Replicas))}
|
||||
}
|
||||
@ -114,11 +114,15 @@ var _ Scaler = &genericScaler{}
|
||||
|
||||
// ScaleSimple updates a scale of a given resource. It returns the resourceVersion of the scale if the update was successful.
|
||||
func (s *genericScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint, gr schema.GroupResource) (updatedResourceVersion string, err error) {
|
||||
scale, err := s.scaleNamespacer.Scales(namespace).Get(gr, name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
scale := &autoscalingv1.Scale{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name},
|
||||
}
|
||||
if preconditions != nil {
|
||||
var err error
|
||||
scale, err = s.scaleNamespacer.Scales(namespace).Get(gr, name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := preconditions.validate(scale); err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -135,9 +139,6 @@ func (s *genericScaler) ScaleSimple(namespace, name string, preconditions *Scale
|
||||
// Scale updates a scale of a given resource to a new size, with optional precondition check (if preconditions is not nil),
|
||||
// optional retries (if retry is not nil), and then optionally waits for the status to reach desired count.
|
||||
func (s *genericScaler) Scale(namespace, resourceName string, newSize uint, preconditions *ScalePrecondition, retry, waitForReplicas *RetryParams, gr schema.GroupResource) error {
|
||||
if preconditions == nil {
|
||||
preconditions = &ScalePrecondition{-1, ""}
|
||||
}
|
||||
if retry == nil {
|
||||
// make it try only once, immediately
|
||||
retry = &RetryParams{Interval: time.Millisecond, Timeout: time.Millisecond}
|
||||
|
3
vendor/k8s.io/kubernetes/pkg/kubectl/scheme/install.go
generated
vendored
3
vendor/k8s.io/kubernetes/pkg/kubectl/scheme/install.go
generated
vendored
@ -45,6 +45,7 @@ import (
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
@ -56,6 +57,8 @@ import (
|
||||
func init() {
|
||||
// Register external types for Scheme
|
||||
metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
|
||||
utilruntime.Must(metav1beta1.AddMetaToScheme(Scheme))
|
||||
utilruntime.Must(metav1.AddMetaToScheme(Scheme))
|
||||
utilruntime.Must(scheme.AddToScheme(Scheme))
|
||||
|
||||
utilruntime.Must(Scheme.SetVersionPriority(corev1.SchemeGroupVersion))
|
||||
|
1
vendor/k8s.io/kubernetes/pkg/kubectl/util/deployment/deployment.go
generated
vendored
1
vendor/k8s.io/kubernetes/pkg/kubectl/util/deployment/deployment.go
generated
vendored
@ -109,7 +109,6 @@ func rsListFromClient(c appsclient.AppsV1Interface) rsListFunc {
|
||||
|
||||
// TODO: switch this to full namespacers
|
||||
type rsListFunc func(string, metav1.ListOptions) ([]*appsv1.ReplicaSet, error)
|
||||
type podListFunc func(string, metav1.ListOptions) (*corev1.PodList, error)
|
||||
|
||||
// listReplicaSets returns a slice of RSes the given deployment targets.
|
||||
// Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan),
|
||||
|
2
vendor/k8s.io/kubernetes/pkg/kubectl/util/storage/storage.go
generated
vendored
2
vendor/k8s.io/kubernetes/pkg/kubectl/util/storage/storage.go
generated
vendored
@ -28,7 +28,7 @@ import (
|
||||
// marks a class as the default StorageClass
|
||||
const IsDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class"
|
||||
|
||||
// BetaIsDefaultStorageClassAnnotation is the beta version of BetaIsDefaultStorageClassAnnotation.
|
||||
// BetaIsDefaultStorageClassAnnotation is the beta version of IsDefaultStorageClassAnnotation.
|
||||
const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class"
|
||||
|
||||
// IsDefaultAnnotationText returns a pretty Yes/No String if
|
||||
|
Reference in New Issue
Block a user