Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: strip down cluster and service sideloads #306

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/open-policy-agent/gatekeeper/v3 v3.17.1
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/pkg/errors v0.9.1
github.com/pluralsh/console/go/client v1.21.4
github.com/pluralsh/console/go/client v1.22.1
github.com/pluralsh/controller-reconcile-helper v0.1.0
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34
github.com/pluralsh/polly v0.1.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pluralsh/console/go/client v1.21.4 h1:LT0u/2b8HYTZtFUc/UBXqj08dD9y3R2FWU+zDHJxwMA=
github.com/pluralsh/console/go/client v1.21.4/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k=
github.com/pluralsh/console/go/client v1.22.1 h1:kC6QEiOkUnOGyJFugsPejzMNlM+4VgfJR1oST9Pxfkg=
github.com/pluralsh/console/go/client v1.22.1/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k=
github.com/pluralsh/controller-reconcile-helper v0.1.0 h1:BV3dYZFH5rn8ZvZjtpkACSv/GmLEtRftNQj/Y4ddHEo=
github.com/pluralsh/controller-reconcile-helper v0.1.0/go.mod h1:RxAbvSB4/jkvx616krCdNQXPbpGJXW3J1L3rASxeFOA=
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw=
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/argorollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r *ArgoRolloutReconciler) Reconcile(ctx context.Context, req ctrl.Request)
if serviceID == "" {
return ctrl.Result{}, fmt.Errorf("the service ID from the inventory annotation is empty")
}
service, err := r.ConsoleClient.GetService(serviceID)
service, err := r.ConsoleClient.GetServiceDeploymentComponents(serviceID)
if err != nil {
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (r *ArgoRolloutReconciler) rollback(rolloutIf clientset.RolloutInterface, r
return nil
}

func hasPausedRolloutComponent(service *console.GetServiceDeploymentForAgent_ServiceDeployment) bool {
func hasPausedRolloutComponent(service *console.GetServiceDeploymentComponents_ServiceDeployment) bool {
for _, component := range service.Components {
if component.Kind == rollouts.RolloutKind {
if component.State != nil && *component.State == console.ComponentStatePaused {
Expand Down
3 changes: 2 additions & 1 deletion pkg/client/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type Client interface {
UpdateClusterRestore(id string, attrs console.RestoreAttributes) (*console.ClusterRestoreFragment, error)
SaveClusterBackup(attrs console.BackupAttributes) (*console.ClusterBackupFragment, error)
GetClusterBackup(clusterID, namespace, name string) (*console.ClusterBackupFragment, error)
GetServices(after *string, first *int64) (*console.PagedClusterServices, error)
GetServices(after *string, first *int64) (*console.PagedClusterServiceIds, error)
GetService(id string) (*console.GetServiceDeploymentForAgent_ServiceDeployment, error)
GetServiceDeploymentComponents(id string) (*console.GetServiceDeploymentComponents_ServiceDeployment, error)
UpdateComponents(id, revisionID string, sha *string, components []*console.ComponentAttributes, errs []*console.ServiceErrorAttributes) error
AddServiceErrors(id string, errs []*console.ServiceErrorAttributes) error
ParsePipelineGateCR(pgFragment *console.PipelineGateFragment, operatorNamespace string) (*v1alpha1.PipelineGate, error)
Expand Down
16 changes: 12 additions & 4 deletions pkg/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import (
console "github.com/pluralsh/console/go/client"
)

func (c *client) GetServices(after *string, first *int64) (*console.PagedClusterServices, error) {

resp, err := c.consoleClient.PagedClusterServices(c.ctx, after, first, nil, nil)
func (c *client) GetServices(after *string, first *int64) (*console.PagedClusterServiceIds, error) {
resp, err := c.consoleClient.PagedClusterServiceIds(c.ctx, after, first, nil, nil)
if err != nil {
return nil, err
}
if resp.GetPagedClusterServices() == nil {
return nil, fmt.Errorf("the response from PagedClusterServices is nil")
return nil, fmt.Errorf("the response from PagedClusterServiceIds is nil")
}
return resp, nil
}
Expand All @@ -27,6 +26,15 @@ func (c *client) GetService(id string) (*console.GetServiceDeploymentForAgent_Se
return resp.ServiceDeployment, nil
}

func (c *client) GetServiceDeploymentComponents(id string) (*console.GetServiceDeploymentComponents_ServiceDeployment, error) {
resp, err := c.consoleClient.GetServiceDeploymentComponents(c.ctx, id)
if err != nil {
return nil, err
}

return resp.ServiceDeployment, nil
}

func (c *client) UpdateComponents(id, revisionID string, sha *string, components []*console.ComponentAttributes, errs []*console.ServiceErrorAttributes) error {
_, err := c.consoleClient.UpdateServiceComponents(c.ctx, id, components, revisionID, sha, errs)
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/service/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ func (s *ServiceReconciler) ShutdownQueue() {
s.svcQueue.ShutDown()
}

func (s *ServiceReconciler) ListServices(ctx context.Context) *algorithms.Pager[*console.ServiceDeploymentEdgeFragment] {
func (s *ServiceReconciler) ListServices(ctx context.Context) *algorithms.Pager[*console.ServiceDeploymentIDEdgeFragment] {
logger := log.FromContext(ctx)
logger.Info("create service pager")
fetch := func(page *string, size int64) ([]*console.ServiceDeploymentEdgeFragment, *algorithms.PageInfo, error) {
fetch := func(page *string, size int64) ([]*console.ServiceDeploymentIDEdgeFragment, *algorithms.PageInfo, error) {
resp, err := s.consoleClient.GetServices(page, &size)
if err != nil {
logger.Error(err, "failed to fetch service list from deployments service")
Expand All @@ -258,7 +258,7 @@ func (s *ServiceReconciler) ListServices(ctx context.Context) *algorithms.Pager[
}
return resp.PagedClusterServices.Edges, pageInfo, nil
}
return algorithms.NewPager[*console.ServiceDeploymentEdgeFragment](common2.DefaultPageSize, fetch)
return algorithms.NewPager[*console.ServiceDeploymentIDEdgeFragment](common2.DefaultPageSize, fetch)
}

func (s *ServiceReconciler) Poll(ctx context.Context) error {
Expand Down
72 changes: 65 additions & 7 deletions pkg/test/mocks/Client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading