mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-23 05:41:19 -05:00
operators: pass additional components to upgrade-agent
This commit is contained in:
parent
6f1b6b532f
commit
070c23f876
@ -358,14 +358,8 @@ func (r *NodeVersionReconciler) tryStartClusterVersionUpgrade(ctx context.Contex
|
|||||||
|
|
||||||
log.FromContext(ctx).Info("Starting cluster upgrade", "clusterVersion", nodeVersion.Spec.KubernetesClusterVersion)
|
log.FromContext(ctx).Info("Starting cluster upgrade", "clusterVersion", nodeVersion.Spec.KubernetesClusterVersion)
|
||||||
|
|
||||||
kubeadm, err := clusterComponents.GetKubeadmComponent()
|
|
||||||
if err != nil {
|
|
||||||
log.FromContext(ctx).Error(err, "Unable to get kubeadm component")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// talk to the upgrade-agent to start the upgrade
|
// talk to the upgrade-agent to start the upgrade
|
||||||
if err := r.Upgrade(ctx, kubeadm.Url, kubeadm.Hash, nodeVersion.Spec.KubernetesClusterVersion); err != nil {
|
if err := r.Upgrade(ctx, clusterComponents.GetUpgradableComponents(), nodeVersion.Spec.KubernetesClusterVersion); err != nil {
|
||||||
log.FromContext(ctx).Error(err, "Unable to upgrade cluster")
|
log.FromContext(ctx).Error(err, "Unable to upgrade cluster")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -935,7 +929,7 @@ type etcdRemover interface {
|
|||||||
|
|
||||||
type clusterUpgrader interface {
|
type clusterUpgrader interface {
|
||||||
// UpgradeCluster upgrades the cluster to the specified version.
|
// UpgradeCluster upgrades the cluster to the specified version.
|
||||||
Upgrade(ctx context.Context, KubeadmURL, KubeadmHash, WantedKubernetesVersion string) error
|
Upgrade(ctx context.Context, kubernetesComponents components.Components, WantedKubernetesVersion string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type kubernetesServerVersionGetter interface {
|
type kubernetesServerVersionGetter interface {
|
||||||
|
@ -7,6 +7,7 @@ go_library(
|
|||||||
visibility = ["//operators/constellation-node-operator:__subpackages__"],
|
visibility = ["//operators/constellation-node-operator:__subpackages__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//internal/constants",
|
"//internal/constants",
|
||||||
|
"//internal/versions/components",
|
||||||
"//upgrade-agent/upgradeproto",
|
"//upgrade-agent/upgradeproto",
|
||||||
"@org_golang_google_grpc//:go_default_library",
|
"@org_golang_google_grpc//:go_default_library",
|
||||||
"@org_golang_google_grpc//credentials/insecure",
|
"@org_golang_google_grpc//credentials/insecure",
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
mainconstants "github.com/edgelesssys/constellation/v2/internal/constants"
|
mainconstants "github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/upgrade-agent/upgradeproto"
|
"github.com/edgelesssys/constellation/v2/upgrade-agent/upgradeproto"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -31,7 +32,7 @@ func NewClient() *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Upgrade upgrades the Constellation node to the given Kubernetes version.
|
// Upgrade upgrades the Constellation node to the given Kubernetes version.
|
||||||
func (c *Client) Upgrade(ctx context.Context, KubeadmURL, KubeadmHash, WantedKubernetesVersion string) error {
|
func (c *Client) Upgrade(ctx context.Context, kubernetesComponents components.Components, WantedKubernetesVersion string) error {
|
||||||
conn, err := grpc.DialContext(ctx, mainconstants.UpgradeAgentMountPath, grpc.WithTransportCredentials(insecure.NewCredentials()),
|
conn, err := grpc.DialContext(ctx, mainconstants.UpgradeAgentMountPath, grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||||
grpc.WithContextDialer(
|
grpc.WithContextDialer(
|
||||||
func(ctx context.Context, addr string) (net.Conn, error) {
|
func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
@ -43,11 +44,24 @@ func (c *Client) Upgrade(ctx context.Context, KubeadmURL, KubeadmHash, WantedKub
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
// While we're transitioning between version 2.13 and 2.14, we need to
|
||||||
|
// expect an upgrade-agent that does not yet understand the
|
||||||
|
// KubernetesComponents proto field. Therefore, we pass the kubeadm
|
||||||
|
// component twice: once via KubeadmUrl/KubeadmHash, once as part of the
|
||||||
|
// kubernetesComponents argument.
|
||||||
|
kubeadm, err := kubernetesComponents.GetKubeadmComponent()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("expected a kubeadm Component: %w", err)
|
||||||
|
}
|
||||||
protoClient := upgradeproto.NewUpdateClient(conn)
|
protoClient := upgradeproto.NewUpdateClient(conn)
|
||||||
_, err = protoClient.ExecuteUpdate(ctx, &upgradeproto.ExecuteUpdateRequest{
|
_, err = protoClient.ExecuteUpdate(ctx, &upgradeproto.ExecuteUpdateRequest{
|
||||||
KubeadmUrl: KubeadmURL,
|
// TODO(burgerdev): remove these fields after releasing 2.14.
|
||||||
KubeadmHash: KubeadmHash,
|
// %< ---------------------------------
|
||||||
|
KubeadmUrl: kubeadm.Url,
|
||||||
|
KubeadmHash: kubeadm.Hash,
|
||||||
|
// %< ---------------------------------
|
||||||
WantedKubernetesVersion: WantedKubernetesVersion,
|
WantedKubernetesVersion: WantedKubernetesVersion,
|
||||||
|
KubernetesComponents: kubernetesComponents,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to execute update: %w", err)
|
return fmt.Errorf("failed to execute update: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user