зеркало из https://github.com/Azure/ARO-RP.git
61 строка
1.6 KiB
Go
61 строка
1.6 KiB
Go
package frontend
|
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the Apache License 2.0.
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/Azure/ARO-RP/pkg/api"
|
|
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
|
"github.com/Azure/ARO-RP/pkg/frontend/middleware"
|
|
)
|
|
|
|
func (f *frontend) postAdminReconcileFailedNIC(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
|
r.URL.Path = filepath.Dir(r.URL.Path)
|
|
|
|
err := f._postAdminReconcileFailedNIC(ctx, r, log)
|
|
|
|
adminReply(log, w, nil, nil, err)
|
|
}
|
|
|
|
func (f *frontend) _postAdminReconcileFailedNIC(ctx context.Context, r *http.Request, log *logrus.Entry) error {
|
|
vars := mux.Vars(r)
|
|
resType, resName, resGroupName := vars["resourceType"], vars["resourceName"], vars["resourceGroupName"]
|
|
|
|
nicName := r.URL.Query().Get("nicName")
|
|
if err := validateNetworkInterfaceName(nicName); err != nil {
|
|
return err
|
|
}
|
|
|
|
resourceID := strings.TrimPrefix(r.URL.Path, "/admin")
|
|
|
|
doc, err := f.dbOpenShiftClusters.Get(ctx, resourceID)
|
|
switch {
|
|
case cosmosdb.IsErrorStatusCode(err, http.StatusNotFound):
|
|
return api.NewCloudError(http.StatusNotFound, api.CloudErrorCodeResourceNotFound, "", "The Resource '%s/%s' under resource group '%s' was not found.", resType, resName, resGroupName)
|
|
case err != nil:
|
|
return err
|
|
}
|
|
|
|
subscriptionDoc, err := f.getSubscriptionDocument(ctx, doc.Key)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
a, err := f.azureActionsFactory(log, f.env, doc.OpenShiftCluster, subscriptionDoc)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return a.NICReconcileFailedState(ctx, nicName)
|
|
}
|