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

Wrong CRD may be referenced by Custom Resource in global_deploy #880

Open
arunikadhal opened this issue Mar 11, 2022 · 0 comments
Open

Wrong CRD may be referenced by Custom Resource in global_deploy #880

arunikadhal opened this issue Mar 11, 2022 · 0 comments

Comments

@arunikadhal
Copy link

Bug report

In global_deploy_task.rb, in

def discover_resources
      logger.info("Discovering resources:")
      resources = []
      crds_by_kind = cluster_resource_discoverer.crds.map { |crd| [crd.name, crd] }.to_h
      @template_sets.with_resource_definitions do |r_def|
        crd = crds_by_kind[r_def["kind"]]&.first
        r = KubernetesResource.build(context: context, logger: logger, definition: r_def,
          crd: crd, global_names: global_kinds, statsd_tags: statsd_tags)
        resources << r
        logger.info("  - #{r.id}")
      end
      StatsD.client.gauge('discover_resources.count', resources.size, tags: statsd_tags)
      resources.sort
    rescue InvalidTemplateError => e
      record_invalid_template(logger: logger, err: e.message, filename: e.filename, content: e.content)
      raise FatalDeploymentError, "Failed to parse template"
end

we are grouping crds by name but trying to extract using kind from r_def. There are no tests that currently catch this.

Proposal:
We should use a uniform approach to pick crds, either kind or name. It would be beneficial to use name since name is always unique. Following the changes made to fix this bug, we can also update deploy_task.rb to follow the same approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant