mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
kubeadm: optimize and make the usage consistent about apierrors.IsNotFound
This commit is contained in:
parent
575031b68f
commit
d4cafe4738
@ -344,12 +344,12 @@ func migrateCoreDNSCorefile(client clientset.Interface, cm *v1.ConfigMap, corefi
|
||||
// GetCoreDNSInfo gets the current CoreDNS installed and the current Corefile Configuration of CoreDNS.
|
||||
func GetCoreDNSInfo(client clientset.Interface) (*v1.ConfigMap, string, string, error) {
|
||||
coreDNSConfigMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(context.TODO(), kubeadmconstants.CoreDNSConfigMap, metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return nil, "", "", nil
|
||||
}
|
||||
return nil, "", "", err
|
||||
}
|
||||
if apierrors.IsNotFound(err) {
|
||||
return nil, "", "", nil
|
||||
}
|
||||
corefile, ok := coreDNSConfigMap.Data["Corefile"]
|
||||
if !ok {
|
||||
return nil, "", "", errors.New("unable to find the CoreDNS Corefile data")
|
||||
|
@ -76,9 +76,9 @@ func NewClientBackedDryRunGetterFromKubeconfig(file string) (*ClientBackedDryRun
|
||||
// HandleGetAction handles GET actions to the dryrun clientset this interface supports
|
||||
func (clg *ClientBackedDryRunGetter) HandleGetAction(action core.GetAction) (bool, runtime.Object, error) {
|
||||
unstructuredObj, err := clg.dynamicClient.Resource(action.GetResource()).Namespace(action.GetNamespace()).Get(context.TODO(), action.GetName(), metav1.GetOptions{})
|
||||
// Inform the user that the requested object wasn't found.
|
||||
printIfNotExists(err)
|
||||
if err != nil {
|
||||
// Inform the user that the requested object wasn't found.
|
||||
printIfNotExists(err)
|
||||
return true, nil, err
|
||||
}
|
||||
newObj, err := decodeUnstructuredIntoAPIObject(action, unstructuredObj)
|
||||
|
@ -125,7 +125,7 @@ func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error {
|
||||
func (w *KubeWaiter) WaitForPodToDisappear(podName string) error {
|
||||
return wait.PollImmediate(kubeadmconstants.APICallRetryInterval, w.timeout, func() (bool, error) {
|
||||
_, err := w.client.CoreV1().Pods(metav1.NamespaceSystem).Get(context.TODO(), podName, metav1.GetOptions{})
|
||||
if apierrors.IsNotFound(err) {
|
||||
if err != nil && apierrors.IsNotFound(err) {
|
||||
fmt.Printf("[apiclient] The old Pod %q is now removed (which is desired)\n", podName)
|
||||
return true, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user