-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove headless services for instance manager pods
longhorn-8844 Signed-off-by: Phan Le <phan.le@suse.com> (cherry picked from commit 8ee07d1)
- Loading branch information
1 parent
fca1d4d
commit d67e7b1
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package v162to163 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
clientset "k8s.io/client-go/kubernetes" | ||
|
||
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned" | ||
) | ||
|
||
const ( | ||
upgradeLogPrefix = "upgrade from v1.6.2 to v1.6.3: " | ||
) | ||
|
||
func UpgradeResources(namespace string, lhClient *lhclientset.Clientset, kubeClient *clientset.Clientset, resourceMaps map[string]interface{}) error { | ||
if err := deleteInstanceManagerServices(namespace, kubeClient); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func UpgradeResourcesStatus(namespace string, lhClient *lhclientset.Clientset, kubeClient *clientset.Clientset, resourceMaps map[string]interface{}) error { | ||
// Currently there are no resources status to upgrade. See previous Longhorn | ||
// versions for examples. | ||
return nil | ||
} | ||
|
||
func deleteInstanceManagerServices(namespace string, kubeClient *clientset.Clientset) (err error) { | ||
defer func() { | ||
err = errors.Wrapf(err, upgradeLogPrefix+"delete instance manager service failed") | ||
}() | ||
|
||
instanceManagerServiceNames := []string{"longhorn-engine-manager", "longhorn-replica-manager"} | ||
|
||
for _, serviceName := range instanceManagerServiceNames { | ||
if err := kubeClient.CoreV1().Services(namespace).Delete(context.TODO(), serviceName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |