Skip to content

Commit

Permalink
Fix corner case of cluster subscribed to multiple versions of the sam… (
Browse files Browse the repository at this point in the history
razee-io#1323)

* Fix corner case of cluster subscribed to multiple versions of the same channel

* fix testcase
  • Loading branch information
carrolp authored May 23, 2023
1 parent ac055e5 commit a67b0a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/apollo/test/channel.remote.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ describe('channel remote graphql test suite', () => {
},
],
},
}
},
});
console.log( `addSubscription result: ${JSON.stringify( result.data, null, 2 )}` );
const addSubscription = result.data.data.addSubscription;
Expand Down Expand Up @@ -723,7 +723,8 @@ describe('channel remote graphql test suite', () => {
expect(sub01).to.be.an('object');
expect(sub01.remote).to.be.an('object');
expect(sub01.remote.remoteType).to.equal('github');
expect(sub01.remote.parameters.length).to.equal(3); // One from the Config, one from the Version created with the channel, one from the new subscription
console.log( `PLC sub01.remote.parameters: ${JSON.stringify( sub01.remote.parameters, null, 2 )}` );
expect(sub01.remote.parameters.length).to.equal(2); // One from the Config merged with one from the Version
} catch (error) {
if (error.response) {
console.error('error encountered: ', error.response.data);
Expand Down
2 changes: 1 addition & 1 deletion app/utils/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getSubscriptionDetails = async(orgId, matchingSubscriptions, cluster) => {
else if( channel.contentType === CHANNEL_CONSTANTS.CONTENTTYPES.REMOTE ) {
sub.remote = {
remoteType: channel.remote.remoteType,
parameters: channel.remote.parameters || [],
parameters: channel.remote.parameters ? _.cloneDeep(channel.remote.parameters) : [], // cloning channel params prevents incorrect behavior if a cluster is subscribed to multiple versions of the same channel
};
// Find version (avoid using deprecated/ignored `versions` attribute on the channel)
const version = await models.DeployableVersion.findOne( { org_id: orgId, uuid: subscription.version_uuid } );
Expand Down

0 comments on commit a67b0a9

Please sign in to comment.