Skip to content
Closed
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
632 changes: 0 additions & 632 deletions .tekton/assisted-service-rhel8-acm-ds-2-15-pull-request.yaml

This file was deleted.

629 changes: 0 additions & 629 deletions .tekton/assisted-service-rhel8-acm-ds-2-15-push.yaml

This file was deleted.

632 changes: 0 additions & 632 deletions .tekton/assisted-service-rhel8-acm-ds-main-pull-request.yaml

This file was deleted.

629 changes: 0 additions & 629 deletions .tekton/assisted-service-rhel8-acm-ds-main-push.yaml

This file was deleted.

632 changes: 0 additions & 632 deletions .tekton/assisted-service-rhel9-acm-ds-2-15-pull-request.yaml

This file was deleted.

629 changes: 0 additions & 629 deletions .tekton/assisted-service-rhel9-acm-ds-2-15-push.yaml

This file was deleted.

568 changes: 0 additions & 568 deletions .tekton/assisted-service-saas-main-pull-request.yaml

This file was deleted.

565 changes: 0 additions & 565 deletions .tekton/assisted-service-saas-main-push.yaml

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions internal/bminventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ func (b *bareMetalInventory) InstallClusterInternal(ctx context.Context, params
}

// Refresh schedulable masters again after all roles are assigned
if internalErr := b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *cluster.ID); internalErr != nil {
if internalErr := b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, cluster); internalErr != nil {
log.WithError(internalErr).Errorf("Failed to refresh SchedulableMastersForcedTrue while installing cluster <%s>", cluster.ID)
return internalErr
}
Expand Down Expand Up @@ -3488,7 +3488,7 @@ func (b *bareMetalInventory) V2DeregisterHostInternal(ctx context.Context, param
log.WithError(err).Warnf("Failed to refresh cluster after de-registerating host <%s>", params.HostID)
}
}
if err := b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *h.ClusterID); err != nil {
if err := b.clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, *h.ClusterID); err != nil {
log.WithError(err).Errorf("Failed to refresh SchedulableMastersForcedTrue while de-registering host <%s> to cluster <%s>", h.ID, h.ClusterID)
return err
}
Expand Down Expand Up @@ -5678,7 +5678,7 @@ func (b *bareMetalInventory) V2RegisterHost(ctx context.Context, params installe
}

if host.ClusterID != nil {
if err = b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *host.ClusterID); err != nil {
if err = b.clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, *host.ClusterID); err != nil {
log.WithError(err).Errorf("Failed to refresh SchedulableMastersForcedTrue while registering host <%s> to cluster <%s>", host.ID, host.ClusterID)
return installer.NewV2RegisterHostInternalServerError().
WithPayload(common.GenerateError(http.StatusInternalServerError, err))
Expand Down Expand Up @@ -5936,7 +5936,7 @@ func (b *bareMetalInventory) BindHostInternal(ctx context.Context, params instal
return nil, common.NewApiError(http.StatusInternalServerError, err)
}

if err = b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *cluster.ID); err != nil {
if err = b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, cluster); err != nil {
log.WithError(err).Errorf("Failed to refresh SchedulableMastersForcedTrue while binding host <%s> to cluster <%s>", host.ID, host.ClusterID)
return nil, common.NewApiError(http.StatusInternalServerError, err)
}
Expand Down Expand Up @@ -5982,7 +5982,7 @@ func (b *bareMetalInventory) UnbindHostInternal(ctx context.Context, params inst
}
}

