Skip to content

Guarantee functions are not lost after Knative update

What does this MR do?

This MR not only renames Cluster::Concerns::ApplicationStatus.installed to Cluster::Concerns::ApplicationStatus.available but also include applications with the state udpated to it, so that functions are properly found for Knative installed and updated apps. Explanation below:

After updating Knative, the app state will be updated instead of installed.

In our FunctionsController we find our functions with the Projects::Serverless::FunctionsFinder:

def finder
  Projects::Serverless::FunctionsFinder.new(project.clusters)
end

This finder will try to find the functions for clusters that are included in the Clusters::Cluster.with_knative_installed:

def execute
  knative_services.flatten.compact
end

def knative_service(environment_scope, name)
  clusters_with_knative_installed.preload_knative.map do |cluster|
  ...
end

def clusters_with_knative_installed
  @clusters.with_knative_installed
end

ultimately, with_knative_installed clusters scope will query clusters that have knative applications that are included in the Clusters::Applications::Knative.installedscope.

scope :with_knative_installed, -> { joins(:application_knative).merge(Clusters::Applications::Knative.installed) }

This change could also fix our Gitlab::UsageData.system_usage_data which also makes use of the above scope to count the number of installed Knative apps.

What are the relevant issue numbers?

#56937 (closed)

Does this MR meet the acceptance criteria?

Edited by Kamil Trzciński

Merge request reports