mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-20 23:36:29 -04:00
bootstrapper: don't error on etcdio in any case
This commit is contained in:
parent
a1f883fdf6
commit
451d51dc07
@ -56,7 +56,7 @@ func NewClient(log *slog.Logger) *Client {
|
||||
// Since it might be possible that the process just started (if this method is called
|
||||
// right after the kubelet started), it retries to do its work each second
|
||||
// until it succeeds or the timeout of 10 seconds is reached.
|
||||
func (c *Client) PrioritizeIO() error {
|
||||
func (c *Client) PrioritizeIO() {
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
@ -67,19 +67,19 @@ func (c *Client) PrioritizeIO() error {
|
||||
err := c.setIOPriority()
|
||||
if err == nil {
|
||||
// Success, return directly
|
||||
return nil
|
||||
return
|
||||
} else if errors.Is(err, ErrNoEtcdProcess) {
|
||||
c.log.Info("No etcd process found, retrying")
|
||||
} else {
|
||||
c.log.Warn("Prioritizing etcd I/O failed", "error", err)
|
||||
return fmt.Errorf("prioritizing etcd I/O: %w", err)
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ticker.C:
|
||||
case <-timeout.Done():
|
||||
c.log.Warn("Timed out waiting for etcd to start")
|
||||
return nil
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ type kubeAPIWaiter interface {
|
||||
}
|
||||
|
||||
type etcdIOPrioritizer interface {
|
||||
PrioritizeIO() error
|
||||
PrioritizeIO()
|
||||
}
|
||||
|
||||
// KubeWrapper implements Cluster interface.
|
||||
@ -152,9 +152,7 @@ func (k *KubeWrapper) InitCluster(
|
||||
}
|
||||
|
||||
k.log.Info("Prioritizing etcd I/O")
|
||||
if err := k.etcdIOPrioritizer.PrioritizeIO(); err != nil {
|
||||
k.log.Warn("Prioritizing etcd I/O failed", "error", err)
|
||||
}
|
||||
k.etcdIOPrioritizer.PrioritizeIO()
|
||||
|
||||
err = k.client.Initialize(kubeConfig)
|
||||
if err != nil {
|
||||
@ -265,9 +263,7 @@ func (k *KubeWrapper) JoinCluster(ctx context.Context, args *kubeadm.BootstrapTo
|
||||
// If on control plane (and thus with etcd), try to prioritize etcd I/O.
|
||||
if peerRole == role.ControlPlane {
|
||||
k.log.Info("Prioritizing etcd I/O")
|
||||
if err := k.etcdIOPrioritizer.PrioritizeIO(); err != nil {
|
||||
k.log.Warn("Prioritizing etcd I/O failed", "error", err)
|
||||
}
|
||||
k.etcdIOPrioritizer.PrioritizeIO()
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -329,9 +325,7 @@ func (k *KubeWrapper) StartKubelet() error {
|
||||
return fmt.Errorf("starting kubelet: %w", err)
|
||||
}
|
||||
|
||||
if err := k.etcdIOPrioritizer.PrioritizeIO(); err != nil {
|
||||
k.log.Warn("Prioritizing etcd I/O failed", "error", err)
|
||||
}
|
||||
k.etcdIOPrioritizer.PrioritizeIO()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -181,41 +181,6 @@ func TestInitCluster(t *testing.T) {
|
||||
k8sVersion: "1.19",
|
||||
wantErr: true,
|
||||
},
|
||||
"etcd prioritizer doesn't fail on error": {
|
||||
clusterUtil: stubClusterUtil{kubeconfig: []byte("someKubeconfig")},
|
||||
kubeAPIWaiter: stubKubeAPIWaiter{},
|
||||
etcdIOPrioritizer: stubEtcdIOPrioritizer{assert.AnError},
|
||||
providerMetadata: &stubProviderMetadata{
|
||||
selfResp: metadata.InstanceMetadata{
|
||||
Name: nodeName,
|
||||
ProviderID: providerID,
|
||||
VPCIP: privateIP,
|
||||
AliasIPRanges: []string{aliasIPRange},
|
||||
},
|
||||
getLoadBalancerHostResp: loadbalancerIP,
|
||||
getLoadBalancerPortResp: strconv.Itoa(constants.KubernetesPort),
|
||||
},
|
||||
wantConfig: k8sapi.KubeadmInitYAML{
|
||||
InitConfiguration: kubeadm.InitConfiguration{
|
||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
||||
KubeletExtraArgs: map[string]string{
|
||||
"node-ip": privateIP,
|
||||
"provider-id": providerID,
|
||||
},
|
||||
Name: nodeName,
|
||||
},
|
||||
},
|
||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
||||
ClusterName: "kubernetes",
|
||||
ControlPlaneEndpoint: loadbalancerIP,
|
||||
APIServer: kubeadm.APIServer{
|
||||
CertSANs: []string{privateIP},
|
||||
},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
k8sVersion: versions.Default,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
@ -403,28 +368,6 @@ func TestJoinCluster(t *testing.T) {
|
||||
role: role.Worker,
|
||||
wantErr: true,
|
||||
},
|
||||
"etcd prioritizer error doesn't fail": {
|
||||
clusterUtil: stubClusterUtil{},
|
||||
etcdIOPrioritizer: stubEtcdIOPrioritizer{assert.AnError},
|
||||
providerMetadata: &stubProviderMetadata{
|
||||
selfResp: metadata.InstanceMetadata{
|
||||
ProviderID: "provider-id",
|
||||
Name: "metadata-name",
|
||||
VPCIP: "192.0.2.1",
|
||||
},
|
||||
},
|
||||
k8sComponents: k8sComponents,
|
||||
role: role.Worker,
|
||||
wantConfig: kubeadm.JoinConfiguration{
|
||||
Discovery: kubeadm.Discovery{
|
||||
BootstrapToken: joinCommand,
|
||||
},
|
||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
||||
Name: "metadata-name",
|
||||
KubeletExtraArgs: map[string]string{"node-ip": "192.0.2.1"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
@ -627,10 +570,6 @@ func (s *stubKubeAPIWaiter) Wait(_ context.Context, _ kubewaiter.KubernetesClien
|
||||
return s.waitErr
|
||||
}
|
||||
|
||||
type stubEtcdIOPrioritizer struct {
|
||||
prioritizeErr error
|
||||
}
|
||||
type stubEtcdIOPrioritizer struct{}
|
||||
|
||||
func (s *stubEtcdIOPrioritizer) PrioritizeIO() error {
|
||||
return s.prioritizeErr
|
||||
}
|
||||
func (s *stubEtcdIOPrioritizer) PrioritizeIO() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user