if err = b.clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *host.ClusterID); err != nil {
if err = b.clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, *host.ClusterID); err != nil {
log.WithError(err).Errorf("Failed to refresh SchedulableMastersForcedTrue while unbinding host <%s> to cluster <%s>", host.ID, host.ClusterID)
return nil, common.NewApiError(http.StatusInternalServerError, err)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/bminventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ var _ = Describe("RegisterHost", func() {
infraEnv := createInfraEnv(db, *cluster.ID, *cluster.ID)

mockClusterApi.EXPECT().AcceptRegistration(gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrue(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrueWithClusterID(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockHostApi.EXPECT().RegisterHost(gomock.Any(), gomock.Any(), gomock.Any()).
DoAndReturn(func(ctx context.Context, h *models.Host, db *gorm.DB) error {
// validate that host is registered with auto-assign role
Expand Down Expand Up @@ -662,7 +662,7 @@ var _ = Describe("RegisterHost", func() {
infraEnv := createInfraEnv(db, *cluster.ID, *cluster.ID)

mockClusterApi.EXPECT().AcceptRegistration(gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrue(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrueWithClusterID(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockHostApi.EXPECT().RegisterHost(gomock.Any(), gomock.Any(), gomock.Any()).
DoAndReturn(func(ctx context.Context, h *models.Host, db *gorm.DB) error {
// validate that host is registered with auto-assign role
Expand Down Expand Up @@ -781,7 +781,7 @@ var _ = Describe("RegisterHost", func() {
}).Times(1)
mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockCRDUtils.EXPECT().CreateAgentCR(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrue(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrueWithClusterID(gomock.Any(), gomock.Any()).Return(nil).Times(1)

By("trying to register a host bound to day2 cluster")
reply := bm.V2RegisterHost(ctx, installer.V2RegisterHostParams{
Expand Down Expand Up @@ -18227,7 +18227,7 @@ var _ = Describe("V2DeregisterHost", func() {
eventstest.WithInfraEnvIdMatcher(infraEnvID.String()),
eventstest.WithSeverityMatcher(models.EventSeverityInfo)))
mockClusterApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("Bad Refresh Status"))
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrue(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrueWithClusterID(gomock.Any(), gomock.Any()).Return(nil).Times(1)
response := bm.V2DeregisterHost(ctx, params)
Expect(response).To(BeAssignableToTypeOf(&installer.V2DeregisterHostNoContent{}))
})
Expand Down Expand Up @@ -18272,7 +18272,7 @@ var _ = Describe("UnbindHost", func() {
eventstest.WithInfraEnvIdMatcher(infraEnvID.String()),
eventstest.WithSeverityMatcher(models.EventSeverityInfo)))
mockHostApi.EXPECT().UnbindHost(ctx, gomock.Any(), gomock.Any(), false)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrue(gomock.Any(), gomock.Any()).Return(nil).Times(1)
mockClusterApi.EXPECT().RefreshSchedulableMastersForcedTrueWithClusterID(gomock.Any(), gomock.Any()).Return(nil).Times(1)
response := bm.UnbindHost(ctx, params)
Expect(response).To(BeAssignableToTypeOf(&installer.UnbindHostOK{}))
})
Expand Down
25 changes: 16 additions & 9 deletions internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ type API interface {
PermanentClustersDeletion(ctx context.Context, olderThan strfmt.DateTime, objectHandler s3wrapper.API) error
DeregisterInactiveCluster(ctx context.Context, maxDeregisterPerInterval int, inactiveSince strfmt.DateTime) error
TransformClusterToDay2(ctx context.Context, cluster *common.Cluster, db *gorm.DB) error
RefreshSchedulableMastersForcedTrue(ctx context.Context, clusterID strfmt.UUID) error
RefreshSchedulableMastersForcedTrue(ctx context.Context, cluster *common.Cluster) error
RefreshSchedulableMastersForcedTrueWithClusterID(ctx context.Context, clusterID strfmt.UUID) error
HandleVerifyVipsResponse(ctx context.Context, clusterID strfmt.UUID, stepReply string) error
UpdateFinalizingStage(ctx context.Context, clusterID strfmt.UUID, finalizingStage models.FinalizingStage) error
}
Expand Down Expand Up @@ -656,7 +657,7 @@ func (m *Manager) ClusterMonitoring() {
m.triggerLeaseTimeoutEvent(ctx, cluster)
}

if err := m.RefreshSchedulableMastersForcedTrue(ctx, *cluster.ID); err != nil {
if err := m.RefreshSchedulableMastersForcedTrue(ctx, cluster); err != nil {
log.WithError(err).Errorf("failed to refresh cluster with ID '%s' masters schedulability", string(*cluster.ID))
}
duration := float64(time.Since(startTime).Milliseconds())
Expand Down Expand Up @@ -1734,8 +1735,19 @@ func (m *Manager) TransformClusterToDay2(ctx context.Context, cluster *common.Cl
return nil
}

func (m *Manager) RefreshSchedulableMastersForcedTrue(ctx context.Context, clusterID strfmt.UUID) error {
func (m *Manager) RefreshSchedulableMastersForcedTrue(ctx context.Context, cluster *common.Cluster) error {
// Refresh the value of SchedulableMastersForcedTrue which depends on the number of hosts registered with the cluster
var err error

newSchedulableMastersForcedTrue := common.ShouldMastersBeSchedulable(&cluster.Cluster)
if cluster.SchedulableMastersForcedTrue == nil || newSchedulableMastersForcedTrue != *cluster.SchedulableMastersForcedTrue {
err = m.updateSchedulableMastersForcedTrue(ctx, *cluster.ID, newSchedulableMastersForcedTrue)
}

return err
}

func (m *Manager) RefreshSchedulableMastersForcedTrueWithClusterID(ctx context.Context, clusterID strfmt.UUID) error {
log := logutil.FromContext(ctx, m.log)
var cluster *common.Cluster
var err error
Expand All @@ -1745,12 +1757,7 @@ func (m *Manager) RefreshSchedulableMastersForcedTrue(ctx context.Context, clust
return err
}

newSchedulableMastersForcedTrue := common.ShouldMastersBeSchedulable(&cluster.Cluster)
if cluster.SchedulableMastersForcedTrue == nil || newSchedulableMastersForcedTrue != *cluster.SchedulableMastersForcedTrue {
err = m.updateSchedulableMastersForcedTrue(ctx, clusterID, newSchedulableMastersForcedTrue)
}

return err
return m.RefreshSchedulableMastersForcedTrue(ctx, cluster)
}

func (m *Manager) updateSchedulableMastersForcedTrue(ctx context.Context, clusterID strfmt.UUID, newSchedulableMastersForcedTrue bool) error {
Expand Down
8 changes: 4 additions & 4 deletions internal/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3930,7 +3930,7 @@ var _ = Describe("Test RefreshSchedulableMastersForcedTrue", func() {
createWorkerHost(*cluster.ID, "", db)
}

err := clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *cluster.ID)
err := clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, *cluster.ID)
Expect(err).ToNot(HaveOccurred())

cluster = getClusterFromDB(*cluster.ID, db)
Expand All @@ -3943,7 +3943,7 @@ var _ = Describe("Test RefreshSchedulableMastersForcedTrue", func() {
createHost(*cluster.ID, "", db)
}

err := clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *cluster.ID)
err := clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, *cluster.ID)
Expect(err).ToNot(HaveOccurred())

cluster = getClusterFromDB(*cluster.ID, db)
Expand All @@ -3953,7 +3953,7 @@ var _ = Describe("Test RefreshSchedulableMastersForcedTrue", func() {
It("schedulableMastersForcedTrue should set a value when the existing value is nil", func() {
cluster := createCluster(nil)

err := clusterApi.RefreshSchedulableMastersForcedTrue(ctx, *cluster.ID)
err := clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, *cluster.ID)
Expect(err).ToNot(HaveOccurred())

cluster = getClusterFromDB(*cluster.ID, db)
Expand All @@ -3962,7 +3962,7 @@ var _ = Describe("Test RefreshSchedulableMastersForcedTrue", func() {

It("schedulableMastersForcedTrue should return an error when the cluster does not exists", func() {
invalidClusterID := strfmt.UUID(uuid.New().String())
err := clusterApi.RefreshSchedulableMastersForcedTrue(ctx, invalidClusterID)
err := clusterApi.RefreshSchedulableMastersForcedTrueWithClusterID(ctx, invalidClusterID)
Expect(err).To(HaveOccurred())
})
})
Expand Down
22 changes: 18 additions & 4 deletions internal/cluster/mock_cluster_api.go

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

7 changes: 7 additions & 0 deletions internal/network/connectivity_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package network
import (
"encoding/json"
"net"
"sort"

"github.com/go-openapi/strfmt"
"github.com/golang-collections/go-datastructures/bitarray"
Expand Down Expand Up @@ -633,5 +634,11 @@ func GatherL3ConnectedAddresses(hosts []*models.Host) (map[strfmt.UUID][]string,
}
}
}

// Sort address lists to ensure deterministic results across multiple function calls
for _, addresses := range ret {
sort.Strings(addresses)
}

return ret, nil
}
34 changes: 12 additions & 22 deletions internal/network/connectivity_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/openshift/assisted-service/models"
"github.com/thoas/go-funk"
)

type node struct {
Expand Down Expand Up @@ -873,15 +872,6 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
})
})
Context("L3 connected addresses", func() {
expectEquivalentMaps := func(actual, expected map[strfmt.UUID][]string) {
Expect(actual).To(HaveLen(len(expected)))
for key, actualValue := range actual {
expectedValue, ok := expected[key]
Expect(ok).To(BeTrue())
Expect(actualValue).To(HaveLen(len(expectedValue)))
Expect(expectedValue).To(ConsistOf(funk.Map(actualValue, func(s string) interface{} { return s }).([]interface{})...))
}
}
It("3 hosts with empty connectivity reports - no results expected", func() {
hosts := []*models.Host{
{
Expand Down Expand Up @@ -973,11 +963,11 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
}
ret, err := GatherL3ConnectedAddresses(hosts)
Expect(err).ToNot(HaveOccurred())
expectEquivalentMaps(ret, map[strfmt.UUID][]string{
Expect(ret).To(Equal(map[strfmt.UUID][]string{
*nodes[0].id: {nodes[0].addressNet1},
*nodes[1].id: {nodes[1].addressNet1},
*nodes[2].id: {nodes[2].addressNet1},
})
}))
})
It("3 hosts with connectivity reports with 2 networks - all host with connected addresses from both networks expected", func() {
hosts := []*models.Host{
Expand Down Expand Up @@ -1005,11 +995,11 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
}
ret, err := GatherL3ConnectedAddresses(hosts)
Expect(err).ToNot(HaveOccurred())
expectEquivalentMaps(ret, map[strfmt.UUID][]string{
Expect(ret).To(Equal(map[strfmt.UUID][]string{
*nodes[0].id: {nodes[0].addressNet1, nodes[0].addressNet2},
*nodes[1].id: {nodes[1].addressNet1, nodes[1].addressNet2},
*nodes[2].id: {nodes[2].addressNet1, nodes[2].addressNet2},
})
}))
})
It("3 hosts with connectivity reports with 2 networks, one direction missing - all hosts with connected addresses from both networks without all addresses expected", func() {
hosts := []*models.Host{
Expand Down Expand Up @@ -1037,11 +1027,11 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
}
ret, err := GatherL3ConnectedAddresses(hosts)
Expect(err).ToNot(HaveOccurred())
expectEquivalentMaps(ret, map[strfmt.UUID][]string{
Expect(ret).To(Equal(map[strfmt.UUID][]string{
*nodes[0].id: {nodes[0].addressNet1, nodes[0].addressNet2},
*nodes[1].id: {nodes[1].addressNet1},
*nodes[2].id: {nodes[2].addressNet1, nodes[2].addressNet2},
})
}))
})
It("4 hosts with connectivity reports with 2 networks - all host with connected addresses from both networks expected", func() {
hosts := []*models.Host{
Expand Down Expand Up @@ -1080,12 +1070,12 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
}
ret, err := GatherL3ConnectedAddresses(hosts)
Expect(err).ToNot(HaveOccurred())
expectEquivalentMaps(ret, map[strfmt.UUID][]string{
Expect(ret).To(Equal(map[strfmt.UUID][]string{
*nodes[0].id: {nodes[0].addressNet1, nodes[0].addressNet2},
*nodes[1].id: {nodes[1].addressNet1, nodes[1].addressNet2},
*nodes[2].id: {nodes[2].addressNet1, nodes[2].addressNet2},
*nodes[3].id: {nodes[3].addressNet1, nodes[3].addressNet2},
})
}))
})
It("4 hosts with connectivity reports with 2 networks, one host with single network - hosts with connected addresses from both networks expected", func() {
nodes[3].addressNet2 = ""
Expand Down Expand Up @@ -1125,12 +1115,12 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
}
ret, err := GatherL3ConnectedAddresses(hosts)
Expect(err).ToNot(HaveOccurred())
expectEquivalentMaps(ret, map[strfmt.UUID][]string{
Expect(ret).To(Equal(map[strfmt.UUID][]string{
*nodes[0].id: {nodes[0].addressNet1, nodes[0].addressNet2},
*nodes[1].id: {nodes[1].addressNet1, nodes[1].addressNet2},
*nodes[2].id: {nodes[2].addressNet1, nodes[2].addressNet2},
*nodes[3].id: {nodes[3].addressNet1},
})
}))
})
It("4 hosts with connectivity reports with 2 networks, no connectivity to 2 hosts - expect connected addresses only to the connected hosts", func() {
hosts := []*models.Host{
Expand Down Expand Up @@ -1167,10 +1157,10 @@ func GenerateL3ConnectivityGroupTests(ipV4 bool, net1CIDR, net2CIDR string) {
}
ret, err := GatherL3ConnectedAddresses(hosts)
Expect(err).ToNot(HaveOccurred())
expectEquivalentMaps(ret, map[strfmt.UUID][]string{
Expect(ret).To(Equal(map[strfmt.UUID][]string{
*nodes[2].id: {nodes[2].addressNet1, nodes[2].addressNet2},
*nodes[3].id: {nodes[3].addressNet1, nodes[3].addressNet2},
})
}))
})

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ var Operator = models.MonitoredOperator{
OperatorType: models.OperatorTypeOlm,
SubscriptionName: operatorSubscriptionName,
TimeoutSeconds: 30 * 60,
Bundles: pq.StringArray{},
Bundles: pq.StringArray{
operatorsCommon.BundleVirtualization.ID,
},
}

type operator struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ var Operator = models.MonitoredOperator{
OperatorType: models.OperatorTypeOlm,
SubscriptionName: operatorSubscriptionName,
TimeoutSeconds: 30 * 60,
Bundles: pq.StringArray{},
Bundles: pq.StringArray{
operatorscommon.BundleVirtualization.ID,
},
}

type operator struct {
Expand Down