mirror of https://github.com/kubernetes/kops.git
Merge pull request #12973 from olemarkus/karpenter-npr
Various nill pointer fixes for karpenter
This commit is contained in:
commit
e0d22ce2f7
|
@ -34,10 +34,11 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubectl/pkg/drain"
|
||||
|
||||
api "k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/pkg/cloudinstances"
|
||||
"k8s.io/kops/pkg/validation"
|
||||
"k8s.io/kubectl/pkg/drain"
|
||||
)
|
||||
|
||||
const rollingUpdateTaintKey = "kops.k8s.io/scheduled-for-update"
|
||||
|
@ -680,7 +681,7 @@ func (c *RollingUpdateCluster) UpdateSingleInstance(cloudMember *cloudinstances.
|
|||
if detach {
|
||||
if cloudMember.CloudInstanceGroup.InstanceGroup.IsMaster() {
|
||||
klog.Warning("cannot detach master instances. Assuming --surge=false")
|
||||
} else {
|
||||
} else if cloudMember.CloudInstanceGroup.InstanceGroup.Spec.Manager != api.InstanceManagerKarpenter {
|
||||
err := c.detachInstance(cloudMember)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to detach instance: %v", err)
|
||||
|
|
|
@ -546,10 +546,12 @@ func deleteInstance(c AWSCloud, i *cloudinstances.CloudInstance) error {
|
|||
return fmt.Errorf("id was not set on CloudInstance: %v", i)
|
||||
}
|
||||
|
||||
if i.CloudInstanceGroup.InstanceGroup.Spec.Manager != kops.InstanceManagerKarpenter {
|
||||
err := deregisterInstanceFromClassicLoadBalancer(c, i)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to deregister instance from loadBalancer before terminating: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
request := &ec2.TerminateInstancesInput{
|
||||
InstanceIds: []*string{aws.String(id)},
|
||||
|
@ -576,7 +578,6 @@ func deregisterInstanceFromClassicLoadBalancer(c AWSCloud, i *cloudinstances.Clo
|
|||
asgDetails, err := c.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{asg.AutoScalingGroupName},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error describing autoScalingGroups: %v", err)
|
||||
}
|
||||
|
@ -599,7 +600,6 @@ func deregisterInstanceFromClassicLoadBalancer(c AWSCloud, i *cloudinstances.Clo
|
|||
InstanceId: aws.String(i.ID),
|
||||
}},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error describing instance health: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue