mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Cleanup] Remove unused code (#1046)
This commit is contained in:
parent
4102f97dc0
commit
369952d147
6 changed files with 11 additions and 68 deletions
|
@ -538,18 +538,10 @@ func (d *Deployment) RenderPodForMember(ctx context.Context, acs sutil.ACS, spec
|
|||
return d.resources.RenderPodForMember(ctx, acs, spec, status, memberID, imageInfo)
|
||||
}
|
||||
|
||||
func (d *Deployment) RenderPodForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.Pod, error) {
|
||||
return d.resources.RenderPodForMemberFromCurrent(ctx, acs, memberID)
|
||||
}
|
||||
|
||||
func (d *Deployment) RenderPodTemplateForMember(ctx context.Context, acs sutil.ACS, spec api.DeploymentSpec, status api.DeploymentStatus, memberID string, imageInfo api.ImageInfo) (*core.PodTemplateSpec, error) {
|
||||
return d.resources.RenderPodTemplateForMember(ctx, acs, spec, status, memberID, imageInfo)
|
||||
}
|
||||
|
||||
func (d *Deployment) RenderPodTemplateForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.PodTemplateSpec, error) {
|
||||
return d.resources.RenderPodTemplateForMemberFromCurrent(ctx, acs, memberID)
|
||||
}
|
||||
|
||||
func (d *Deployment) SelectImage(spec api.DeploymentSpec, status api.DeploymentStatus) (api.ImageInfo, bool) {
|
||||
return d.resources.SelectImage(spec, status)
|
||||
}
|
||||
|
|
|
@ -227,14 +227,6 @@ func (ac *actionContext) GetAgencyCache() (agencyCache.State, bool) {
|
|||
return ac.context.GetAgencyCache()
|
||||
}
|
||||
|
||||
func (ac *actionContext) RenderPodForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.Pod, error) {
|
||||
return ac.context.RenderPodForMemberFromCurrent(ctx, acs, memberID)
|
||||
}
|
||||
|
||||
func (ac *actionContext) RenderPodTemplateForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.PodTemplateSpec, error) {
|
||||
return ac.context.RenderPodTemplateForMemberFromCurrent(ctx, acs, memberID)
|
||||
}
|
||||
|
||||
func (ac *actionContext) SetAgencyMaintenanceMode(ctx context.Context, enabled bool) error {
|
||||
return ac.context.SetAgencyMaintenanceMode(ctx, enabled)
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
upgraderules "github.com/arangodb/go-upgrade-rules"
|
||||
|
||||
|
@ -389,16 +387,16 @@ func memberImageInfo(spec api.DeploymentSpec, status api.MemberStatus, images ap
|
|||
|
||||
func (r *Reconciler) getPodDetails(ctx context.Context, apiObject k8sutil.APIObject, spec api.DeploymentSpec,
|
||||
group api.ServerGroup, status api.DeploymentStatus, m api.MemberStatus,
|
||||
planCtx PlanBuilderContext) (string, *core.Pod, *api.ArangoMember, bool) {
|
||||
planCtx PlanBuilderContext) (string, *api.ArangoMember, bool) {
|
||||
imageInfo, imageFound := planCtx.SelectImageForMember(spec, status, m)
|
||||
if !imageFound {
|
||||
// Image is not found, so rotation is not needed
|
||||
return "", nil, nil, false
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
member, ok := planCtx.ACS().CurrentClusterCache().ArangoMember().V1().GetSimple(m.ArangoMemberName(apiObject.GetName(), group))
|
||||
if !ok {
|
||||
return "", nil, nil, false
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
groupSpec := spec.GetServerGroupSpec(group)
|
||||
|
@ -406,16 +404,16 @@ func (r *Reconciler) getPodDetails(ctx context.Context, apiObject k8sutil.APIObj
|
|||
renderedPod, err := planCtx.RenderPodForMember(ctx, planCtx.ACS(), spec, status, m.ID, imageInfo)
|
||||
if err != nil {
|
||||
r.planLogger.Err(err).Error("Error while rendering pod")
|
||||
return "", nil, nil, false
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
checksum, err := resources.ChecksumArangoPod(groupSpec, renderedPod)
|
||||
if err != nil {
|
||||
r.planLogger.Err(err).Error("Error while getting pod checksum")
|
||||
return "", nil, nil, false
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
return checksum, renderedPod, member, true
|
||||
return checksum, member, true
|
||||
}
|
||||
|
||||
// arangoMemberPodTemplateNeedsUpdate returns true when the specification of the
|
||||
|
@ -425,7 +423,7 @@ func (r *Reconciler) getPodDetails(ctx context.Context, apiObject k8sutil.APIObj
|
|||
func (r *Reconciler) arangoMemberPodTemplateNeedsUpdate(ctx context.Context, apiObject k8sutil.APIObject, spec api.DeploymentSpec,
|
||||
group api.ServerGroup, status api.DeploymentStatus, m api.MemberStatus,
|
||||
planCtx PlanBuilderContext) (string, bool) {
|
||||
checksum, _, member, valid := r.getPodDetails(ctx, apiObject, spec, group, status, m, planCtx)
|
||||
checksum, member, valid := r.getPodDetails(ctx, apiObject, spec, group, status, m, planCtx)
|
||||
if valid && !member.Spec.Template.EqualPodSpecChecksum(checksum) {
|
||||
return "Pod Spec changed", true
|
||||
}
|
||||
|
|
|
@ -95,16 +95,6 @@ func (c *testContext) RenderPodForMember(ctx context.Context, acs sutil.ACS, spe
|
|||
}
|
||||
|
||||
func (c *testContext) RenderPodTemplateForMember(ctx context.Context, acs sutil.ACS, spec api.DeploymentSpec, status api.DeploymentStatus, memberID string, imageInfo api.ImageInfo) (*core.PodTemplateSpec, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *testContext) RenderPodForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.Pod, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (c *testContext) RenderPodTemplateForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.PodTemplateSpec, error) {
|
||||
return &core.PodTemplateSpec{}, nil
|
||||
}
|
||||
|
||||
|
@ -944,7 +934,10 @@ func TestCreatePlan(t *testing.T) {
|
|||
},
|
||||
Extender: func(t *testing.T, r *Reconciler, c *testCase) {
|
||||
// Add ArangoMember
|
||||
template, err := newPlanBuilderContext(r.context).RenderPodTemplateForMemberFromCurrent(context.Background(), c.context.ACS(), c.context.ArangoDeployment.Status.Members.Agents[0].ID)
|
||||
imageInfo, _ := c.context.SelectImage(c.context.ArangoDeployment.Spec, c.context.ArangoDeployment.Status)
|
||||
template, err := newPlanBuilderContext(r.context).RenderPodTemplateForMember(context.Background(), c.context.ACS(),
|
||||
c.context.ArangoDeployment.Spec, c.context.ArangoDeployment.Status,
|
||||
c.context.ArangoDeployment.Status.Members.Agents[0].ID, imageInfo)
|
||||
require.NoError(t, err)
|
||||
|
||||
checksum, err := resources.ChecksumArangoPod(c.context.ArangoDeployment.Spec.Agents, resources.CreatePodFromTemplate(template))
|
||||
|
|
|
@ -71,10 +71,6 @@ type DeploymentPodRenderer interface {
|
|||
RenderPodForMember(ctx context.Context, acs sutil.ACS, spec api.DeploymentSpec, status api.DeploymentStatus, memberID string, imageInfo api.ImageInfo) (*core.Pod, error)
|
||||
// RenderPodTemplateForMember Renders PodTemplate definition for member
|
||||
RenderPodTemplateForMember(ctx context.Context, acs sutil.ACS, spec api.DeploymentSpec, status api.DeploymentStatus, memberID string, imageInfo api.ImageInfo) (*core.PodTemplateSpec, error)
|
||||
// RenderPodForMemberFromCurrent Renders PodTemplate definition for member from current state
|
||||
RenderPodForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.Pod, error)
|
||||
// RenderPodTemplateForMemberFromCurrent Renders PodTemplate definition for member
|
||||
RenderPodTemplateForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.PodTemplateSpec, error)
|
||||
|
||||
DeploymentEndpoints
|
||||
}
|
||||
|
|
|
@ -291,34 +291,6 @@ func (r *Resources) RenderPodTemplateForMember(ctx context.Context, acs sutil.AC
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Resources) RenderPodTemplateForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.PodTemplateSpec, error) {
|
||||
if p, err := r.RenderPodForMemberFromCurrent(ctx, acs, memberID); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return &core.PodTemplateSpec{
|
||||
ObjectMeta: p.ObjectMeta,
|
||||
Spec: p.Spec,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Resources) RenderPodForMemberFromCurrent(ctx context.Context, acs sutil.ACS, memberID string) (*core.Pod, error) {
|
||||
spec := r.context.GetSpec()
|
||||
status, _ := r.context.GetStatus()
|
||||
|
||||
member, _, ok := status.Members.ElementByID(memberID)
|
||||
if !ok {
|
||||
return nil, errors.Newf("Member not found")
|
||||
}
|
||||
|
||||
imageInfo, imageFound := r.SelectImageForMember(spec, status, member)
|
||||
if !imageFound {
|
||||
return nil, errors.Newf("ImageInfo not found")
|
||||
}
|
||||
|
||||
return r.RenderPodForMember(ctx, acs, spec, status, member.ID, imageInfo)
|
||||
}
|
||||
|
||||
func (r *Resources) RenderPodForMember(ctx context.Context, acs sutil.ACS, spec api.DeploymentSpec, status api.DeploymentStatus, memberID string, imageInfo api.ImageInfo) (*core.Pod, error) {
|
||||
log := r.log.Str("section", "member")
|
||||
apiObject := r.context.GetAPIObject()
|
||||
|
|
Loading…
Reference in a new issue